-
-
Notifications
You must be signed in to change notification settings - Fork 408
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
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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() | ||||||
|
||||||
service = 'Mast.Caom.Cone' | ||||||
params = {'ra': 184.3, | ||||||
'dec': 54.5, | ||||||
|
@@ -174,9 +170,6 @@ def test_mast_service_request(self): | |||||
assert len(result[np.where(result["obs_id"] == "6374399093149532160")]) == 2 | ||||||
|
||||||
def test_mast_query(self): | ||||||
# clear columns config | ||||||
Mast._column_configs = dict() | ||||||
|
||||||
result = Mast.mast_query('Mast.Caom.Cone', ra=184.3, dec=54.5, radius=0.2) | ||||||
|
||||||
# Is result in the right format | ||||||
|
@@ -225,9 +218,6 @@ def test_observations_query_region_async(self): | |||||
assert isinstance(responses, list) | ||||||
|
||||||
def test_observations_query_region(self): | ||||||
# clear columns config | ||||||
Observations._column_configs = dict() | ||||||
|
||||||
result = Observations.query_region("322.49324 12.16683", radius="0.005 deg") | ||||||
assert isinstance(result, Table) | ||||||
assert len(result) > 500 | ||||||
|
@@ -243,9 +233,6 @@ def test_observations_query_object_async(self): | |||||
assert isinstance(responses, list) | ||||||
|
||||||
def test_observations_query_object(self): | ||||||
# clear columns config | ||||||
Observations._column_configs = dict() | ||||||
|
||||||
result = Observations.query_object("M8", radius=".04 deg") | ||||||
assert isinstance(result, Table) | ||||||
assert len(result) > 150 | ||||||
|
@@ -264,10 +251,6 @@ def test_observations_query_criteria_async(self): | |||||
assert isinstance(responses, list) | ||||||
|
||||||
def test_observations_query_criteria(self): | ||||||
|
||||||
# clear columns config | ||||||
Observations._column_configs = dict() | ||||||
|
||||||
# without position | ||||||
result = Observations.query_criteria(instrument_name="*WFPC2*", | ||||||
proposal_id=8169, | ||||||
|
@@ -333,10 +316,6 @@ def test_observations_get_product_list_async(self): | |||||
assert isinstance(responses, list) | ||||||
|
||||||
def test_observations_get_product_list(self): | ||||||
|
||||||
# clear columns config | ||||||
Observations._column_configs = dict() | ||||||
|
||||||
observations = Observations.query_object("M8", radius=".04 deg") | ||||||
test_obs_id = str(observations[0]['obsid']) | ||||||
mult_obs_ids = str(observations[0]['obsid']) + ',' + str(observations[1]['obsid']) | ||||||
|
@@ -519,6 +498,19 @@ def test_observations_download_file_cloud(self, tmp_path, in_uri): | |||||
assert result == ('COMPLETE', None, None) | ||||||
assert Path(tmp_path, filename).exists() | ||||||
|
||||||
def test_observations_download_file_escaped(self, tmp_path): | ||||||
# test that `download_file` correctly escapes a URI | ||||||
in_uri = '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' | ||||||
filename = Path(in_uri).name | ||||||
result = Observations.download_file(uri=in_uri, local_path=tmp_path) | ||||||
assert result == ('COMPLETE', None, None) | ||||||
assert Path(tmp_path, filename).exists() | ||||||
|
||||||
# check that downloaded file is a valid FITS file | ||||||
f = fits.open(filename) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.close() | ||||||
|
||||||
@pytest.mark.parametrize("test_data_uri, expected_cloud_uri", [ | ||||||
("mast:HST/product/u24r0102t_c1f.fits", | ||||||
"s3://stpubdata/hst/public/u24r/u24r0102t/u24r0102t_c1f.fits"), | ||||||
|
@@ -618,10 +610,7 @@ def check_result(result, row, exp_values): | |||||
for k, v in exp_values.items(): | ||||||
assert result[row][k] == v | ||||||
|
||||||
# clear columns config | ||||||
Catalogs._column_configs = dict() | ||||||
in_radius = 0.1 * u.deg | ||||||
|
||||||
result = Catalogs.query_region("158.47924 -7.30962", | ||||||
radius=in_radius, | ||||||
catalog="Gaia") | ||||||
|
@@ -717,9 +706,6 @@ def check_result(result, exp_values): | |||||
for k, v in exp_values.items(): | ||||||
assert v in result[k] | ||||||
|
||||||
# clear columns config | ||||||
Catalogs._column_configs = dict() | ||||||
|
||||||
result = Catalogs.query_object("M10", | ||||||
radius=.001, | ||||||
catalog="TIC") | ||||||
|
@@ -819,9 +805,6 @@ def check_result(result, exp_vals): | |||||
for k, v in exp_vals.items(): | ||||||
assert v in result[k] | ||||||
|
||||||
# clear columns config | ||||||
Catalogs._column_configs = dict() | ||||||
|
||||||
# without position | ||||||
result = Catalogs.query_criteria(catalog="Tic", | ||||||
Bmag=[30, 50], | ||||||
|
@@ -897,10 +880,6 @@ def test_catalogs_query_hsc_matchid_async(self): | |||||
assert isinstance(responses, list) | ||||||
|
||||||
def test_catalogs_query_hsc_matchid(self): | ||||||
|
||||||
# clear columns config | ||||||
Catalogs._column_configs = dict() | ||||||
|
||||||
catalogData = Catalogs.query_object("M10", | ||||||
radius=.001, | ||||||
catalog="HSC", | ||||||
|
@@ -921,10 +900,6 @@ def test_catalogs_get_hsc_spectra_async(self): | |||||
assert isinstance(responses, list) | ||||||
|
||||||
def test_catalogs_get_hsc_spectra(self): | ||||||
|
||||||
# clear columns config | ||||||
Catalogs._column_configs = dict() | ||||||
|
||||||
result = Catalogs.get_hsc_spectra() | ||||||
assert isinstance(result, Table) | ||||||
assert result[np.where(result['MatchID'] == '19657846')] | ||||||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 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?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.
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 thecolumnsConfig
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?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.
i'm fine with removing from the tests