SubjectOperator

Note

This page is a reference documentation. It only explains the class signature, and not how to use it. Please refer to the Habitat Guide and Python API guide (v2.0) for usage.

class SubjectOperator(*args, **kwargs)[source]

Bases: Protocol, Generic[TIn, TOut]

A computation that touches exactly one subject.

Declaring this is a contract, not a hint: it tells the execution backend that the work may be parallelised, checkpointed, retried, isolated on failure, and – in a federated deployment – executed inside the hospital that owns the images.

Note what this protocol does NOT introduce: a second method name. It is __call__ plus two pieces of metadata, so every one of the subject-level domain protocols satisfies it automatically and no plugin author ever writes an adapter.

Implementations must be free of shared mutable state so they can be sent to a worker process.

property spec: Spec

Return the algorithm specification, used as part of the cache key.

__call__(item: TIn) → TOut[source]

Process one subject’s payload.

Parameters:

item – The subject-scoped input.

Returns:

The subject-scoped output.

cache_key(item: TIn) → str[source]

Return a stable key identifying this computation for checkpointing.

Parameters:

item – The subject-scoped input.

Returns:

A key combining the subject identity and the spec fingerprint, so that changing an algorithm parameter correctly invalidates a resumed run instead of silently reusing stale results.

__init__(*args, **kwargs)