-
Notifications
You must be signed in to change notification settings - Fork 105
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 ability to specify search path for SNOPT import with env var #338
Add ability to specify search path for SNOPT import with env var #338
Conversation
Codecov Report
@@ Coverage Diff @@
## main #338 +/- ##
===========================================
- Coverage 83.92% 72.40% -11.53%
===========================================
Files 22 22
Lines 3347 3363 +16
===========================================
- Hits 2809 2435 -374
- Misses 538 928 +390
... and 7 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
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.
Thanks for the PR Phil! I just have two quick comments:
- I like using a self-explanatory name for the environmental variable, even if long. I am just not convinced about the
_NONRELATIVE
part, it might not be intuitive for users. What about something along the lines ofPYOPTSPARSE_LOAD_COMPILED_SNOPT
? Would that be ambiguous? I have no strong opinions on this name myself . - Could you update the docs here? Just clarifying the scenario in which this approach is recommended (as you did in Allow
snopt
module to be loaded non-relatively #337) and a snippet with the updated env variables is enough imho
@marcomangano I pushed a change renaming the variable to |
PYOPTSPARSE_LOAD_SNOPT_NONRELATIVE
flagPYOPTSPARSE_IMPORT_SNOPT_ABSOLUTE
flag
The failing test seems to be related to NSGA segfaults (#340), otherwise this is ready. |
PYOPTSPARSE_IMPORT_SNOPT_ABSOLUTE
flag
A clarification on how this behaves - The original search order for
With this change, if you specify a path with
The second item may be unexpected, so I wanted to point it out. |
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.
Thanks for the update. Aside the comment below, I feel your note on the search order should be included in the documentation.
I see how searching through the "original" PYTHONPATH
is inevitable with this approach. I don't have anything against it, but I think we need some kind of note and/or warning. I can see how more or less intentionally a user could set an invalid env variable but still end up importing any snopt
library already existing on the path. I don't think the logic should change though. Do you have other thoughts @eirikurj
@marcomangano there is one other option, which has no hidden behavior. I will explain it in words and wait for your feedback before implementing.
There is also the option to not attempt the relative import as a fallback if the absolute import fails. This feels a little more intuitive to me. Personally, I would prefer an error to be raised if |
I like this approach, it avoids the ambiguous scenarios I mentioned above.
I also agree with this. pyOptSparse is either importing the library specified in the path or dropping the import, no ambiguous fallbacks.
I think this might be redundant, as we indeed have a check on the correct import here. Maybe we can print a warning for this scenario, but if we end up implementing your latest suggestion I think there is no need for an additional error imho. |
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 looks good to me! Just fixed a minor inconsistency in the docs. Maybe @eirikurj has some final comments on this?
Thanks @marcomangano ! I just pushed one other basic test for |
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.
Thanks for your effort on this and the tests. I just have few very minor questions/comments, otherwise it looks good.
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.
Changes look good. Not sure, but the U22 image failed a couple of times installing the build deps. The current failure is the #340 issue, which is unrelated, so I am approving.
Purpose
Addresses #337
I am totally open to suggestions on the name of this environment variable. For now it is explicit as possible.
Expected time until merged
Quickly - due to small scope of change, not urgency.
Type of change
Testing
Checklist
flake8
andblack
to make sure the Python code adheres to PEP-8 and is consistently formattedfprettify
or C/C++ code withclang-format
as applicable