refactor: dedupe FootprintPlotter, import from cs_util#186
Merged
Conversation
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>
Collaborator
Author
|
Live smoke test passed inside the shapepipe container (Python 3.12, cs_util 0.1.9): Re-export is transparent; same class object is returned, |
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>
martinkilbinger
approved these changes
Jun 3, 2026
…lotter # Conflicts: # .github/workflows/deploy-image.yml # Dockerfile # src/sp_validation/tests/test_cosmo_val.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
FootprintPlotterwas duplicated betweensp_validation.plotsandcs_util.plots, with the local copy stale relative to the canonical cs_util version. This PR deletes the local copy and imports cs_util'sFootprintPlotterdirectly at every call site — the elegant end state, as if the class had always lived in cs_util.What changed
plots.py— the localFootprintPlotterclass is gone; the module no longer references it at all (no re-export shim).cosmo_val.py— dropsfrom .plots import FootprintPlotter; uses the module's existingcs_plotsalias →cs_plots.FootprintPlotter().notebooks/cosmo_val/catalog_paper_plot/plot_gaia_sky.pyandnotebooks/demo_create_footprint_mask.py— importfrom cs_util.plots import FootprintPlotterdirectly.pyproject.toml—cs_util>=0.1.5→>=0.1.9(guarantees the import resolves).from sp_validation.plots import FootprintPlotterno 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
FootprintPlotteris a superset of the old local API (same__init__(nside_coverage=32, nside_map=2048)and public methods, plusvmin/Milky-Way/extent improvements). All call sites were inspected and are compatible:cosmo_val.py:plot_footprints—FootprintPlotter()+create_hsp_map+plot_regionplot_gaia_sky.py—FootprintPlotter(nside_coverage=32, nside_map=2048)+plot_area(..., vmax=...)demo_create_footprint_mask.py—FootprintPlotter()+plot_region/plot_footprint_as_hpTests now run in CI
Previously no unit tests ran in CI: the only live workflow (the docker build) did
python -c "import sp_validation", andci-build.ymlwas dead (triggered onmaster, 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_valdon't re-expose it) and exercisescreate_hsp_mapon a tiny input.testpathsfixed 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.slowon the catalog-data-dependent tests (additive-bias reads the real SP_v1.4.5 catalog;catalog_paths_existchecks files on disk), restoring a fast hermetic-m "not slow"suite (2:54 → 7s);catalog_paths_existalso skips when the data isn't mounted.[test]extra;deploy-image.ymlrunspytest -m "not slow"inside the built image (which carries the full system-dependency stack), so tests run on every push.ci-build.yml.— Claude on behalf of Cail