Closed danielolsen closed 3 years ago
Per conversations with @BainanXia and @rouille, I've refactored this so that we remove the os.chdir
call and pass all directories explicitly to Switch. I also added a validation step to make sure that the required modules.txt file exists in the input directory. The call signature to our call.py scripts remains the same for now, but eventually if we have non-default directories for the input/output dirs, we can add these as inputs to call.py and we're more set up for passing these to the command-line call to Switch.
Tested successfully on the server.
Pull Request doc
Purpose
Add a script which can be used to launch Switch on a directory, with the appropriate default settings and input validation. Closes #52.
What the code is doing
In the
launch_switch
function, input parameters are translated to a list of commands to launch in the appropriate folder viasubprocess.run()
, and the current working directory is restored afterwards no matter what. There is anif __name__ == "__main__"
block to allow command-line invocation.Testing
Tested manually. Note: this relies on the executable named
switch
, installed as part ofswitch-model
, to be findable with the Path variable in the environment you are running in.Usage Example/Visuals
From the command line:
If we try with a folder that does't have an
inputs
subdirectory:From python:
Time estimate
5 minutes to understand the current code. @YifanLi86 & @danlivengood, if this is not the workflow you would prefer to use to launch simulations for now, please let me know. Eventually we will probably want to manage inputs/output files for a series of runs, and this will evolve, but that will be a subsequent evolution, not part of this PR.