-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support local+native usage #477
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the new classes for the different ways to access the engine! I'm curious as your thoughts about how this design can support multiple engines in the future. It looks like we're only supporting REISE.jl
in our local implementation (as opposed to including REISE
like the ssh implementation does), which is probably fine for now, but as we add new engines (e.g. switch
, PowerSimulations.jl
), would we add new launchers (e.g. NativeSwitchLauncher
, 'NativeREISEjlLauncher`) or do you think there's a better way of doing that?
|
||
def get_deployment_mode(): | ||
mode = os.getenv("DEPLOYMENT_MODE") | ||
if mode is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know making the server
deployment type the default is easiest for the team now, but should we think about moving to having local
be the default at some point? As our user base grows, that seems more intuitive/easier-to-use to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it's unclear to me what the default should be in the future, since the docker roadmap and (corresponding user stories) is still being scoped out. But it's something to keep in mind.
Good point - I think we'll have to refactor a bit for that. Ideally if we have a standard interface to each engine, I'm hoping we can call them the same way, just with a different configuration. Maybe something like
and subclassing via
Not sure exactly if/how this would work, but just sharing potential design, mainly based on this post super considered super |
63ffb49
to
126193e
Compare
Running into the following error when trying to run a scenario:
|
What REISE.jl did you check out? |
Good point, not jon/windows. |
This is one of this cross-package feature we love so much! |
Anybody go this setup to run a scenario? For me it hangs with the status "running". |
That's farther than I got |
What are you running? |
You could try to run a Scenatio in ERCOT (see this example) |
|
powersimdata/data_access/launcher.py
Outdated
None, which translates to gurobi | ||
:param bool extract_data: whether the results of the simulation engine should | ||
automatically extracted after the simulation has run. This defaults to True. | ||
:return: (*subprocess.Popen*) or (*requests.Response*) - either the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or (dict) ?
:raises ValueError: if invalid solver provided | ||
""" | ||
solvers = ("gurobi", "glpk") | ||
if solver is not None and solver.lower() not in solvers: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also check solver
is a str similarly as we did in _check_threads
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not as worried about that here, since it will still fail due to not matching one of the predefined solvers or not having a .lower()
method. Although, if you're referring to the error message we would get, then I could add it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I was thinking about the error message.
|
||
|
||
class HttpLauncher(Launcher): | ||
def _launch(self, threads=None, solver=None, extract_data=True): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need extract_data
here, given it is not passed to request
call anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah each _launch
method has to have the same signature, since we call it the same way (from Launcher.launch_simulation
) without knowing which subclass it is. I think we might end up passing it to the request eventually though.
|
||
|
||
class NativeLauncher(Launcher): | ||
def _launch(self, threads=None, solver=None, extract_data=True): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment for extract_data
.
powersimdata/scenario/execute.py
Outdated
:param bool extract_data: whether the results of the simulation engine should | ||
automatically extracted after the simulation has run. This defaults to True. | ||
:param str solver: the solver used for optimization. This defaults to | ||
None, which translates to gurobi | ||
:return: (*subprocess.Popen*) or (*requests.Response*) - either the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or (dict) ?
powersimdata/scenario/execute.py
Outdated
|
||
:raises NotImplementedError: if not running in container mode | ||
:return: (*dict*) -- progress information, or None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should elaborate the returns for different launchers, SSH, HTTP, native?
if mode == "1" or mode.lower() == "container": | ||
return DeploymentMode.Container | ||
if mode == "2" or mode.lower() == "local": | ||
return DeploymentMode.Local |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we need two assignment patterns for mode
: numbers and string, i.e. 1 == Container 2 == Local ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I guess one reason is to decouple the values we set for the environment variable from the internal details. Not sure of a concrete example of when we need this, but feels like it's more flexible if the numbers don't imply any particular behavior/semantics.
What is the status of the tests?
|
I've done successful tests natively on windows/mac and using plug. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it like that
Purpose
Add the remaining code changes so that the framework can be used locally, outside docker, on any os, using a local REISE.jl installation.
What the code is doing
launch_scenario
into subclasses for each use case, and similarly for extracting output.State.refresh
method so state changes have up to date information without re-initializing the instanceTesting
Usage Example/Visuals
The PR for documentation is Breakthrough-Energy/docs#62. For testing locally, I changed the name of the data directory to
ScenarioDataLocal
(in both PowerSimData and REISE.jl) so it won't collide with the existing data from the server.Time estimate
40 mins