-
Notifications
You must be signed in to change notification settings - Fork 425
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Extensible PythonPlugin:SearchPaths #8195
Conversation
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.
Stray debugging line was left in, otherwise this is good to go in.
@@ -108583,6 +108583,7 @@ PythonPlugin:SearchPaths, | |||
\memo that point to libraries of plugin scripts. | |||
\unique-object | |||
\min-fields 1 | |||
\extensible: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.
Marked as extensible ✔️
@@ -108605,6 +108606,7 @@ PythonPlugin:SearchPaths, | |||
\default Yes | |||
A4, \field Search Path 1 | |||
\type alpha | |||
\begin-extensible |
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.
Begins extensible on the first search path ✔️
A12,\field Search Path 9 | ||
\type alpha | ||
\retaincase | ||
A13;\field Search Path 10 |
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.
Adds a few extra paths in the IDD, no problem.
@@ -122,6 +122,7 @@ def isInt(s): | |||
'AirLoopHVAC:Splitter': 'nodes', | |||
'AirLoopHVAC:DedicatedOutdoorAirSystem': 'airloophvacs', | |||
'PythonPlugin:Variables': 'global_py_vars', | |||
'PythonPlugin:SearchPaths': 'py_search_paths', |
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.
Names it py_search_paths
for the input processor ✔️
@@ -62,6 +62,8 @@ | |||
#include <EnergyPlus/PluginManager.hh> | |||
#include <EnergyPlus/UtilityRoutines.hh> | |||
|
|||
#include <nlohmann/json.hpp> |
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.
Includes the header to get access to the proper exception. ✔️
workingDirFlagUC = EnergyPlus::UtilityRoutines::MakeUPPERCase(fields.at("add_current_working_directory_to_search_path")); | ||
} catch (nlohmann::json::out_of_range &e) { | ||
// defaulted to YES | ||
} |
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.
Good fix here, if it was blank that would've been problematic.
if (fields.find("search_path_5") != fields.end()) { | ||
PluginManager::addToPythonPath(PluginManager::sanitizedPath(fields.at("search_path_5")), true); | ||
try { | ||
auto const vars = fields.at("py_search_paths"); |
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.
This lookup is OK since we are inside the try block.
src/EnergyPlus/PluginManager.cc
Outdated
auto const vars = fields.at("py_search_paths"); | ||
for (const auto &var : vars) { | ||
try { | ||
std::cout << var.at("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.
Probably need to remove this though.
@@ -1388,6 +1399,8 @@ namespace PluginManagement { | |||
#if LINK_WITH_PYTHON == 1 | |||
void PluginManager::addToPythonPath(const std::string &path, bool userDefinedPath) | |||
{ | |||
if (path.empty()) return; |
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.
And here we don't try to add a blank path to the Python search path. ✔️
Sorry about that, should be good now. Why do something in 1 commit when you can spread it out over 10... |
Pulled locally to confirm, everything builds and runs fine. I'm going to merge this IDD change now. Thanks @mitchute |
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.