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

Streamlined method to get list of cloud URIs #3064

Merged
merged 5 commits into from
Jul 16, 2024

Conversation

snbianco
Copy link
Contributor

@snbianco snbianco commented Jul 9, 2024

Added mast.Observations.get_cloud_uris_query() method so that given a set of query criteria and optional filters, the user receives a list of cloud data URIs for matching data products.

Also added to documentation and remote unit tests.

@snbianco snbianco marked this pull request as ready for review July 9, 2024 22:11
@snbianco snbianco requested a review from bsipocz July 9, 2024 22:11
@bsipocz bsipocz added the mast label Jul 11, 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.

Any chance of adding the filters and query criteria as optionals into get_cloud_uris() instead?
Even if it means fully changing that method (as there were already issues with it, see the abandoned PR #2145

Anyway, from the users' POV, I think it would be better to have one method than having multiple with very similar name and functionality.

@snbianco
Copy link
Contributor Author

Any chance of adding the filters and query criteria as optionals into get_cloud_uris() instead? Even if it means fully changing that method (as there were already issues with it, see the abandoned PR #2145

Anyway, from the users' POV, I think it would be better to have one method than having multiple with very similar name and functionality.

I agree, that's a great idea. I don't think it should involve a huge rewrite of the method, but I will take a look at that abandoned PR probably sometime next week and see if I can wrap it up.

@snbianco
Copy link
Contributor Author

I moved the logic entirely into get_cloud_uris() and incorporated the changes from #2145. This should be ready for another round of review!


# get uris with other functions
obs = Observations.query_criteria(target_name=234295610,
provenance_name="SPOC",
Copy link
Member

Choose a reason for hiding this comment

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

This triggers a test failure. Could you please run and fix the remote tests?

pytest -P mast -R?

Copy link
Contributor Author

@snbianco snbianco Jul 14, 2024

Choose a reason for hiding this comment

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

That's strange, the tests pass on my local machine. What was the error? There's been some slowdowns on the MAST servers recently, so that might be the cause.

Nevermind, I see it now! I was running the wrong command.

@snbianco
Copy link
Contributor Author

Ok, the new commit should pass the tests. I also made a few minor changes to the documentation so that those are passing as well.

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.

Minor comments about the reason for skipping test for examples. There are a few genuine cases where they can and should be skipping, but for those I would prefer to leave a comment before the example that spells out the reason. So we will remember more easily when next looking into a narrative docs file.

Also, one attribute seems to be undefined, or I just didn't find where it is coming from.

s3_path = "s3://{}/{}".format(self.pubdata_bucket, path)
uri_list.append(s3_path)
elif full_url:
path = "http://s3.amazonaws.com/{}/{}".format(self._pubdata_bucket, path)
Copy link
Member

Choose a reason for hiding this comment

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

Where is _pubdata_bucket is coming from? I cannot find any definition for it in the repo

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 think it's a typo and meant to be just pubdata_bucket. I'll push a fix!

@@ -24,7 +24,7 @@ The returned fields vary by catalog, find the field documentation for specific c
`here <https://mast.stsci.edu/api/v0/pages.html>`__.
If no catalog is specified, the Hubble Source Catalog will be queried.

.. doctest-remote-data::
.. doctest-skip::
Copy link
Member

Choose a reason for hiding this comment

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

why switch to skip here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This one was kind of weird, it was failing because the actual output does not match the expected. However, I can't reproduce the results from the tests.

Whenever I run the code on its own, I get the output that's currently in the documentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The new commit doesn't skip the test, but ignores the output of the offending line.

@@ -284,7 +284,7 @@ with `~astroquery.mast.ObservationsClass.get_product_list`
(see `here <https://mast.stsci.edu/api/v0/_c_a_o_mfields.html>`__ for more details).
Using "obs_id" instead of "obsid" from the previous example will result in the following error:

.. doctest-remote-data::
.. doctest-skip::
Copy link
Member

Choose a reason for hiding this comment

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

why switch to skip for the whole example here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Latest commit doesn't skip the test, but ignores the output where the RemoteServiceError occurs.

This approach is recommended for code brevity. Query criteria are supplied as keyword arguments, and filters are supplied through the
``filter_products`` parameter. If both ``data_products`` and query criteria are provided, ``data_products`` takes precedence.

.. doctest-skip::
Copy link
Member

Choose a reason for hiding this comment

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

Why skipping this example

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, this shouldn't be skipped. New commit reflects this!

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.

Looks good now, thanks. I'll go ahead and rebase it before merge to get rid of the merge commit, as our preference is to rebase to pull in upstread changes rather than merge the main back in the feature branch (doing so creates a not too smooth branch structure, especially if doing that multiple time during the development of a feature).

@@ -286,7 +286,7 @@ Using "obs_id" instead of "obsid" from the previous example will result in the f

.. doctest-remote-data::
>>> obs_ids = obs_table[0:2]['obs_id']
>>> data_products_by_id = Observations.get_product_list(obs_ids)
>>> data_products_by_id = Observations.get_product_list(obs_ids) # doctest: +IGNORE_OUTPUT
Copy link
Member

Choose a reason for hiding this comment

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

An expected error can be explicitly tested, too, but nevertheless, this looks good as is.

@bsipocz bsipocz force-pushed the ASB-27903-cloud-uris-from-query branch from cae5372 to a1349a1 Compare July 16, 2024 04:25
@bsipocz bsipocz added this to the v0.4.8 milestone Jul 16, 2024
@bsipocz bsipocz merged commit cc25c37 into astropy:main Jul 16, 2024
8 checks passed
@snbianco snbianco deleted the ASB-27903-cloud-uris-from-query branch July 17, 2024 01:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants