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
@codecov
Copy link

codecov bot commented Oct 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.33%. Comparing base (2554db5) to head (b0e6693).
⚠️ Report is 26 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3260      +/-   ##
==========================================
- Coverage   96.34%   96.33%   -0.01%     
==========================================
  Files         463      463              
  Lines       58916    58926      +10     
==========================================
+ Hits        56760    56769       +9     
- Misses       2156     2157       +1     
Flag Coverage Δ
behaviourtests 3.59% <0.00%> (-0.01%) ⬇️
unittests 96.42% <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

@djhoese djhoese force-pushed the bugfix-no-pyspectral-downloads branch from eb5c0c9 to ca3e977 Compare February 2, 2026 20:24
@djhoese
Copy link
Member Author

djhoese commented Feb 2, 2026

Ok I've rebased this entire branch and then merged in my branch for the AVHRR HRPT test fixes in #3330. So hopefully if this PR is approved and merged then that PR will be detected as merged as well.

@djhoese
Copy link
Member Author

djhoese commented Feb 3, 2026

Ok I now also merged #3318 because that was the latest failure I saw.

@mraspaud
Copy link
Member

mraspaud commented Feb 3, 2026

Is this failing because of the fake pyspectral data we use now?

@djhoese
Copy link
Member Author

djhoese commented Feb 3, 2026

Probably. I will review when I have time. Permission to merge if it passes after I review what's going on and I add some tolerances?

@djhoese
Copy link
Member Author

djhoese commented Feb 3, 2026

Hm two other environments passed for the same OS. I'm going to rerun the failed jobs and see what happens. I did not see this failure before my last commit (I think) so I'm a little confused.

@mraspaud
Copy link
Member

mraspaud commented Feb 3, 2026

Probably. I will review when I have time. Permission to merge if it passes after I review what's going on and I add some tolerances?

Yes for me

@djhoese
Copy link
Member Author

djhoese commented Feb 3, 2026

@mraspaud it looks like restarting the jobs fixed the failure. If they end up being inconsistent I will work on making them more consistent. Merging...

@djhoese djhoese merged commit 8692f71 into pytroll:main Feb 3, 2026
21 of 29 checks passed
@djhoese djhoese deleted the bugfix-no-pyspectral-downloads branch February 3, 2026 16:10
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