CLI Reference#
PhenoTypic provides a command-line interface for batch processing plate images.
For a guided walkthrough of the execution modes and the parameters worth knowing, see the CLI Execution Modes tutorial.
Usage#
python -m phenotypic --mode full --pipeline PIPELINE_JSON --input INPUT_DIR --output OUTPUT_DIR [OPTIONS]
Path Options#
-p, --pipeline PIPELINE_JSONPath to a pipeline configuration file created with
pipeline.to_json(). Required forfull,measure, andprocessmodes. Rejected inrecompilemode, which reloads the saved pipeline from the output root.-i, --input INPUT_DIRDirectory containing plate images to process. Required for
fullandprocessmodes. Rejected inmeasureandrecompilemodes, which discover prior outputs from the output root.-o, --output OUTPUT_DIRDirectory where results (measurements, overlays under
deliverables/overlays/<dataset>/, checkpoints) are saved. Required for every mode.
Image Options#
--image-type {Image,GridImage}Image class to use for loading. Case-insensitive. Default:
GridImage.--nrows NNumber of grid rows (GridImage only). Overrides any pipeline-level preset; when omitted, the pipeline preset is used, falling back to 8.
--ncols NNumber of grid columns (GridImage only). Overrides any pipeline-level preset; when omitted, the pipeline preset is used, falling back to 12.
--bit-depth {8,16}Force bit depth. Default: auto-detect.
--detect-mode MODEDetection matrix source channel. One of
gray,red,green,blue,MinRGB,HsvS,HsvV,InvS,LabL,LabA,LabB. Default:gray.--ext EXTDeprecated for per-image output. Forward runs write a single OME-Zarr store per image; only overlay PNG rendering still consults this value. Default:
tiff.
Execution Options#
-m, --mode {full,measure,recompile,process,migrate}Select the execution mode. Default:
full.fullApply the pipeline, measure, and emit all deliverables.
measureRe-run measurements from the per-image OME-Zarr stores in an existing output root. Requires
--pipelineand--output. Rejects--input,--dry-run,--restart,--retry-failures,--overwrite, and--sample.recompileRebuild aggregate deliverables from an existing output root. Requires
--output. Rejects--pipeline,--input, and--dry-run.migrateConvert a legacy
.h5output tree to OME-Zarr stores in place, in two passes: the non-image metadata targets first, then each per-imageresults/<ds>/hdf/<stem>.h5toresults/<ds>/zarr/<stem>.ome.zarrwith its marker re-published. Requires--output. Sources are kept unless--delete-sourcesis passed. Every other writing mode refuses an unconverted tree and points here.processApply the pipeline and export one image layer per input, mirroring the input tree. Requires
--pipeline,--input,--output, and--layer. Warns that--metadata,--no-qc, and--no-dataset-columnare ignored.
--layer {rgb,gray,detect_mat,objmap}Image layer exported by
--mode process; required there and rejected in other modes.rgbwrites an integer TIFF at the source bit depth,gray/detect_mata float TIFF,objmapa 16-bit raw-label PNG.--njobs NNumber of parallel jobs for local execution. Default:
-1(all cores).--force-localRun locally even if SLURM is available.
--dry-runValidate pipeline and list images without processing. Supported by
fullandprocessmodes; rejected bymeasureandrecompile.--sample NProcess only N random images per dataset (for testing).
--random-seed SEEDRandom seed for
--samplereproducibility.
Continuation and Recovery#
Compatible full and process invocations continue automatically when run again.
Staged GPU runs select Stage 1, 2, or 3 from the per-image store, the Stage-2
signal under .phenotypic/progress/, and the Stage-3 completion marker.
--retry-failuresInclude exact terminal scientific failures for the current computation in addition to unfinished images. It does not clear failure history.
--restartClear current machine state and start a new lifecycle.
--overwriteReprocess all images after deleting the output directory contents.
--checkpoint-interval NInsert checkpoint tasks every N images in SLURM arrays. Default: auto-estimate.
SLURM Options#
--slurm KEY=VALUEPass SLURM scheduling parameters as repeated key-value pairs (e.g.,
--slurm slurm_partition=compute --slurm mem_gb=16 --slurm time=120). Use theslurm_prefix for standard SBATCH directives, or the convenience keysmem_gbandtime.timeis an integer number of minutes. The deprecatedtime_minkey is auto-migrated totime.--waitWait for SLURM jobs and their dependent finalizer to complete. For staged GPU runs, success requires the finalizer completion marker. Without this flag, the CLI prints
PROCESSING SUBMITTEDand returns without running local aggregation or claiming completion. Ctrl+C detaches monitoring without cancelling the active epoch.
GPU Staging Options#
A pipeline containing a GpuDetector runs as three stages (CPU preprocess →
resident-model GPU detect → CPU measure). These flags tune Stage 2.
On SLURM, an epoch-fenced dependent controller submits additional Stage-2 arrays while retryable images lack a complete Stage-2 signal. It replaces worker signal/self-requeue behavior. Dynamic controller, array, Stage-3, and finalizer job IDs are recorded in the run ledger for monitoring and cancellation.
--gpu-slurm KEY=VALUEStage-2 SBATCH resources. Inherits and deltas over
--slurm(the CPU profile for Stages 1 and 3); auto-addsslurm_gpus_per_node=1.--gpu-shards NParallel Stage-2 GPU tasks, one whole GPU each. SLURM-only; ignored locally. Default: 1.
--gpu-workers-per-gpu WReserved for future per-GPU replica packing. The current staged worker runs one resident model per GPU shard. Default: 1.
Output Options#
--overlay-alpha FLOATAlpha transparency of the label overlay (0.0-1.0). Default: 0.3.
--no-dataset-columnExclude the
Metadata_Datasetcolumn frommaster_measurements.parquet. The column is included by default.--metadata PATHCSV file to left-join onto the measurements mirror on shared columns. Every CSV row survives: one that matches no measured object is kept with null measurements and
QC_MetadataOnlyset totrue, so strains that were never detected stay visible instead of being silently dropped. Measurement rows with no matching CSV row are dropped. The join lands ondeliverables/measurements.csvand its derivatives —master_measurements.parquetstays a clean, metadata-free archive. (The master is Parquet only:master_measurements.csvwas removed, since the un-joined archive is not the file a human opens.) Metadata headers are normalized in memory toMetadata_<Label>. Recompile never mutates this external file; its regenerated bundle-owned metadata copy is canonical.--study PATHOptional
study.yamlof REMBI Study-level fields (Title, License, Author, …) folded intodeliverables/rembi.yaml; overrides constantMetadata_*columns. Applies tofullandmeasuremodes only — it is silently ignored by--mode recompile.--no-qcSkip the QC compute step in finalize. QC otherwise runs whenever the pipeline has a non-empty
qcsection, writing theqc/artifact and resetting GUI review progress.--skip-validationSkip pipeline validation before processing.
Tuning CLI#
PhenoTypic also ships a hyperparameter-tuning engine, launched as
uv run phenotypic-tune. It searches an ImagePipeline’s parameters with
run, infers a reviewable search space with auto-space, and republishes a
completed distributed run with finalize. The tpe, cmaes, gp, and
nsga2 strategies require the optional tune extra (uv sync --extra tune);
grid and random work out of the box. python -m phenotypic.tune remains
an equivalent module invocation.
See the tuning how-to for an end-to-end walkthrough and the distributed HPCC guide for the shared-journal SLURM flow.
run — run a tuning spec#
uv run phenotypic-tune run SPEC_JSON -i INPUT_DIR [OPTIONS]
Path Options#
SPEC_JSONPositional. Path to a
tuning_spec.jsondescribing the search space, scorer, and budget.-i, --input INPUT_DIRDirectory of plate images to tune against. Required.
-o, --output OUTPUT_DIRDirectory where tuning results are written.
Search Options#
--strategy {grid,random,tpe,cmaes,gp,nsga2}Override the spec’s strategy.
grid/randomuse the built-in configs;tpe/cmaes/gp/nsga2build anOptunaConfig(needs thetuneextra).--n-trials NTrial-budget override.
--screen/--no-screenEnable or disable the two-round screening freeze. Default:
--no-screen.
Storage Options#
--storage-url URLOptuna storage URL. Resolution is command-line URL, tuning-spec URL,
$PHENOTYPIC_TUNE_STORAGE_URL, then the mode default: run-local SQLite locally or an absolute run-localjournal://URL for--slurm. Password-bearing URLs are rejected.
Distributed Options#
--slurm [KEY=VALUE]Submit a distributed worker array and one terminal
afteranyfinalizer instead of running locally. It may be repeated as--slurm KEY=VALUEfor SBATCH settings. A Slurm Optuna run defaults to a shared journal; explicit SQLite storage is rejected before run artifacts are created.--n-workers NNumber of SLURM array workers in the fleet (
--slurmonly). When unset, defaults tomin(8, n_trials)(or 4 if no trial budget is known). The fleet shares the one--n-trialsbudget rather than multiplying it.--slurm-partition NAMESLURM partition for the worker fleet (
--slurmonly). When unset the#SBATCH --partitiondirective is omitted (cluster default).--slurm-mem MEMSLURM
--memfor each worker (--slurmonly), e.g.8G.--slurm-time HMSSLURM
--timewall-clock limit for each worker (--slurmonly), e.g.04:00:00.
Robust-Eval Options#
--held-out-fraction FOverride the spec’s held-out fraction: the target share of plates reserved for the generalization pass.
--cv-group COLOverride the held-out grouping column. When unset, the spec value (then the count scorer’s
groupby[0]) is inferred.
auto-space — infer a search space#
uv run phenotypic-tune auto-space PIPELINE_JSON [OPTIONS]
PIPELINE_JSONPositional. Path to a pipeline JSON created with
pipeline.to_json().-o, --output OUTPUT_DIRDirectory where the inferred search space is written.
--unattendedReserved: skip the interactive review prompt (currently a no-op).
finalize — republish a distributed study#
uv run phenotypic-tune finalize OUTPUT_DIR [--force]
OUTPUT_DIRPositional. Existing distributed tune output directory. The command opens its recorded backing store without creating one, requires the recorded terminal-trial budget and a valid winner, then republishes the durable tuning outputs. It refuses an active lifecycle generation.
--forceCancel the recorded generation first, then continue only after scheduler quiescence and zero unresolved scheduler tokens are proven. Successful re-finalization is byte-identical to the existing publication.