Skip to content

Add per-shard CLI and Metadata_Imaging_ImageID propagation - #49

Closed
d33bs wants to merge 1 commit into
WayScience:mainfrom
d33bs:main
Closed

Add per-shard CLI and Metadata_Imaging_ImageID propagation#49
d33bs wants to merge 1 commit into
WayScience:mainfrom
d33bs:main

Conversation

@d33bs

@d33bs d33bs commented Aug 5, 2026

Copy link
Copy Markdown
Member

Description

This PR focuses on productionizing the CLI for use with orchestration for the NF1 project. We add an image_id arg in many spots to help enforce data provenance, which is important for warehousing and may fit in nicely with task parallelization.

What kind of change(s) are included?

  • Documentation (changes docs or other related content)
  • Bug fix (fixes an issue).
  • Enhancement (adds functionality).
  • Breaking change (these changes would cause existing functionality to not work as expected).

Checklist

Please ensure that all boxes are checked before indicating that this pull request is ready for review.

  • I have read and followed the CONTRIBUTING.md guidelines.
  • I have searched for existing content to ensure this is not a duplicate.
  • I have performed a self-review of these additions (including spelling, grammar, and related).
  • These changes pass all pre-commit checks.
  • I have added comments to my code to help provide understanding
  • I have added a test which covers the code changes found within this PR
  • I have deleted all non-relevant text in this pull request template.

ZedProfiler is the feature extractor the NF1 pipeline dispatches per
well/FOV shard via SLURM sbatch. This commit adds the command that process
runs and the identifier column that makes shards warehouse-joinable.

CLI (src/zedprofiler/cli.py):
- "ZedProfiler run" subcommand (argparse): repeatable --image/--label
  NAME=PATH flags, --anisotropy-spacing Z Y X, identifier fields
  (--patient-tumor/--plate/--well/--field), --out-dir, a --features
  selector, repeatable --feature TYPE[,key=value,...] advanced requests,
  --skip-existing, and --force.
- Reuses the six compute_* featurizers; builds the shared loader via
  ImageSetLoader.from_image_dict with the identifier fields.
- Restartable/idempotent: deterministic output paths, --skip-existing
  filters before any image is read (a finished shard re-run skips I/O
  entirely), and atomic writes (temp + os.replace) so a crashed shard
  never leaves a partial file that --skip-existing would mistake for
  complete.
- Fixes the orphaned/mis-cased console script to zedprofiler.cli:trigger.

Identifiers (src/zedprofiler/identifiers.py):
- build_image_id(patient_tumor, plate, well, field) -> deterministic
  Metadata_Imaging_ImageID; single source of truth for the format.

Loaders (src/zedprofiler/IO/loading_classes.py):
- ImageSetConfig carries patient_tumor/plate/well/field with an image_id
  property; ImageSetLoader exposes image_id (falls back to image_set_name).
- New from_image_dict classmethod builds a multi-channel loader from an
  in-memory {key: ndarray} dict (the path the CLI needs); it derives
  compartments/image names directly from the declared label keys so it is
  self-contained and correct independent of get_compartments.

Featurizers (6 modules):
- Each emits Metadata_Imaging_ImageID before Metadata_Experiment_ImageSet.
  Feature values are unchanged; only a metadata column is added.

Feature writing:
- save_features_as_parquet gains an opt-in atomic flag used by the CLI.

End-to-end CLI tests self-skip when the CellProfiler 3D tutorial data is
absent (it lands via a separate data commit), so the CLI test module stays
green everywhere and runs in full wherever the data is available.
@d33bs

d33bs commented Aug 5, 2026

Copy link
Copy Markdown
Member Author

Wrong branch 😓

@d33bs d33bs closed this Aug 5, 2026
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.

1 participant