Skip to content

refactor: dedupe FootprintPlotter, import from cs_util#186

Merged
cailmdaley merged 4 commits into
developfrom
fix/footprint-plotter-dedup
Jun 6, 2026
Merged

refactor: dedupe FootprintPlotter, import from cs_util#186
cailmdaley merged 4 commits into
developfrom
fix/footprint-plotter-dedup

Conversation

@cailmdaley
Copy link
Copy Markdown
Collaborator

@cailmdaley cailmdaley commented Apr 20, 2026

Summary

FootprintPlotter was duplicated between sp_validation.plots and cs_util.plots, with the local copy stale relative to the canonical cs_util version. This PR deletes the local copy and imports cs_util's FootprintPlotter directly at every call site — the elegant end state, as if the class had always lived in cs_util.

What changed

  • plots.py — the local FootprintPlotter class is gone; the module no longer references it at all (no re-export shim).
  • cosmo_val.py — drops from .plots import FootprintPlotter; uses the module's existing cs_plots alias → cs_plots.FootprintPlotter().
  • notebooks/cosmo_val/catalog_paper_plot/plot_gaia_sky.py and notebooks/demo_create_footprint_mask.py — import from cs_util.plots import FootprintPlotter directly.
  • pyproject.tomlcs_util>=0.1.5>=0.1.9 (guarantees the import resolves).

⚠️ Intended breaking change

from sp_validation.plots import FootprintPlotter no longer resolves. This is deliberate — cs_util is the home for the class, and every caller in the repo now imports it from there. No shim is kept.

Caller audit

cs_util 0.1.9's FootprintPlotter is a superset of the old local API (same __init__(nside_coverage=32, nside_map=2048) and public methods, plus vmin/Milky-Way/extent improvements). All call sites were inspected and are compatible:

  • cosmo_val.py:plot_footprintsFootprintPlotter() + create_hsp_map + plot_region
  • plot_gaia_sky.pyFootprintPlotter(nside_coverage=32, nside_map=2048) + plot_area(..., vmax=...)
  • demo_create_footprint_mask.pyFootprintPlotter() + plot_region / plot_footprint_as_hp

Tests now run in CI

Previously no unit tests ran in CI: the only live workflow (the docker build) did python -c "import sp_validation", and ci-build.yml was dead (triggered on master, Python 3.8, conda, setup.py test).

  • tests/test_plots.py (new) — guards the dedup contract (cs_util is the home; sp_validation.plots/cosmo_val don't re-expose it) and exercises create_hsp_map on a tiny input.
  • testpaths fixed from ["sp_validation"] (matched nothing under the src layout, so pytest recursed the whole tree and choked on a stray *test* script) → ["src/sp_validation/tests"].
  • @pytest.mark.slow on the catalog-data-dependent tests (additive-bias reads the real SP_v1.4.5 catalog; catalog_paths_exist checks files on disk), restoring a fast hermetic -m "not slow" suite (2:54 → 7s); catalog_paths_exist also skips when the data isn't mounted.
  • Dockerfile installs the [test] extra; deploy-image.yml runs pytest -m "not slow" inside the built image (which carries the full system-dependency stack), so tests run on every push.
  • Deleted the dead ci-build.yml.

— Claude on behalf of Cail

The FootprintPlotter class was duplicated between sp_validation and
cs_util, with the sp_validation copy stale (missing vmin, milky way,
extent enforcement). Delete the local copy and re-export cs_util's
version for API compatibility. Bump the cs_util dep to >=0.1.9 to
guarantee the import resolves.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@cailmdaley
Copy link
Copy Markdown
Collaborator Author

Live smoke test passed inside the shapepipe container (Python 3.12, cs_util 0.1.9):

from sp_validation.plots import FootprintPlotter
import cs_util.plots
fp = FootprintPlotter()
# FootprintPlotter.__module__ -> cs_util.plots
# FootprintPlotter is cs_util.plots.FootprintPlotter -> True
# list(fp._regions.keys()) -> ['NGC', 'SGC', 'fullsky']
# all('vmin' in r for r in fp._regions.values()) -> True

Re-export is transparent; same class object is returned, _regions matches cs_util's (with vmin). Ready for review.

cailmdaley and others added 2 commits June 3, 2026 10:37
Finish the dedup started in this PR. Instead of re-exporting cs_util's
FootprintPlotter through sp_validation.plots (a compatibility shim), import
it directly at every call site, as if it had always lived in cs_util:

- cosmo_val.py: drop `from .plots import FootprintPlotter`, use the existing
  `cs_plots` alias (`cs_plots.FootprintPlotter()`)
- plot_gaia_sky.py / demo_create_footprint_mask.py: import from cs_util.plots
- plots.py: no longer mentions FootprintPlotter at all

This removes the shim, so `from sp_validation.plots import FootprintPlotter`
no longer resolves — intended; no caller uses it after this.

Tests now actually run in CI:
- New tests/test_plots.py: guards the import contract (cs_util is the home,
  sp_validation.plots/cosmo_val don't re-expose it) and exercises
  create_hsp_map on a tiny input.
- Fix `testpaths = ["sp_validation"]` -> ["src/sp_validation/tests"]; the old
  value matched nothing under the src layout, so pytest recursed the whole
  tree and choked on a stray `*test*` script in cosmo_inference/notebooks.
- Mark the catalog-data-dependent tests slow (additive-bias reads the real
  SP_v1.4.5 catalog; catalog_paths_exist checks files on disk), restoring a
  fast, hermetic `-m "not slow"` suite (2:54 -> 7s) + skip-guard on
  catalog_paths_exist when the data isn't mounted.
- Dockerfile installs the [test] extra; deploy-image.yml runs
  `pytest -m "not slow"` inside the built image (which has the full system
  dependency stack), so tests run on every push.
- Delete the dead ci-build.yml (triggered on master, py3.8, conda,
  setup.py test — never ran, superseded by the docker pytest step).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…lotter

# Conflicts:
#	.github/workflows/deploy-image.yml
#	Dockerfile
#	src/sp_validation/tests/test_cosmo_val.py
@cailmdaley cailmdaley merged commit c118498 into develop Jun 6, 2026
2 checks passed
@cailmdaley cailmdaley deleted the fix/footprint-plotter-dedup branch June 6, 2026 00:15
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