phenotypic.sdk_.typing_ module#
- class phenotypic.sdk_.typing_.TuneSpec(low: float | None = None, high: float | None = None, *, step: float | None = None, log: bool = False, categories: tuple | None = None, tunable: bool = True)[source]#
Bases:
objectPer-field tuning-search metadata (Tier-1 inference override).
TuneSpecmirrors the existing field-marker pattern (_ColumnRefMarker,_OperationFieldMarker): a frozen, slotted, non-pydantic sentinel that is a complete no-op at runtime and is read only byinfer_search_space, viaop.model_fields[name].metadata(where pydantic v2 storesAnnotatedextras). It rides in anAnnotated[T, TuneSpec(...)]chain:class GaussianBlur(ImageEnhancer): sigma: Annotated[float, TuneSpec(0.5, 5.0, log=True)] = 2.0 truncate: Annotated[float, TuneSpec(tunable=False)] = 4.0
At runtime
sigmais still a plainfloat;GaussianBlur(sigma=999.0)constructs exactly as before. The marker is the search domain, never the valid domain — validity stays the job of pydanticField(ge=, le=).It lives here (not in
phenotypic.tune) so operation modules can import it without dragging in the tune engine — the public re-exportfrom phenotypic.tune import TuneSpecstill works.- Parameters:
low (float | None) – Inclusive lower search bound (positional).
Noneleaves the bound to Tier-2 inference / the co-locatedFieldconstraint.high (float | None) – Inclusive upper search bound (positional).
Noneaslow.step (float | None) – Discretization stride — integer step or quantized float.
Nonemeans continuous (or unit-step for integers).log (bool) – Whether to sample on a logarithmic scale (default
False).categories (tuple | None) – Override / subset the auto-derived categorical choices. A list is coerced to a tuple so the marker stays hashable.
tunable (bool) –
Falseexcludes the field from tuning outright and short-circuits Tier-2 (defaultTrue).
Note
This is not a pydantic model — it is a plain slotted sentinel so it can sit in an
Annotatedchain without pydantic trying to validate it. It carries__eq__/__hash__over the full field tuple so a duplicate in anAnnotatedchain de-dupes (PEP 593 chain semantics).
- phenotypic.sdk_.typing_.polymorphic_field(base: type | Callable[[], type], *, marker: Any = None)[source]#
A pydantic field for a polymorphic model subtree.
The concrete subclass survives a JSON round-trip via the
phenotypicclass registry: the field serializes to{"class": <name>, "params": {...}}(or the pipeline-tagged form for anImagePipeline) and reconstructs the concrete subclass on load.- Parameters:
base (type | Callable[[], type]) – Constrains the accepted/validated type — a class or a zero-arg callable returning the class (the lazy form avoids import cycles, e.g.
OperationFieldnamingBaseOperation).marker (Any) – Optional sentinel attached to the
Annotatedchain (e.g. the GUI’s_OperationFieldMarker) so introspecting tools can recognise the field despite theAnycore erasure.
- Returns:
An
Annotatedtype usable as a pydantic field annotation. Host models must setmodel_configwitharbitrary_types_allowed=True.
- phenotypic.sdk_.typing_.CheckpointType#
--checkpoint-typeflag values for the SLURM sentinel handler.alias of
Literal[‘manifest’, ‘finalize’]
- phenotypic.sdk_.typing_.CliMode#
Public top-level CLI execution mode.
fullperforms the normal apply-and-measure run,measurereruns measurement from existing HDFs,recompilerefreshes aggregate outputs from an existing output root, andprocessperforms the apply-only single-layer export selected by--layer.alias of
Literal[‘full’, ‘measure’, ‘recompile’, ‘process’]
- phenotypic.sdk_.typing_.CompositeBlend#
The single-objective composite blend selector — the serialized value of
CompositeScorer.blend."tchebycheff"(default) is conjunctive (worst-axis-dominant, augmented Tchebycheff over per-child cost);"weighted_mean"is the compensatory opt-out. No Enum partner is needed — this is a serialized field value with no separate documentation surface (mirrorsDetectMode/ExecutionMode). The geometric-mean-of-cost blend is intentionally NOT offered (it inverts the conjunctive property).alias of
Literal[‘tchebycheff’, ‘weighted_mean’]
- phenotypic.sdk_.typing_.DinoSize#
DINO backbone size for DinoSam2Detector. Maps with DinoVersion to the HF model id (e.g. (2, “base”) -> “facebook/dinov2-base”).
alias of
Literal[‘small’, ‘base’, ‘large’]
- phenotypic.sdk_.typing_.DinoVersion#
DINO backbone generation for DinoSam2Detector. 2 = DINOv2 (Apache, ungated, default); 3 = DINOv3 (gated, opt-in — routes through require_license_acceptance). Type-only closed set (no Enum / documentation surface needed).
alias of
Literal[2, 3]
- phenotypic.sdk_.typing_.ExecutionMode#
Forward-run / recompile execution backend. Bare-string carrier for serialization (
progress/job_metadata.json); callers convert to/from the dataclass field of the same name onProcessingState/ExecutionResults.alias of
Literal[‘local’, ‘slurm’]
- phenotypic.sdk_.typing_.FailureSource#
Tag attached to each row of
progress/failures.jsonldistinguishing Python-side exceptions from SLURM sbatch failures.alias of
Literal[‘python’, ‘slurm’]
- phenotypic.sdk_.typing_.GpuInputLayer#
Image layer a GpuDetector consumes as model input. Single-channel layers (gray/detect_mat) are stacked to (H, W, 3) by GpuDetector.preprocess.
alias of
Literal[‘rgb’, ‘gray’, ‘detect_mat’]
- phenotypic.sdk_.typing_.GpuOutputKind#
Object output a GpuDetector produces. “instance” -> labeled objmap; “semantic” -> binary objmask (auto-labels into objmap, like a threshold detector).
alias of
Literal[‘instance’, ‘semantic’]
- phenotypic.sdk_.typing_.ImageTypeName#
String form of the
IMAGE_TYPESEnum’sBASEandGRIDmembers, which are the only two image-type values that cross CLI / GUI boundary code today. OtherIMAGE_TYPESmembers (CROP / OBJECT / GRID_SECTION) are internal to the core library and don’t need a Literal partner yet.alias of
Literal[‘Image’, ‘GridImage’]
- phenotypic.sdk_.typing_.NdArrayField#
Annotated
np.ndarrayusable as a pydantic field annotation.Accepts a
list/ nested list or annp.ndarrayas input, serializes to a JSON-native nested list, and reports an"array"JSON schema. The host model must declaremodel_configwitharbitrary_types_allowed=True(the field type is the arbitrary, non-pydanticnp.ndarray).Example
>>> import numpy as np >>> from pydantic import BaseModel, ConfigDict >>> from phenotypic.sdk\_.typing_ import NdArrayField >>> class KernelOp(BaseModel): ... model_config = ConfigDict(arbitrary_types_allowed=True) ... kernel: NdArrayField >>> op = KernelOp(kernel=[[1, 0], [0, 1]]) >>> isinstance(op.kernel, np.ndarray) True >>> op.model_dump(mode="json")["kernel"] [[1, 0], [0, 1]] >>> KernelOp.model_json_schema()["properties"]["kernel"]["type"] 'array'
alias of
Annotated[ndarray,BeforeValidator(func=_coerce_to_ndarray, json_schema_input_type=PydanticUndefined),PlainSerializer(func=_ndarray_to_list, return_type=list, when_used=always),WithJsonSchema(json_schema={‘items’: {}, ‘type’: ‘array’}, mode=None)]
- phenotypic.sdk_.typing_.OperationField#
Annotated operation type usable as a pydantic field annotation for a parameter that holds another operation or a nested pipeline.
Back-compat alias — an operation/pipeline-valued field built by
polymorphic_field(). Serializes to a class-tagged dict so the concrete subclass survives a JSON round-trip; deserializes by resolving the class through thephenotypicregistry. Use it directly (OperationField) or inside a container — e.g.list[OperationField]— when the field must accept several operation types and round-trip each losslessly.The core type is
Any(naming the operation base classes here would create an import cycle throughsdk_); anAfterValidatorrestores the operation/pipeline type guard. The trailing_OperationFieldMarkerlets the GUIOperationRegistryrecognise the field despite theAnyerasure.alias of
Annotated[Any,BeforeValidator(func=_deserialize_operation_value, json_schema_input_type=PydanticUndefined),AfterValidator(func=_require),PlainSerializer(func=_serialize_operation_value, return_type=PydanticUndefined, when_used=always), _OperationFieldMarker()]
- phenotypic.sdk_.typing_.ProcessOnlyLayer#
Image layer a process-mode CLI run exports. A closed subset of the layers exposed as Image accessors;
rgb/gray/detect_matsave as TIFF,objmapas a raw-label PNG.alias of
Literal[‘rgb’, ‘gray’, ‘detect_mat’, ‘objmap’]