satpy icon indicating copy to clipboard operation
satpy copied to clipboard

Add `fsspec` support to `msi_safe` reader

Open simonreise opened this issue 1 month ago • 3 comments

The changes added in this PR are nearly identical to #3173

Zip archives are still the default distribution format for Sentinel-2 MSI_SAFE imagery, however, now SatPy msi_safe reader does not support it.

fsspec can be used to read data from archives, or, e.g. remote data sources like AWS or Planetary Computer.

The msi_safe reader file reading functionality is nearly identical to the one of Landsat readers, so I tried to implement fsspec support the same way.

However, I am stuck on adding tests, because in the current testing workflow no files are being used. For XML files the StringIO and BytesIO objects are being used (however, we can write the content of these objects to files in the fsspec filesystem to test if it works). For jp2 files no reading is performed at all, instead of actual reading the function is just being mocked by mock.path, which returns the pre-defined fake data instead of loading something from file (so, we either have to just leave it as-is or add actual loading functionality to the tests).

  • [ ] Closes #xxxx
  • [ ] Tests added
  • [x] Fully documented
  • [ ] Add your name to AUTHORS.md if not there already

simonreise avatar Nov 21 '25 18:11 simonreise

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 96.33%. Comparing base (ee989f6) to head (09446dc). :warning: Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3306   +/-   ##
=======================================
  Coverage   96.33%   96.33%           
=======================================
  Files         463      463           
  Lines       58870    58871    +1     
=======================================
+ Hits        56711    56712    +1     
  Misses       2159     2159           
Flag Coverage Δ
behaviourtests 3.60% <0.00%> (-0.01%) :arrow_down:
unittests 96.42% <100.00%> (+<0.01%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

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

codecov[bot] avatar Nov 21 '25 18:11 codecov[bot]

Pull Request Test Coverage Report for Build 19579904993

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 4 unchanged lines in 1 file lost coverage.
  • Overall coverage remained the same at 96.409%

Files with Coverage Reduction New Missed Lines %
readers/msi_safe.py 4 98.41%
<!-- Total: 4
Totals Coverage Status
Change from base Build 19515384246: 0.0%
Covered Lines: 56590
Relevant Lines: 58698

💛 - Coveralls

coveralls avatar Nov 21 '25 19:11 coveralls

FYI, the Sentinel-2 file format will be changing next year to Zarr - so if this PR is problematic for you then I'd recommend considering how much time you're willing to spend on something that'll be obselete in 6 months :)

simonrp84 avatar Nov 24 '25 08:11 simonrp84