-
Notifications
You must be signed in to change notification settings - Fork 22
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
feat: add more command line inputs #109
Conversation
1178223
to
868ec69
Compare
0edb38b
to
f4d2c07
Compare
e14fe94
to
dc5a3ba
Compare
I got a warning during test run, just fyi. Each line is from stderr in the api response, and I removed a duplicate from line 74. The scenario still ran successfully though.
|
pyreisejl/utility/launchers.py
Outdated
|
||
return tuple([importlib.import_module(f"julia.{i}") for i in imports]) | ||
|
||
def parse_and_return_runtime(self, start, end): |
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 might call this just parse_runtime
since the return is kinda implied
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.
Done
pyreisejl/utility/launchers.py
Outdated
Julia(compiled_modules=False) | ||
from julia import Gurobi # noqa: F401 | ||
from julia import REISE | ||
Gurobi, REISE = self.init_julia(imports=["Gurobi", "REISE"]) |
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.
Since we don't use the gurobi import directly, you could do _, REISE = ...
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.
Done.
Yeah, this is from our custom parse-hdf5-matfile-to-nested-dict-of-arrays script, and it's not new. Everything still works fine, but we'll probably want to update the call to avoid this warning in the future. |
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.
LGTM. I was able to run simulations with both glpk and gurobi successfully, and your test of the new arguments looks sufficient.
One more question: is the default of 1 for num_segments consistent with the current behavior? |
Yes, see Line 48 in 332e3ca
|
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 set up my local environment for running REISE.jl on my mac and run similar tests as @danielolsen posted. It works!
bxia REISE.jl (daniel/more_command_line_inputs) $ python pyreisejl/utility/call.py -s '2016-01-01 00:00:00' -e '2016-01-01 05:00:00' -int 2 -i "/Users/bainanxia/OneDrive - Gates Ventures/Documents/local_scenario_runs/scenario_3217" -l 3 --solver GLPK
Validation complete!
Launching scenario with parameters:
{'num_segments': 3, 'interval': 2, 'n_interval': 3, 'start_index': 1, 'input_dir': '/Users/bainanxia/OneDrive - Gates Ventures/Documents/local_scenario_runs/scenario_3217', 'execute_dir': None, 'threads': None, 'julia_env': None, 'solver_kwargs': None}
INFO: threads not supported by GLPK, ignoring
Reading from folder: /Users/bainanxia/OneDrive - Gates Ventures/Documents/local_scenario_runs/scenario_3217
...loading case.mat
...loading demand.csv
...loading hydro.csv
...loading wind.csv
...loading solar.csv
File case_storage.mat not found in /Users/bainanxia/OneDrive - Gates Ventures/Documents/local_scenario_runs/scenario_3217
All scenario files loaded!
linearizing
All preparation complete!
Redirecting outputs, see stdout.log & stderr.err in outputfolder
Run time: 0:01:28
dc5a3ba
to
1700b77
Compare
Purpose
What is the code doing
Launcher
init, to minimize duplication in the childlaunch_scenario
methods.init_julia
method is added which will start a Julia session in the specified environment and import a given list of Julia packages. To be able to start in a given environment, we need to change the way we start the Julia sessions fromfrom julia.api import Julia; Julia(compiled_modules=False)
tofrom julia.api import LibJulia; api = LibJulia.load(); api.init_julia(["--compiled-modules=no"])
; these are equivalent, see https://pyjulia.readthedocs.io/en/latest/troubleshooting.html#turn-off-compilation-cache. This lets us add another command-line argument to start in a given project folder (environment), see https://julialang.github.io/Pkg.jl/v1.5/environments/#Using-someone-else's-projectparse_and_return_runtime
parse_runtime
method is added to minimize duplication in the childlaunch_scenario
methods.Usage Example
First, we'll set up a new Julia environment in an arbitrary folder, and install REISE and GLPK into this environment:
Then, let's use all of our new command line parameters, executing them inside this new environment:
This works even if GLPK is not installed in your default environment, which you can check with a simple import in fresh julia session:
Time to review
30 minutes.