Skip to content

Allow executable to be specified when creating plugins#75

Merged
nstauff merged 3 commits intowatts-dev:developmentfrom
paulromano:executable-init
Nov 29, 2022
Merged

Allow executable to be specified when creating plugins#75
nstauff merged 3 commits intowatts-dev:developmentfrom
paulromano:executable-init

Conversation

@paulromano
Copy link
Copy Markdown
Contributor

This PR adds an executable argument to the constructor of all our plugins so that a user can specify an executable at the time the plugin is created. @nstauff ran into an issue where PluginSerpent was complaining that the sss2 executable wasn't found, and the only way to fix it was to make sure that sss2 was found via the PATH environment variable. With this change, one can either 1) explicitly give the absolute path of the executable or 2) give the name of the executable and specify an associated environment variable (e.g., SERPENT_DIR). I'll note that the way the executable is handled is now must more consistent across the different plugin classes.

@paulromano paulromano requested a review from nstauff November 11, 2022 19:52
@nstauff nstauff requested a review from zhieejhia93 November 11, 2022 21:08
@nstauff
Copy link
Copy Markdown
Contributor

nstauff commented Nov 11, 2022

Thanks @paulromano - this looks good to me. @zhieejhia93 - could you try this out for SAS and RELAP executables?

@nstauff
Copy link
Copy Markdown
Contributor

nstauff commented Nov 11, 2022

@paulromano - while trying from my laptop, I am getting the following error - any idea how to fix this?

(base) c356021:1App_PyARC_UnitCell nstauff$ python watts_exec.py 
Traceback (most recent call last):
  File "watts_exec.py", line 14, in <module>
    import watts
  File "/Users/nstauff/Documents/CODES/WATTS/src/watts/__init__.py", line 4, in <module>
    from .plugin import *
  File "/Users/nstauff/Documents/CODES/WATTS/src/watts/plugin.py", line 306
    if (base_dir := os.environ.get(environment_variable)) is not None:
                 ^
SyntaxError: invalid syntax

@paulromano
Copy link
Copy Markdown
Contributor Author

@nstauff Oops, sorry I got too fancy. The := is the new assignment expression, which I had forgotten is only Python 3.8+. I'll change to support previous Python versions.

@nstauff
Copy link
Copy Markdown
Contributor

nstauff commented Nov 11, 2022

Thanks @paulromano - this is now running on my end.

@zhieejhia93
Copy link
Copy Markdown
Contributor

Thanks for the changes @paulromano and sorry for the delayed response. The changes work fine for the SAS executables. However, it seems like there's a small issue with the RELAP5 plugin where I run into the following error when I provide extra_args (used to be known as extra_options) as an argument to the plugin. Please note that the the plugin works fine if extra_args is not provided. Thank you.

TypeError: __init__() got an unexpected keyword argument 'extra_args'

@paulromano
Copy link
Copy Markdown
Contributor Author

@zhieejhia93 the extra_args argument is used at the time you call the plugin, not at the time you create it:

relap5 = watts.PluginRELAP(...)
params = watts.Parameters(...)
result = relap5(params, extra_args=[...])

Can you give that a try?

@zhieejhia93
Copy link
Copy Markdown
Contributor

Thanks @paulromano . It worked!

@nstauff nstauff merged commit ca16bba into watts-dev:development Nov 29, 2022
@paulromano paulromano deleted the executable-init branch November 29, 2022 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants