-
Notifications
You must be signed in to change notification settings - Fork 0
Add cwd option to add_process #469
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
Conversation
simvue/executor.py
Outdated
@@ -203,10 +208,20 @@ def callback_function(status_code: int, std_out: str, std_err: str) -> None: | |||
) | |||
|
|||
if script: | |||
self._runner.save_file(file_path=script, category="code") | |||
if cwd: |
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.
Can simplify this to:
self._runner.save_file(
file_path=os.path.join(cwd or os.getcwd(), script), category="code"
)
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.
My issue with this would be what if they've provided the absolute path to the script? Will it not then duplicate the start of the path and fail to find the file?
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.
Well the issue then is that someone could provide both cwd
and the path to their script as an absolute path.
I don't really agree with script being a string this creates ambiguity:
cwd
should be directory to run process in.script
should be a path to the script to execute.
The two are not related as you might want to run a script from another directory in the current directory. I think the solution here is unstable
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.
Looks good, this can go in
For the FDS connector to be able to support executing a simulation in a different working directory to the place where the connector is called, need to be able to specify a working directory for the process to use (since FDS always puts results into the working directory). Added this as an option to the
add_process
method, which then just passes thecwd
parameter through to the subprocess.This now assumes that the path to the
script
orinput_file
are relative to thecwd
parameter, so have updated the file upload inadd_process
to join together these paths before trying to find the file ifcwd
is specified. Also had to loosen the typing forscript
andinput_file
to accept a string or Path, since the path provided for either of these may not exist ifcwd
is specified.Added a test which checks this functionality