phenotypic.tune.run_tuning#

phenotypic.tune.run_tuning(spec: TuningSpec, images: list, output_dir: Path, *, strategy: str | None = None, n_trials: int | None = None, screen: bool = False, storage_url: str | None = None, slurm: bool = False, spec_path: Path | None = None, images_dir: Path | None = None, held_out_fraction: float | None = None, cv_group: str | None = None, n_workers: int | None = None, slurm_partition: str | None = None, slurm_mem: str | None = None, slurm_time: str | None = None, slurm_constraint: str | None = None, nrows: int | None = None, ncols: int | None = None) Trial | None[source]#

Run spec over images and write the deliverables/ artifacts.

Writes trials.parquet (root) and, under deliverables/, tuning_spec.json / best_pipeline.json / param_importance.json. --strategy overrides the spec’s strategy (selecting the Optuna study backend for an Optuna sampler); --screen runs the two-round freeze; --storage-url / $PHENOTYPIC_TUNE_STORAGE_URL names a shared Optuna store; --slurm submits a distributed worker fleet.

Parameters:
  • spec (TuningSpec) – The tuning recipe.

  • images (list) – The calibration images.

  • output_dir (Path) – The run directory.

  • strategy (str | None) – Optional --strategy override (grid/random/tpe/cmaes/gp/nsga2).

  • n_trials (int | None) – Optional trial-budget override forwarded to the strategy.

  • screen (bool) – Whether to run the two-round screening freeze.

  • storage_url (str | None) – Optional Optuna storage URL (falls back to the env var).

  • slurm (bool) – Whether to submit a distributed worker fleet instead of running locally.

  • spec_path (Path | None) – Path to the on-disk tuning_spec.json (required for --slurm so each worker can load it).

  • images_dir (Path | None) – The calibration image directory (required for --slurm).

  • held_out_fraction (float | None) – Optional --held-out-fraction override of the spec’s HeldOutConfig.held_out_fraction (robust-eval). None keeps the spec value. CLI flag > spec value > inference.

  • cv_group (str | None) – Optional --cv-group override of the held-out grouping column (HeldOutConfig.group_key). None keeps the spec value (then the scorer’s inferred groupby[0]). The gap margins stay spec-only.

  • n_workers (int | None) – Optional --n-workers override of the SLURM fleet size (--slurm only); None keeps the min(8, n_trials) default.

  • slurm_partition (str | None) – Optional --slurm-partition for the worker fleet (--slurm only); None omits the #SBATCH --partition directive (the cluster default partition).

  • slurm_mem (str | None) – Optional --slurm-mem per worker (--slurm only), e.g. "8G"; None omits the directive.

  • slurm_time (str | None) – Optional --slurm-time wall-clock limit per worker (--slurm only), e.g. "04:00:00"; None omits the directive.

  • slurm_constraint (str | None)

  • nrows (int | None)

  • ncols (int | None)

Returns:

The best Trial, or None (e.g. a fire-and-forget SLURM submission, or no successful trial).

Return type:

Trial | None