Skip to content

Tests: SSC cassette migration (unit tier)#296

Open
jeandet wants to merge 80 commits into
SciQLop:mainfrom
jeandet:modernisation/pr7-ssc-cassettes
Open

Tests: SSC cassette migration (unit tier)#296
jeandet wants to merge 80 commits into
SciQLop:mainfrom
jeandet:modernisation/pr7-ssc-cassettes

Conversation

@jeandet
Copy link
Copy Markdown
Member

@jeandet jeandet commented May 11, 2026

Summary

Seventh PR of the modernisation effort. Fourth per-provider cassette migration after AMDA, CDA, CSA.

Plan: docs/superpowers/plans/2026-05-11-pr7-ssc-cassettes.md.

Stacked on PR #295 (CSA), which stacks on #294#293#292#291#290. This PR's diff includes all predecessors until they merge in order.

What this PR does

  • Promotes tests/test_sscweb.py (17 tests, mostly trajectory/inventory queries) from contract tier to unit tier with cassette-backed replay.
  • Records 10 cassettes (3.3 MB uncompressed → 0.57 MB gzipped, ~6× ratio; 9 unique compressed blobs since test_get_orbit_5 and test_get_orbit_6 produced identical responses → content-addressed dedup), uploads to https://sciqlop.lpp.polytechnique.fr/data/speasy_cassettes/, updates manifest.
  • Adds tests/test_sscweb_contract.py (3 daily-cron drift probes: known observatory present, observatory list count, basic get_data fetch).

Net effect

  • Unit tier: +17 (now 621) — every SSC test runs on every PR, deterministic, no network.
  • Contract tier: -17 +3 — 3 small SSC drift probes hit upstream daily.
  • Compressed cassette storage: +0.57 MB.

Test plan

  • CI: unit.yml green — SSC tests replay from cassettes
  • CI: contract.yml (manually triggered) — 3 SSC probes pass against real upstream

jeandet and others added 30 commits May 8, 2026 15:55
Captures decisions on UV adoption, hatchling build backend, ruff/basedpyright
tooling, and three-tier test strategy (unit/contract/e2e). Sequences the work
as 17 small PRs ending with a mass reformat.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Per-task implementation plan for the first PR of the modernisation effort.
Covers pyproject.toml updates, uv.lock generation, CI/RTD switch to uv,
deletion of requirements*.txt / tox.ini / setup.cfg, and developer-doc
updates to drop the PYTHONPATH=. pattern.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Add SPEASY_CORE_HTTP_REWRITE_RULES env to PRs.yml non-3.10 pytest step
  (previously only on push/scheduled tests.yml — would have hit a
  non-existent server on PR builds for non-3.10 matrix entries).
- Add --with wheel to PRs.yml build step for parity with tests.yml.
- Scope flake8 to 'speasy tests' in both workflows (matches Makefile
  lint target). Avoids silently broadening lint to docs/conf.py and
  removes the .venv exclusion workaround that was needed when
  flake8 ran from repo root.
Without UV_PROJECT_ENVIRONMENT, uv creates .venv/ inside the project
and RTD's sphinx step (which calls $READTHEDOCS_VIRTUALENV_PATH/bin/python
directly) fails with 'python: not found'. Point uv at RTD's venv so the
install lands where the runner looks for it.
Classified via devtools/apply_test_markers.py:
- 12 files marked unit (pure-logic, no network)
- 19 files marked contract (real-server, will be migrated to cassettes in PRs 4-9)

Reclassifications during manual review:
- test_cache.py: contract -> unit (pure cache-logic, no network or speasy provider use)
- test_file_access.py: unit -> contract (uses HTTP via any_loc_open against live servers)

test_wasm.py was manually adjusted to place pytestmark at module level (the
file's body lives inside a try/except ImportError block, so the script's
naive insertion landed at wrong indentation).
…le path and sample across the inventory

The flat_inventories.generic_archive lookup uses module attribute access on
an instance, not a submodule import. Also, the first N parameters in the
flat inventory are clustered by mission, so a fixed time range can miss all
of them; sample across the full list instead.
- test_e2e_smoke.test_generic_archive: fail loudly if every candidate
  raises (was silently skipping, defeating the e2e tier's purpose).
- pyproject.toml: drop dead --ignore=setup.py from addopts and document
  the -m unit override semantics so future contributors don't trip on
  'pytest tests/test_amda.py' silently collecting nothing.
- contract.yml / e2e.yml: add concurrency groups so a manual run can't
  overlap with a cron run hammering the same upstream servers.
- CONTRIBUTING.rst: add a short note explaining the three test tiers
  and how to invoke each from local dev.
CI failure (blocking):
- unit.yml: 'make doctest' was using system Python (no sphinx in scope).
  Prefix with 'uv run' so make uses the project venv.

Reviewer findings:
- wasm_tests.yml: pytest tests/test_wasm.py without -m collected 0 tests
  under the new addopts default (test_wasm.py is contract-marked). Add
  -m '' to override.
- CLAUDE.md: examples like 'uv run pytest tests/test_amda.py' silently
  collected 0 tests under -m unit default. Replaced with tier-aware
  examples and added -m '' for the all-tests case.
- unit.yml: only sync --group docs on the coverage runner that needs it,
  not on every matrix entry.
nbsphinx requires the system pandoc binary (not the Python pandoc
wrapper that's in the docs dependency group). PR 1's tests.yml had
'sudo apt install -y texlive pandoc' before make doctest; my unit.yml
rewrite in PR 2 dropped that line, so the doctest job failed with
'nbsphinx.NotebookError: PandocMissing in examples/AMDA.ipynb'.
Restored as a separate apt step on the coverage runner.
The doctest step's examples reference all data providers (cdpp3dview
included) and live inventories. The job-level
SPEASY_CORE_DISABLED_PROVIDERS='cdpp3dview' makes the inventory tree's
cdpp3dview attribute missing during doctest, surfacing as
'types.SimpleNamespace object has no attribute cdpp3dview' and a chain
of NameErrors for variables defined in earlier doctest blocks.

Original tests.yml overrode SPEASY_CORE_DISABLED_PROVIDERS="" on the
combined pytest+doctest step, plus set HTTP_REWRITE_RULES (re-routes
the placeholder URL used in some examples to LPP's mirror) and
USER_AGENT. My PR 2 rewrite dropped the env block; restoring it on
the doctest step.
Pandas now prints its public name in type() repr ('pandas.DataFrame')
rather than the internal module path ('pandas.core.frame.DataFrame').
The user/numpy.rst doctest was written against the old form.
Surfaced now that uv.lock pins a recent pandas; pip-installed envs
were getting older pandas where the old form still applied.
jeandet added 27 commits May 13, 2026 14:45
- Skip 4 tests whose cassettes blow the 150 MB unit-tier budget (full
  inventory fetch, FEEPS electron intensity, MMS FGM virtual-parameter
  fallback, EQ_PP_MAM via inventory) - all keep equivalent live coverage in
  tests/test_cdaweb_contract.py.
- Drop the MMS2_SCM_SRVY_L2_SCSRVY case from both ddt-driven tests
  (MMS2 SCM survey returns ~76 MB per request because the API serves the
  day-aligned CDF chunk regardless of the requested time window).
- Drop the MMS1_SCM_BRST_L2_SCB case from both ddt-driven tests (10 min
  of burst SCM is a ~380 MB CDF).
- Shrink large API/FILE windows where it preserves the test's intent
  (PSP ISOIS, MMS FGM sanitised).
- Skip ConcurrentRequests.test_get_variable: thread-pool requests are not
  reliably intercepted by VCR, breaking replay.
- Skip test_get_cluster_fgm_data: upstream-data assumption no longer
  holds (CDA now returns Cluster C1 FGM data for the 2018-03/2016-03
  windows the test asserted None on).
Four daily-cron probes covering the live CDA paths whose cassettes
were dropped from the unit tier for size reasons (full inventory
fetch and the FEEPS electron-intensity request) plus two cheap
smoke checks (short THA fetch, inventory dataset presence).
Mocks speasy.data_providers.cda.http.get to return a 500 so the unit
tier verifies that a CDA server error surfaces as CdaWebException
rather than being silently swallowed.
@jeandet jeandet force-pushed the modernisation/pr7-ssc-cassettes branch from c6d84d5 to 008d0da Compare May 13, 2026 12:45
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
8 Security Hotspots
E Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants