Skip to content

Latest commit

 

History

History

workflow

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

ShapePipe Snakemake orchestration

Snakemake workflow that orchestrates real-data ShapePipe runs. It is the one production orchestration: there is no CANFAR submission front end and no per-site sbatch layer beside it. The two Gen-2 bash scripts (run_job_sp_canfar_v2.0.bash → job_sp_canfar_v2.0.bash) are still in the tree and still installed (pyproject.toml's [tool.setuptools] script-files): sp_validation's image-simulation workflow calls run_job_sp_canfar_v2.0.bash by path, so they stay until that chain is ported or parked. Module code is untouched: rules call shapepipe_run -c <config> on the existing config chains. Design and rationale: CosmoStat/shapepipe#848 (the design document).

There is no concept of a catalogue version in the code. No path branches on v1.3..v1.6 or v2.0, and there are no sky patches: a campaign is a tile list, and the version of a catalogue is the git tag of the code that produced it.

Use workflow/bin/sp for everything. Bare snakemake all outside sp is unsupported: sp sets the state directory, the SLURM profile, and SP_PHASE, which the Snakefile needs to build the tile/exposure index at parse time. Running snakemake directly skips all of that.

Quick start (nibi)

# One-time: a snakemake env on a SHARED filesystem (/project — NOT /tmp, which
# is node-local; the SLURM executor re-invokes this python inside every job).
uv venv /project/def-mjhudson/cdaley/snakemake-env --python 3.12
source /project/def-mjhudson/cdaley/snakemake-env/bin/activate
uv pip install 'snakemake>=9,<10' 'snakemake-executor-plugin-slurm>=2.7,<3'

# Write a run config (see Run configuration below) that sets at least `run:`,
# the campaign's name; workflow/config.yaml's input_types: and machines: tables supply the rest.

# `psf_model` is `psfex` for data (`fake` for image sims). `mccd` is refused
# until `persist_exp.py` and `merge_star_cat.py` read MCCD products.
# Both `tile_detection` values run SExtractor on the tile image. Under
# `unions_catalogue` (the input_types default for data) the UNIONS per-tile
# catalogue at `inputs.catalogues` is fetched and the detections are joined
# to it, taking its NUMBER; the tile image must be the catalogue's release
# (DR6), or the join fails. `sextractor` (the default for image sims) keeps
# SExtractor's own NUMBER. Either way make_cat writes
# TILE_UNIQUE_ID = tile_id * 10**6 + NUMBER.
# `blend_handling` is ngmix's neighbour treatment: `uberseg` (the default) or
# `noisefill`. Under both, tile_detect adds the coadd segmentation stamps to
# the sexcat as SEG_VIGNET and ngmix's neighbours are the other objects'
# footprints in them. It is chosen per campaign: flipping it on an existing
# run dir reruns tile_ngmix and the rest of the shape chain for every finished
# tile, and reclaimed exposures make that destructive, so a comparison needs
# its own `run:`.

# The committed launcher loads apptainer/1.4.5 + the /project venv, so a
# fresh shell always has the right state.
workflow/bin/sp run -c my_run.yaml      # bring products on disk up to date with the tile list
workflow/bin/sp report -c my_run.yaml   # emit run_report.json now (mid-run is fine)
workflow/bin/sp cancel <run-name-substring>   # scancel this workflow's jobs
workflow/bin/sp container status              # which image the jobs will run

Supported ranges: snakemake>=9,<10, snakemake-executor-plugin-slurm>=2.7,<3. The profiles use Snakemake 9's --sdm software deployment and executor plugins; see profiles/ for the rerun triggers.

Anything other than run, report, container, cancel passes straight through to snakemake with the workflow's profile and state dir — the direct command path for sp --unlock, sp --dag, sp exp_psf ....

Image simulations

The same workflow runs the SKiLLS image simulations used to measure the shear multiplicative bias, so that m calibrates the pipeline that makes the real catalogue rather than a frozen copy of it. A simulation run sets input_type: image_sims, which points $SP_CONFIG at config/cfis_image_sims/. That directory holds real files only for the stages whose input naming differs (tile Git/Uz/Fe, exposure Gie/Sp) and for the true-PSF model; everything else is a symlink into config/cfis/, so a change to the real-data chain reaches the simulations with no second edit. Keep the diff of each overlay file to its cfis/ original confined to input naming.

psf_model: fake is the simulations' true PSF: the exposure stage runs only SExtractor (for the background maps the vignets read), and tile_vignets runs fake_interp_runner, which writes the galaxy_psf product from psf_dict. With no PSF model there is nothing to persist per exposure, so exp_persist, exp_maps and the two merges after them do not run and clean_exposure does not wait on them. Simulations that contain stars can run psfex as the data do. mccd is refused until persist_exp.py and merge_star_cat.py read MCCD products.

One campaign per shear branch, each with its own run config:

SP_PROFILE=candide workflow/bin/sp run -c /path/run_1p2z_grid_1.yaml

Run configuration

A run config passed with -c/--config-file is merged on top of workflow/config.yaml and snapshotted with the code. (-c is sp's own flag; pass snakemake's cores as --cores/-j. SP_RUN_CONFIG still works and is what the jobs read.) SP_PROFILE (default nibi, or machine: in the run config, which must agree with it) and input_type: then select defaults for whatever the run config leaves unset: first the input_types: entry, which supplies what follows from the kind of input (tile_detection, psf_model), then, overriding it, the machines: entry, which supplies tile_list, retrieve (symlink or vos), inputs, outputs, container and psf_dict ($base_dir expands to that machine's base_dir, and $name or ${name} to any top-level scalar of the run config, e.g. $run to run:; write ${name} when word characters follow). run: is required: it also names the campaign's merged catalogues, and config.yaml leaves it unset. An unset required key, or a value of TBD, stops the run at parse time until it is set. A run config therefore only needs what differs, e.g. for one SKiLLS shear branch on candide:

machine: candide
input_type: image_sims
run: 1z2z_grid_3
tile_list: /path/to/tiles.txt
inputs:
  tiles: /n09data/hervas/skills_out/1z2z_grid_3/images/SP_tiles
  exposures: /n09data/hervas/skills_out/1z2z_grid_3/images/SP_exp
outputs:
  run_dir: /path/to/run
  products_dir: /path/to/product
  index_db: /path/to/run/index.sqlite

sp_validation's image-simulation workflow drives these campaigns and measures m from their final catalogues. A simulation campaign ends in the same merged catalogue as a data campaign, written by the same final_cat_merge rule: <products_dir>/final_cat_<run>.hdf5, with the columns of config/cfis_image_sims/final_cat.param and the tile count as the file's n_tiles attribute (there is no n_tiles_final.txt).

On candide, the tile store is not node-local: the profile binds a shared NFS directory to /local/scratch, never the node's /tmp. To use another directory, set tile_store_root: in the run config; sp run binds it to /local/scratch for that campaign. The store names carry a per-campaign hash, so all branches can share one root.

The container image

sp container owns which image the jobs run inside. Two layers, and the second only exists if you ask for one:

  • your cached SIF (~/.cache/shapepipe/shapepipe.sif, SP_CACHE_DIR or SP_CONTAINER to move it) — a read-only pull of the published image, private to you, so nobody else's refresh moves the ground under your running jobs;
  • an optional sandbox (~/.cache/shapepipe/sandbox/, SP_SANDBOX) — the same image unpacked writable, so a pip install into it sticks. The escape hatch for work needing a package the image does not carry yet.

The Snakefile's container: is that resolution, in one order shared by the CLI and the workflow: sandbox → cached SIF → the container: path in config.yaml. With an empty cache, resolution falls back to the configured shared image.

sp container status                      # layers present, active one, revision vs HEAD
sp container pull                        # ghcr.io/cosmostat/shapepipe:develop
sp container pull --tag docker://...     # some other image
sp container sandbox                     # unpack the SIF writable (opt-in)
sp container exec --writable pip install <pkg>
sp container exec python -c 'import shapepipe'
sp container resolve                     # just the path the workflow will run

status reads the image's OCI labels and places its org.opencontainers.image.revision against this checkout's HEAD: in-sync / behind / ahead / diverged, or unknown when the image carries no label or the commit was never fetched here.

pull needs the network. Candide and nibi compute nodes both have it, so pull runs from a login node, an salloc allocation or a batch job alike. pull and sandbox both stage to a sibling path and swap it in, so an in-flight job never sees a half-written image and a failed rebuild leaves the one you had intact.

Execution: two static invocations

The exposure job set is data-derived from the tiles' find_exposures output, so it cannot live in the same static DAG that produces it. sp run is therefore two snakemake invocations over one Snakefile:

  1. PREPARE — snakemake prepare_all_tiles: per-tile static DAG (Git_vos → Uz → Fe), keep-going so tile failures are independent. A nonzero exit still allows COMPUTE to run, but makes sp run fail. Tiles without exposure lists are dropped at the compute parse, subject to SP_MISSING_THRESHOLD (default 0.0).
  2. COMPUTE — snakemake all: this invocation's parse builds the tile↔exposure index (build_index.py, imported at parse time, not a DAG node) and runs the full tile/exposure compute chain. The index accumulates across invocations, so appending tiles later changes which jobs exist without invalidating completed work.

sp run chains both so the UX is one command; both exit codes are checked and the run fails if either phase failed.

The launch code snapshot

sp run copies the code it is about to launch — workflow/ (config symlinks dereferenced), src/, the repo's scripts/ (final_cat_merge loads scripts/python/create_final_cat.py by path) and the profile — into <state dir>/code, records HEAD plus a dirty flag in <state dir>/code/snapshot.json, and runs the campaign entirely out of that copy. It matters because a campaign is not one process: the SLURM executor re-invokes snakemake on every job's node, so jobs re-parse the Snakefile and read workflow/scripts/* and the ini chain hours after launch. Editing the checkout while a campaign runs is therefore harmless; a change takes effect on the next sp run.

Everything workflow-internal hangs off workflow.basedir, which is the snapshot, including the profile's PYTHONPATH pin, which YAML cannot interpolate: sp run rewrites that single path in the snapshot's copy of the profile and launches --profile at the copy. The snapshot is refreshed wholesale on every sp run — a new sp run is the relaunch — and the other verbs run out of the existing snapshot, sp container excepted (it is about the image you are working with now, not about a campaign). The mechanism and its rationale live in one place: bin/sp.

Execution mode: SLURM rules and groups

The profile (profiles/nibi/config.yaml) sets executor: slurm. Ungrouped rule instances become individual SLURM jobs; grouped rules share a job. Rules define attempt-scaled resources (cpus_per_task = threads, mem_mb, runtime) and run inside apptainer exec via the profile's software-deployment method — the workflow never calls apptainer directly. Snakemake feeds the queue as jobs finish, so the full campaign's job count never needs to queue at once, and multi-node scaling is inherent. jobs: in the profile caps concurrent submissions at a fraction of the cluster's per-user submit limit (queried, not invented — see the comment in the profile file for the query and date).

The profile intentionally sets no set-resources / set-threads overrides: those replace a rule's own values wholesale, which would kill the attempt-scaled mem_mb = lambda wc, attempt: ... OOM retries and the tuned ngmix thread count. Rules own their own resources; the profile only supplies defaults for rules that state nothing.

The rule files define the groups and their resource constraints. See workflow/rules/prepare.smk, exposure.smk, and tile.smk for their composition.

Layout

workflow/
  Snakefile              parse-time index load; global container:; onsuccess/onerror report hooks
  config.yaml            the run: tile list, input/output paths, container, chunk count
  bin/sp                 committed launcher (module load + /project venv + launch code snapshot + run/report/container/cancel)
  rules/
    prepare.smk          tile get_images/uncompress/find_exposures
    exposure.smk         per-exposure: get_images, split, psf, persist, maps (no temp()); campaign star_cat_merge, exposure_maps
    tile.smk             per-tile: exp forest, merge_headers, detect (SExtractor, joined to the UNIONS catalogue on data), vignets, ngmix, merge, make_cat; campaign final_cat_merge
  scripts/
    build_index.py       prepare-phase run_index.sqlite builder (plain script)
    build_forest.py      per-tile exposure symlink forest (group-compatible shell)
    completeness.py      the ported count-floor table + the `check` every rule ends with
    run_report.py        standalone report (NOT a DAG node; run_report hooks call it)
    container.py         image layers + the resolution order behind `sp container` (stdlib-only)
    ngmix_range.py       the ngmix chunk partition: written once by tile_vignets, read by each chunk
    persist_exp.py       ONE exposure's keepable PSF products -> one tar on products_dir (the exp_persist rule)
    hdf5_reconcile.py    bring an hdf5 catalogue into agreement with a campaign (shared by both merges)
    merge_star_cat.py    ALL exposures' validation_psf, out of the tars -> full_starcat_<run>.hdf5
    merge_final_cat.py   ALL tiles' final_cat -> final_cat_<run>.hdf5 (the final_cat_merge rule)
    clean_exposure.py    ONE exposure's store + manifests + logs -> tombstone (the clean_exposure rule)
    exp_maps.py          ONE exposure's valid-PSF CCD footprints + flagged-pixel counts -> healsparse fragment (the exp_maps rule)
    merge_exposure_maps.py  ALL fragments -> nexp_<run>.hsp, nflagged_<run>.hsp (the exposure_maps rule)
    clean_tile.py        ONE finished tile's store -> tombstone (the clean_tile rule)
profiles/nibi/config.yaml  SLURM executor; apptainer SDM; per-user jobs cap; keep-going

Products and lifecycle

  • The atom is one rule == one shapepipe_run on one unit. Its single declared output is that unit's manifest (<unit dir>/manifests/<stage>.json), not its product files — a missing CCD is often legitimate, and at DR6 scale per-CCD declaration means millions of paths.

  • Manifests are the DAG's currency, and they are success-only. completeness.py check writes its full verdict — per-runner counts against expected counts, scraped failure reasons, the shapepipe_run exit status when nonzero — to the rule's log: (<unit dir>/logs/<stage>.json) on every run, and additionally to the declared <stage>.json manifest only when that verdict is a success. So <stage>.json on disk means "this stage succeeded", and a resume after an unclean death cannot schedule downstream work on top of a failure. Nothing unlinks anything: Snakemake deletes a failed job's declared output natively and never touches its log, which is why the profile runs without keep-incomplete. sp report reads both dirs — the manifest for success, the log for failure — and a unit with neither ran nothing.

  • Completeness is a count floor, not a taxonomy. There is no per-unit wrapper script: the Snakefile's unit_pre() builds the unit's furniture and clears the stage's run dir as bash inlined into the rule's params, and sp_shell() composes every rule's shell as prologue, one shapepipe_run, one completeness.py check. That check counts products per mandatory runner against completeness.py's floor and exits nonzero below it. Per-CCD attrition between floor and expect is tolerated. No 3-class taxonomy, no error-signature whitelist. --keep-going isolates a failure to its own DAG cone.

  • Stores are sharded. Every tile/exposure runs its own shapepipe_run in tiles/<2-char prefix>/<ID>/ or exp/<prefix>/<base>/. Configs are committed under workflow/config/cfis/ and version with the rules that set the env vars they interpolate — there is no config_src knob, and no per-unit config symlink; $SP_CONFIG points straight at the committed directory.

  • There is no masking stage, on either side. ShapePipe generates no masks (PR #847). The one mask that reaches pixels is the instrument flag image delivered with each exposure, which exp_split splits per CCD beside image and weight and SExtractor reads as IMAFLAGS_ISO. Everything else — star halos, manual masks, per-band coverage, MaxiMask — is supplied as sky-fixed healsparse maps and QUERIED once per object: the mask_query module writes a MASK_EXT column onto each CCD's detection catalogue (inside exp_psf), and make_cat writes one MASK_<band> column per band onto the final catalogue (inside tile_make_cat). Neither is cut on in the pipeline: instrument flags mark corrupted measurements and are the only masks that reject anything here, while the healsparse masks are location flags and every decision about them is downstream. On exposures the query ships off — MASK_PATHS is commented out, making mask_query a no-op pass-through — so turning it on is a config edit, not a chain edit. Map paths are config, not code, so regenerated products cost a config edit. Nothing is fetched from a catalogue server, staged, or rasterized, which is why the old star_catalogue / exp_star_cat / exp_mask rules and their cache root are gone.

  • Four HealSparse maps come out of the exposures. At nside 131072, npoint_<run>.hsp counts filled pointing hulls of present main-array CCDs 0–35. The hull fills CCD gaps and excludes ear CCDs 36–39, regardless of PSF success. ntaken_<run>.hsp counts exposures covering each pixel with any CCD's DATASEC, ears included. nexp_<run>.hsp counts only CCDs with a validated PSF; ntaken - nexp measures CCD-level PSF losses. These three counts are uint8. nflagged_<run>.hsp (uint16) counts flagged CCD pixel centres inside validated CCD DATASEC coverage, with ~74 CCD pixels per sky pixel. The overscan border contributes neither coverage nor flags. exp_maps writes one packed uint16 fragment beside each PSF tar: the low three bits store 1 = pointing, 2 = taken, 4 = validated, and bits 3–10 store flag counts clipped at 255. Scalar fragments use compressed image storage (~2.6 MB per exposure); record-array table storage costs ~31 MB. exposure_maps sums the fragments; nothing in the workflow reads the four maps. npoint follows the v1.X npoint3 coverage-cut lineage, nexp supports an N_EPOCH cut, and nflagged diagnoses detector defects rather than exposures lost to the defect veto. A plain uint8 fragment is rejected with an exposure-specific backfill command. For reclaimed scratch stores, raw-MEF mode rewrites both the fragment and its completion manifest (the fragment is the durable DAG edge):

    python workflow/scripts/exp_maps.py --exp "$exp" \
      --image-mef "$raw/${exp}p.fits.fz" --flag-mef "$raw/${exp}p.flag.fits.fz" \
      --persist-manifest "$products/exp/${exp:0:2}/$exp/manifests/exp_persist.json" \
      --fragment "$products/exp/${exp:0:2}/$exp/maps/maps-$exp.hsp" \
      --manifest "$products/exp/${exp:0:2}/$exp/manifests/exp_maps.json"
  • External masks are wired, on the tile side only (data runs). inputs.masks is a third input root beside tiles and exposures, set per machine in the machines: table, exported as $SP_INPUT_MASKS and pointing at the UNIONS DR6 ugriz bit ladder: one boolean healsparse map per bit, nside 131072, True = masked. config_tile_Mc.ini names all 11 of them in MASK_EXT_PATHS under a <flag value>_<name> label, so make_cat writes MASK_1_Faint_star_halos … MASK_2048_z2 and final_cat.param carries the matching 11 names; the config holds the label table. MASK_2048_z2 is True where there is no Pan-STARRS z data, so an OR over every column masks everything. ShapePipe cuts on none of them; the mask choice is sp_validation's.

  • The index is parse-time data, never a rule input. Appending tiles changes which jobs exist without invalidating completed work.

  • Exposure products are not temp(). Exposures overlap tiles, so temp() would cascade destructive reruns when a tile is appended later. Reclamation is the in-DAG clean_exposure rule instead: one job per exposure, taking every consuming tile's tile_vignets manifest as input (the campaign-wide consumer set comes from the accumulating index), which deletes the store and the exposure's manifests/ and logs/, and leaves a cleaned.json tombstone. Deleting the manifests is what makes a late append correct: the appended tile finds an unbuilt chain and regenerates it. The clean: flag in config.yaml gates it; flipping it on later reclaims retroactively, since the missing tombstones schedule exactly the outstanding clean jobs. The tombstone is written before anything is deleted, so a crash can cost disk but never the record.

  • Tile epoch-cut diagnostics survive cleaning. tile_ngmix completeness checks capture PR #922's five counters before each chunk's temporary directory goes away. tile_make_cat sums all configured chunks and publishes tile_make_cat.json beside the tile's persistent final_cat. Its epoch_cuts field contains schema_version, n_chunks, per-chunk chunks, and tile totals for considered, masked_fraction, central_veto, failed, and objects_emptied. Counts are sequential veto counts, not independent cut incidences; objects_emptied counts objects whose considered epochs were all removed before fitting. Missing, malformed, or duplicate summaries fail completeness rather than becoming zeros. clean_tile validates the durable count record before touching scratch, so clean_tiles: true needs no module-log retention override. This requires an ngmix build with PR #922's end-of-loop epoch cuts: summary, including on empty chunks. Older code without that summary fails the ngmix completeness check and leaves scratch intact.

    Every tile joined to the external catalogue also publishes catalogue_match in this same tile_make_cat.json (under <products_dir>/tiles/<shard>/<tile>/). It contains integer n_sextractor, n_external, n_paired, n_external_only, n_dropped, plus external_paired_fraction (zero for an empty external catalogue) and external_warning_budget. The budget is max(20, 0.02 * n_external + 50) when any pairs exist, otherwise max(20, 0.02 * n_external); exceeding it only warns. The SExtractor-side mismatch still fails hard. The record travels from detection FITS headers through tile_detect.json before scratch cleanup, without changing catalogue rows. Join the manifest's unit converted to float to the final catalogue's TILE_ID to cut downstream; records exist for passing and warning tiles alike, including zero-object tiles. Runs without an external join omit catalogue_match. A zero-detection tile is valid: detection writes zero-row LDAC_OBJECTS/EPOCH_* tables and an explicitly shaped SEG_VIGNET; pairing records zero pairs and warns when above budget. PSF interpolation and vignette extraction write empty SQLite stores, each ngmix chunk and their merge write five zero-row shear HDUs with zero epoch-cut counts, and make-cat publishes an HDF5 catalogue with the normal columns and zero rows. Completeness counts these files, not their rows; the campaign merge retains the tile as a zero-length structured dataset rather than losing its identity. The workflow keeps its configured static ngmix fan-out even for zero objects: ngmix_range.py writes a normal ranges document with every chunk set to the positive empty interval (2, 1). This avoids the unbounded ROW_MAX <= 0 sentinel and lets every scheduled chunk publish its normal empty product, so merge and completeness need no separate zero-chunk graph. Nonzero partitions are unchanged. For example, real b619 tile 058.220 has (n_sextractor, n_external, n_paired, n_external_only, n_dropped) = (774, 845, 774, 71, 0), fraction 774/845 = 0.9159763313609467, budget 66.9, and now warns rather than failing.

    For an idle existing campaign with kept logs, use workflow/scripts/backfill_epoch_cuts.py --run-dir <run> --products-dir <products> --n-chunks <N> --dry-run first. Alternatively pass --config <run_config.yaml> to resolve products and chunk count from the run's frozen workflow/config.yaml plus its run config. The script skips tiles without a nonempty persisted catalogue and refuses missing or ambiguous chunk evidence. Without --dry-run, it publishes the same manifest schema and reclaims through clean_tile.reclaim, including its survivor checks and tombstone. Don't use it while jobs or another cleaner are writing the campaign. Dry-run reads metadata and small logs only, writes nothing, and reports logical regular-file bytes (not allocated blocks), without following symlinks.

    Deploy at a campaign boundary. The completeness/helper hash is part of every ShapePipe rule's params; this change also alters make-cat's params, outputs and shell, and clean-tile's inputs and shell. An ordinary resume against old completed tiles can therefore schedule science stages again, even after their exposure stores have been reclaimed. Backfill old campaigns without changing their frozen code or resuming them against this workflow; removing the log-retention override is appropriate for new campaigns running this contract.

  • A finished tile declares no reclaimed exposures. Deleting an exposure's manifests would otherwise rerun every other tile that reads it, and those reruns spread across the exposure-overlap component. So a tile whose final_cat exists drops the exposure manifests that are gone from its input list, and holds the rest through ancient(). This is why the profile runs with rerun-triggers: [mtime, params, code, software-env]: the input trigger reads that cut as a reason to rerun the very tiles it protects. Know the consequence — --forcerun on a tile whose final_cat exists will not rebuild its reclaimed exposures. Delete the final_cat first.

  • PSF products are persisted independently of scratch cleanup. exp_persist writes <products_dir>/exp/<prefix>/<base>/psf/<base>.tar and a manifest, even with clean: false. See workflow/scripts/persist_exp.py for retention guarantees, measured storage costs, and packing details; see workflow/CONTRACTS for cleanup ordering.

  • Configure optional retention with persist_exp:. Product names and their meanings live in workflow/scripts/persist_exp.py; persist_exp.py --list-products prints them. The default is psf_model, and psf_validation is mandatory regardless of the list. Retention is additive: shrinking the list does not remove saved products. Remove products explicitly from products_dir.

  • The campaign ends in two merged catalogues, and the workflow makes both. Everything above is per unit; the two products downstream analysis actually opens are per campaign. star_cat_merge collects every exposure's every CCD's psf_validation into <products_dir>/full_starcat_<run>.hdf5, one dataset per exposure at exposures/<exp> — the rho/tau statistics input. It reads the members straight out of the per-exposure tars (tarfile; unpacking ~800k files to merge them would defeat the tar's whole purpose), keeps their native dtypes, and stores CCD_NB as an int. sp_validation opens the flat FITS name, full_starcat-0000000.fits; its readers move to this file under sp_validation#340, the same migration that retires the patches/ key on the tile side. The rule exists whenever the campaign has a persisted exposure. Two writers, one schema. The module runner still emits the flat FITS table through MergeStarCatPSFEX, and this rule emits the hdf5; they are separate implementations on purpose, because only one of them reads tars, keeps native dtypes and reconciles. Their column names must agree; tests/unit/test_star_cat_columns.py enforces that coupling. final_cat_merge collects every ready tile's final_cat-<ID>.hdf5 into <products_dir>/final_cat_<run>.hdf5: one dataset per tile under a group named patches/<run>, the final_cat.param columns, an n_tiles attribute. That schema is what sp_validation's reader opens, so it is fixed; the column extraction reuses scripts/python/create_final_cat.py while the file is written here, because that script's own discovery walks a directory layout this workflow does not have. The run config's run: names both files and the group. Both reconcile through one shared module (hdf5_reconcile.py) so the campaign's two products cannot disagree about what an output owes its inputs. Each adds the units that have no dataset, drops datasets whose unit left the campaign, re-reads one whose source changed (every dataset records its source's size and mtime) or whose column set moved (a digest on the file's root), and leaves the rest unread — because re-reading a campaign to add one unit is ~800 GB of IO at DR6 scale. The content is still a function of the input set; the byte layout is not, and a no-op leaves the file untouched rather than rewritten. Both rerun when the set changes: the unit ids' fingerprint rides on params. Neither is a localrule — one job over ~20k units is real work — and neither puts its input paths in its shell, which is not fastidiousness: ~20k paths is an order of magnitude over Linux's 128 KiB MAX_ARG_STRLEN for a single argv entry, so each job is handed the tile list and the run index and derives the same set from them.

  • A dead tile can be told to stop pinning exposures. An exposure is cleanable only once every consuming tile has its vignets, so one permanently-failed tile holds its ~80 exposures for the life of the campaign. List it under clean_ignore_tiles: in config.yaml and it leaves the consumer sets. Retrying an ignored tile later is legal and expensive: its exposure chains are gone and rebuild from scratch.

  • A reclaimed exposure reports as cleaned. run_report.py reads the absorbed manifests out of cleaned.json, so a reclaimed exposure keeps its per-runner counts and blocks no tile. The logs go with the manifests — a log claiming complete for a store that is gone would contradict the unbuilt chain the DAG must see, and its content duplicates the manifest anyway. The exp_psf benchmark tsv lives beside both dirs, not inside either, so reclamation does not eat the memory-sizing data.

  • Failure is a report, not a gate. run_report.py disk-scans the trees against the count table and enumerates shortfalls (whole-unit absence vs per-CCD attrition). It runs standalone — a DAG report node would itself be poisoned by the failures it must enumerate — and fires automatically from the COMPUTE invocation's onsuccess/onerror hooks, or on demand via sp report.