-
Notifications
You must be signed in to change notification settings - Fork 392
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
Add additional python path for use with EP-Launch #8985
Conversation
Looking at this, I'm not sure this is the best path forward. I would kinda like EPLaunch itself to handle this custom behavior rather than E+ itself. We only add a few paths that we absolutely need to make the plugin system function and then allow the user to add custom folders for their workflows. While EP-Launch is our own tool and not some random thing, it's also an old tool that we are trying to replace with EPLaunch 3. I guess maybe this could've been an IDD switch. I dunno. @JasonGlazer what do you think? |
I'm not against it but I think we should have a field in PythonPlugin:SearchPaths to turn this on or off. |
Could this be accomplished via the Add Current Working Directory to Search Path field? Not sure what EP-Launch uses for the working directory, but it could be set to the IDF directory before it is copied, then if the python file is alongside the original IDF it would be found. |
@bonnema EP-Launch creates a new directory below the IDF that it copies the IDF into uses for the CWD. EP-Launch uses the I am okay adding a separate field as @JasonGlazer suggested, but that would mean it would have to wait for a future release since we are are wrapping up IO freeze for this release. |
I see. So the working and IDF directory are the same, and you cannot really switch either or else it will break other stuff. |
Here's a suggestion. In epl-run.bat, when EnergyPlus is executed, use command line arguments to point to the input file, let the outputs default into the temporary CWD and everything else in epl-run.bat should finish up the same as before. There would need to be some logic to track whether the original idf, or epmif, or expidf should be executed (but that |
Hey @Myoldmopar @JasonGlazer @mjwitte, is the consensus that we should just hold off on this until the next release? |
What if EPLaunch just copied any Python files into the run directory along with the IDF? It could be really intelligent about it and look for PythonPlugin:Instances and then only copy Python filenames from that object, or it be simpler and could copy Python files that match the IDF name or all the Python files or something. That would match what it is doing with the IDF itself, which seems like a good option and doesn't require breaking EnergyPlus operation. |
I guess I don't see how the solution in this PR is breaking anything. EnergyPlus already looks for other files in the I don't really see this as an EPLaunch issue. I think it should work for anyone setting |
Well, currently this PR is breaking things because it is trying to call My main concern is introducing ambiguity into the Python search path. Right now the only path that is always searched is the EnergyPlus install directory. This has to be searched because that is where the If we add this change in, then is it possible that the user will have a Python file in two different folders and it will try to find the wrong one and the user won't have control to avoid it? If we make EPLaunch carry over the files so that the IDF, EPW, and Python files stay together during the run, or better yet if we make EPLaunch use the command line arguments so that it doesn't have to move anything around, then we don't have to introduce anything like this into EnergyPlus. While I get that EnergyPlus searches for things in |
That's fair @Myoldmopar. My feeling is that more users are going to be tripped up by not searching Maybe its worth re-thinking whether we want separate behavior for python modules and other external files. I think there is some utility in users being able to set a search path outside of EXE / IDF through an environment variable (e.g., if multiple users have a shared repo of python modules and they don't want to change the paths in the IDFs every time they run them on a different machine). I agree that if this goes in, it should be explicitly tested in integration tests. |
@matthew-larson @lgentile it has been 28 days since this pull request was last updated. |
Now that we are now in flexible I/O time, I think it would be good to wrap this one up. Earlier in the conversation I think we are felt OK adding a new input switch to solve this issue, but we were past I/O freeze. If we still feel that way, I'm happy to pick up this branch and modify it so it is protected by a new input field. |
@matthew-larson @lgentile it has been 28 days since this pull request was last updated. |
1 similar comment
@matthew-larson @lgentile it has been 28 days since this pull request was last updated. |
How do we feel about adding a new field to the SearchPaths object for searching the New field:
Original A4 and beyond will be moved down one index with a transition rule. Documentation will be updated accordingly. Let me know if that works or doesn't work and I'll do it and fix the seg fault as well. |
Alright, I think I got all the pieces in place. I tested the new input field and was able to find files based on |
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 good with these changes, but I'll let CI run on it before merging. If anyone sees anything missing, or you want to add anything @nealkruis or @matthew-larson have at it or let me know.
@@ -127,6 +127,12 @@ \subsubsection{Inputs} | |||
In these cases, it may be useful to keep plugin files right next to the input file, regardless of the current working directory. | |||
Turning this field to Yes will add the directory where the input file is located to the list of search paths. | |||
|
|||
\paragraph{Field: Add epin Environment Variable to Search Path} |
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.
Small description of the new input field.
@@ -104640,35 +104640,45 @@ PythonPlugin:SearchPaths, | |||
\key Yes | |||
\key No | |||
\default Yes | |||
A4, \field Search Path 1 | |||
A4, \field Add epin Environment Variable to Search Path |
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.
New input field to allow responding to the epin
environment variable, defaulted to ON. Of course incremented all following input field numbers.
); | ||
} | ||
} | ||
} |
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.
- Assume the input field value is true, then read the value from the IDF
- If it is true, then try to read the environment variable value
- If the environment variable doesn't exist, issue a warning for that odd combination
- Otherwise read the environment variable value, and if the path exists, add it to the Python search path.
- I thought about this one for a bit. Should we concern ourselves with checking if the path exists on the drive? I mean maybe, maybe not, but in this case, the Python interpreter is literally milliseconds away from actually using that path to find Python stuff, so I leaned on providing a nice warning if the directory doesn't exist.
} | ||
|
||
unsigned long numVals = PyList_Size(pyth_val); | ||
if (numVals == 0) { | ||
EnergyPlus::ShowFatalError(state, "No traceback available"); | ||
EnergyPlus::ShowContinueError(state, "No traceback available"); |
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.
We don't need to throw fatal errors in here, just issue continuations and return, the code is already destined for a more meaningful fatal error at this point.
OutArgs(1:3)=InArgs(1:3) | ||
OutArgs(4) = 'Yes' | ||
OutArgs(5:CurArgs+1)=InArgs(4:CurArgs) | ||
CurArgs = CurArgs + 1 |
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.
Simple transition rule to increment the arg count by one and push everything past by one spot.
Alright, Clang format caught something, but I've got that fixed locally. Otherwise, CI looks to be coming back clean. I'm going to push the Clang format fix and then merge this right in. Goodnight all. |
Add additional python path for use with EP-Launch
Pull request overview
epin
to the python search plan. I utilized theepin
path but had to use it's parent directory to get it to work. Also,state.dataSysVars->envinputpath1
is blank it this point in the code, which is why I used theget_environment_variable
function to get the path. Tested in Windows using EP-Launch.Pull Request Author
Add to this list or remove from it as applicable. This is a simple templated set of guidelines.
Reviewer
This will not be exhaustively relevant to every PR.