Skip to content
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

Refactor reference file loading #233

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

hpparvi
Copy link
Contributor

@hpparvi hpparvi commented Nov 18, 2024

This PR addresses Issue #169 (also discussed in PR #165) by using the astropy.config.ConfigNamespace.set_temp context manager to temporarily set the default data download URL and then using either astropy.utils.data.get_pkg_data_fileobj or astropy.utils.data.get_pkg_data_filename to get a readable file or a path to the downloaded and cached file.

However, I'm not convinced this approach leads to more elegant code than the original one. We eliminate the two wrapper functions, but the file-handling code is somewhat messy because of all the nesting. Please take a look and let me know what you think.

…eobj and get_pkg_data_filename and translate URLError errors into warnings.
Copy link

codecov bot commented Nov 18, 2024

Codecov Report

Attention: Patch coverage is 81.13208% with 10 lines in your changes missing coverage. Please review.

Project coverage is 84.15%. Comparing base (ef38dc0) to head (db5d5ad).
Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
specreduce/calibration_data.py 81.13% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #233      +/-   ##
==========================================
+ Coverage   83.36%   84.15%   +0.79%     
==========================================
  Files          13       13              
  Lines        1136     1136              
==========================================
+ Hits          947      956       +9     
+ Misses        189      180       -9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@hpparvi hpparvi changed the title Issue 169 fix Refactor reference file loading Nov 18, 2024
@hpparvi
Copy link
Contributor Author

hpparvi commented Nov 27, 2024

Do you have any opinions about this, @cshanahan1, @tepickering, and @kecnry? If nobody opposes this approach, I'll improve the code coverage and see if I can make the code a bit more readable.

@tepickering
Copy link
Contributor

thanks for catching this! i filed the original issue, but had long since forgotten about it 😅. i like what you've done so far. will give it a closer look when you're more ready to merge. a few test failures to address as well as the coverage.

…ion_data.

- Marked several of the function arguments used by the previous approach as deprecated (pending) using deprecated_renamed_argument.
- Improved tests to bring calibration_data coverage to 87%.
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.

2 participants