Skip to content

MAST: Read product function for MastMissions - #3593

Merged
bsipocz merged 16 commits into
astropy:mainfrom
snbianco:read-product-mm
Nov 3, 2026
Merged

bsipocz merged 16 commits into
astropy:mainfrom
snbianco:read-product-mm

Conversation

@snbianco

@snbianco snbianco commented May 18, 2026 •

Copy link
Copy Markdown
Contributor

A function in the MastMissions class that can read products into memory.

For FITS files, we use astropy.io.fits.open. The product files are downloaded and cached by Astropy, and then read into a HDUList object.

For ASDF files, we use fsspec and asdf. Our downloads for Roman data are redirected to S3, so these files are not downloaded and are streamed directly into asdf.AsdfFile objects.

@codecov

codecov Bot commented May 18, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.00000% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.94%. Comparing base (e93dabb) to head (6d145c7).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
astroquery/mast/missions.py 92.00% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3593      +/-   ##
==========================================
+ Coverage   73.87%   73.94%   +0.06%     
==========================================
  Files         228      228              
  Lines       21485    21572      +87     
==========================================
+ Hits        15873    15952      +79     
- Misses       5612     5620       +8     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@scfleming

Copy link
Copy Markdown

Until we have a more mature version ready, can we please ensure documentation / tutorials call out that for FITS files read_product() still downloads the file locally, so people working on Roman work who may want to use this to download HST or JWST FITS files aren't surprised if read_product() is using up credits writing to local cloud storage on them?

I presume this can be avoided once there's a "get_s3_uris()" endpoint in MissionMAST for all the supported missions beyond Roman?

@snbianco
snbianco force-pushed the read-product-mm branch 2 times, most recently from 617201a to cdda4a2 Compare May 27, 2026 17:05
@snbianco
snbianco marked this pull request as ready for review May 27, 2026 20:55

@bsipocz bsipocz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

code changes look good, but I have problem with the proposed changes in pyproject.toml, IMO we should avoid workaround for [all] and should not include optional dependencies to be installed for all the test jobs.

Comment thread pyproject.toml Outdated
"sphinx-astropy>=1.5",
"scipy",
"fsspec[http]",
"asdf"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

where is it used in the docs?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think I thought I had to include it for the code blocks. Removed!

Comment thread pyproject.toml Outdated
Comment on lines +45 to +47
"fsspec[http]",
"fsspec[http,s3]",
"moto[s3]",
"s3fs",
"asdf"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think that optional dependencies should be installed for all test runs. The fact that we have fsspec and s3fs listed here is a problem of its own and should be cleaned up. So, I would not think we should add asdf.

@snbianco
snbianco force-pushed the read-product-mm branch 2 times, most recently from f071d04 to d620a7a Compare September 24, 2026 15:28
@snbianco

snbianco commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

Could we get another round of review on this PR? After the weekend, of course. We're hoping to get this particular feature into a dev release as soon as we can since it will be important for accessing Roman data.

@bsipocz bsipocz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Here are some comments, I don't see any big issues but am still waiting on the tests to finish

Comment thread astroquery/mast/tests/test_mast.py Outdated
Comment on lines +766 to +769
if asdf is not None:
mock_asdf_file = MagicMock(spec=asdf.AsdfFile)
else:
mock_asdf_file = MagicMock()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not sure what this suppose to be, what is the scenario when you end up in the else part? (if there is no asdf then we should not get to that line)

Comment thread astroquery/mast/tests/test_mast.py Outdated
assert isinstance(obj, fits.HDUList)


def test_missions_read_product_asdf(mocker, mock_asdf_open):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

do we want to instead decorate these with a skipif like we do for other optional dependencies?

Comment thread astroquery/mast/missions.py Outdated

return manifest

def read_product(self, uri, *, mission=None, **kwargs):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

in other modules we tend to have the naming of get_... rather than read_..., but I can't claim we are overly consistent, and that what we have is the way should be. But, eventually we may want to be more unified. And we already have get_product etc in euclid that downloads data.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We chatted about this: renaming and adding a deprecation warning for the rename from read_product sounds good to me.

Comment thread astroquery/mast/missions.py Outdated
**file_kwargs,
)
except ImportError:
fsspec = None

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Minor nitpicking about consistency, we tend to use the HAS_{packagename} variables for cases like this.

@bsipocz bsipocz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@bsipocz bsipocz added this to the 0.4.12 milestone Nov 3, 2026
@bsipocz
bsipocz merged commit 5ac6610 into astropy:main Nov 3, 2026
12 checks passed
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.

3 participants