-
Notifications
You must be signed in to change notification settings - Fork 26
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
Fix handling of pathlib.Path objects #143
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #143 +/- ##
==========================================
- Coverage 59.33% 59.25% -0.09%
==========================================
Files 24 24
Lines 1606 1615 +9
==========================================
+ Hits 953 957 +4
- Misses 653 658 +5 ☔ View full report in Codecov by Sentry. |
tests/test_step.py
Outdated
@@ -284,9 +284,9 @@ def test_step_list_args(config_file_list_arg_step): | |||
correctly. | |||
""" | |||
config, returned_config_file = ListArgStep.build_config( | |||
"science.fits", config_file=config_file_list_arg_step | |||
"science.fits", config_file=str(config_file_list_arg_step) |
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.
As updating build_config
to also accept Path
seems to match the efforts in this PR would you update that portion of Step
to also accept a Path
instance:
Lines 1376 to 1381 in ee5f1ee
if "config_file" in kwargs: | |
config_file = kwargs["config_file"] | |
del kwargs["config_file"] | |
config_from_file = config_parser.load_config_file(config_file) | |
config_parser.merge_config(config, config_from_file) | |
config_dir = os.path.dirname(config_file) |
That should make this call to
str
unnecessary.
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 actually fails within ConfigObj
unfortunately. It does not fully accept pathlib.Path
objects. And since this is now a dependency instead of vendored in extern
, not much I can do here. Though perhaps I could modify line 1379 to pass a str()
of the 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.
It looks like config_file
is returned by this function and is documented to be a str
. So perhaps converting config_file
to a str
on 1377?
Thanks for putting this together! Do the changes in this PR allow us to use |
Good question. I'll give it a try. I too was trying to think of a way to prevent the use of the |
8e54d31
to
066cde2
Compare
pyproject.toml
Outdated
@@ -71,7 +71,8 @@ addopts = [ | |||
"--strict-config", | |||
"--strict-markers", | |||
"-ra", | |||
"--color=yes" | |||
"--color=yes", | |||
"-p no:legacypath", |
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.
Unfortunately it looks like the CI is currently using this config file for pytest runs of downstream (JWST and romancal). As those packages are still using tmpdir
this is leading to failures. I would categorize fixing the CI to not use this config as "outside the scope of this PR" (but would not object to a fix for it even if it's included here). So for now my vote is for removing this option and opening an issue about the above config issue (which is preventing us from using no:legacypath
).
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.
Sounds good. I'll remove this, and I'll open an issue here and in the downstream packages.
1e46fd9
to
066cde2
Compare
Thanks for all your work on this! Regression tests running at: |
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.
Roman regtests all passed
JWST regtests had 3 failures (all known and random failures for missing log messages that occur likely due to stpipe logger handling).
This fixes handling of
pathlib.Path
objects when used for input files forStep
.It also removes the old, deprecated
tmpdir
pytest fixture and replaces it with the moderntmp_path
equivalent, which provides apathlib.Path
instance.Resolves #139