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

Escape MAST Download URIs #3080

Merged
merged 3 commits into from
Aug 7, 2024
Merged

Conversation

snbianco
Copy link
Contributor

@snbianco snbianco commented Aug 6, 2024

Fixes an issue with downloading URIs that include URL parameters. This PR escapes URIs before sending them to the MAST download service so that URIs are not unexpectedly truncated.

Also removes lines from the test suite that were not serving an apparent purpose.

Adding a test case for this particular change would add ~1 minute to test execution time, so I was planning to add that to our internal, backend test suite.

@snbianco snbianco requested a review from bsipocz August 6, 2024 19:54
@snbianco snbianco marked this pull request as ready for review August 6, 2024 19:54
@@ -150,10 +150,6 @@ def test_mast_service_request_async(self):
assert isinstance(responses, list)

def test_mast_service_request(self):

# clear columns config
Mast._column_configs = dict()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like this and the other assignments to dict() were done to reset the class attribute _column_configs. Are we sure we don't need this anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure what purpose the lines serve, but removing them has no impact on the test results. From what I can tell, _column_configs seems to be a sort of caching variable to avoid having to make multiple calls for the columnsConfig entry for a service. I don't see any apparent reason that this should be reset for certain tests, since I don't imagine that we expect the configuration for a service to change all that often. What do you think?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm fine with removing from the tests

@falkben
Copy link

falkben commented Aug 6, 2024

Would it make sense to add a test here with a URI that requires the escaped behavior? Something like: mast:HLA/url/cgi-bin/fitscut.cgi?red=hst_04819_65_wfpc2_f814w_pc&blue=hst_04819_65_wfpc2_f555w_pc&size=ALL&format=fits

@snbianco
Copy link
Contributor Author

snbianco commented Aug 7, 2024

Added a test! Thank you for that URI example, it's a pretty quick download.

assert Path(tmp_path, filename).exists()

# check that downloaded file is a valid FITS file
f = fits.open(filename)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to include the path to open the file here. This passes in CI because remote tests aren't run, but I ran it locally.

Suggested change
f = fits.open(filename)
f = fits.open(Path(tmp_path, filename))

@bsipocz
Copy link
Member

bsipocz commented Aug 7, 2024

Adding a test case for this particular change would add ~1 minute to test execution time

FWIW, adding +1 min to the remote test runtime is not a big deal, there are bigger problems in that ~2hr long run that we can fix first.

@bsipocz bsipocz added the mast label Aug 7, 2024
@bsipocz bsipocz added this to the v0.4.8 milestone Aug 7, 2024
Copy link
Member

@bsipocz bsipocz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.

It's borderline whether it needs a changelog, it feels to be user facing, but it also internal enough.

@bsipocz bsipocz merged commit 515928d into astropy:main Aug 7, 2024
8 of 10 checks passed
@snbianco snbianco deleted the ASB-21598-escape-url branch August 12, 2024 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants