Skip to content

Conversation

@djhoese
Copy link
Member

@djhoese djhoese commented Oct 13, 2025

I noticed while working on other PRs that some of the CI tests were failing with HTTP hiccups trying to download pyspectral LUTs. Turns out this has been happening for years and is a major waste of resources even though it was nice to have the full processing being tested, it isn't "right" in my opinion. This PR:

  • Mocks and removes the usage of pyspectral so it never downloads anything. Additionally it uses autospec so Satpy's usage will always match upstream pyspectral.
  • Adds an autouse fixture for ALL of satpy to mock pyspectral's usage of the requests library so tests fail if they make pyspectral download anything.
  • Closes #xxxx
  • Tests added
  • Fully documented
  • Add your name to AUTHORS.md if not there already

@djhoese djhoese self-assigned this Oct 13, 2025
@djhoese djhoese requested a review from mraspaud as a code owner October 13, 2025 01:46
@djhoese djhoese added component:tests cleanup Code cleanup but otherwise no change in functionality labels Oct 13, 2025
Needs pyorbital, skyfield, and astropy to be installed.
"""
from pyorbital.orbital import tlefile
Copy link
Member Author

Choose a reason for hiding this comment

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

This import was wrong and is no longer available in future versions of pyorbital. I removed it in a PR last week to avoid import-time side effects.

@codecov
Copy link

codecov bot commented Oct 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.29%. Comparing base (9c872cb) to head (26723ff).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3260   +/-   ##
=======================================
  Coverage   96.29%   96.29%           
=======================================
  Files         463      463           
  Lines       58136    58163   +27     
=======================================
+ Hits        55983    56010   +27     
  Misses       2153     2153           
Flag Coverage Δ
behaviourtests 3.64% <0.00%> (-0.01%) ⬇️
unittests 96.38% <100.00%> (+<0.01%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 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.

@djhoese
Copy link
Member Author

djhoese commented Oct 13, 2025

With very little effort of just comparing executing times of the unit test steps to a previous execution: CI on the ubuntu 3.12 false environment ran unit tests 50 seconds faster.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 18452799198

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.001%) to 96.38%

Totals Coverage Status
Change from base Build 18348002293: 0.001%
Covered Lines: 55891
Relevant Lines: 57990

💛 - Coveralls

Copy link
Member

@pnuu pnuu left a comment

Choose a reason for hiding this comment

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

I'm not sure I follow completely how this works, but I certainly approve of forcing the download to be disabled.

@djhoese
Copy link
Member Author

djhoese commented Oct 13, 2025

For hopefully a little clarification: pytest always loads any conftest.py modules in every test directory (include subdirectories) looking for fixtures and other similar things. In Satpy's root test directory I create a fixture that has autouse=True on. That means it is always run for every test. So basically every test has pyspectral's requests mocked to error out.

I also defined it as a session scope so it should hopefully only run at the start of testing and not be enabled/disabled/enabled/disabled/enabled and so on for every test. I think that should be fine even with our "pytest-xdist" usage where it runs tests in parallel but I should confirm that.

@djhoese
Copy link
Member Author

djhoese commented Oct 13, 2025

Did a quick check and I think this should be fine. I think it is run once per worker, but is actually executed so that's fine.

Copy link
Member

@mraspaud mraspaud left a comment

Choose a reason for hiding this comment

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

For reference, as I said on slack, I would like the rayleigh and calculator mocks to be outsourced to pyspectral, eg in a "testing" module. See also: pytroll/pyspectral#262

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cleanup Code cleanup but otherwise no change in functionality component:tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants