Decorators
module crystallize.utils.decorators
Section titled “module crystallize.utils.decorators”Convenience factories and decorators for core classes.
Global Variables
Section titled “Global Variables”- BASELINE_CONDITION
- CONDITION_KEY
- METADATA_FILENAME
- REPLICATE_KEY
- SEED_USED_KEY
function resource_factory
Section titled “function resource_factory”resource_factory( fn: 'Callable[[FrozenContext], Any]', key: 'str | None' = None) → Callable[[FrozenContext], Any]Wrap a factory so the created resource is reused per thread/process.
function pipeline_step
Section titled “function pipeline_step”pipeline_step(cacheable: 'bool' = False) → Callable[..., PipelineStep]Decorate a function and convert it into a :class:PipelineStep factory.
function treatment
Section titled “function treatment”treatment( name: 'str', apply: 'Union[Callable[[FrozenContext], Any], Mapping[str, Any], None]' = None) → Union[Callable[[Callable[[FrozenContext], Any]], Callable[..., Treatment]], Treatment]Create a :class:Treatment from a callable or mapping.
When called with name only, returns a decorator for functions of (ctx). Providing apply directly returns a Treatment instance.
function hypothesis
Section titled “function hypothesis”hypothesis( verifier: 'Callable[[Mapping[str, Sequence[Any]], Mapping[str, Sequence[Any]]], Mapping[str, Any]]', metrics: 'str | Sequence[str] | Sequence[Sequence[str]] | None' = None, name: 'Optional[str]' = None) → Callable[[Callable[[Mapping[str, Any]], float]], Hypothesis]Decorate a ranker function and produce a :class:Hypothesis.
function data_source
Section titled “function data_source”data_source(fn: 'Callable[..., Any]') → Callable[..., DataSource]Decorate a function to produce a :class:DataSource factory.
function verifier
Section titled “function verifier”verifier( fn: 'Callable[..., Any]') → Callable[..., Callable[[Mapping[str, Sequence[Any]], Mapping[str, Sequence[Any]]], Mapping[str, Any]]]Decorate a function to produce a parameterized, picklable verifier callable.
function pipeline
Section titled “function pipeline”pipeline(*steps: 'PipelineStep') → PipelineInstantiate a :class:Pipeline from the given steps.
class ResourceFactoryWrapper
Section titled “class ResourceFactoryWrapper”A picklable, callable class that wraps a resource-creating function.
method ResourceFactoryWrapper.__init__
Section titled “method ResourceFactoryWrapper.__init__”__init__(fn: 'Callable[[FrozenContext], Any]', key: 'str | None' = None)class VerifierCallable
Section titled “class VerifierCallable”A picklable callable that wraps the verifier function with fixed parameters.
method VerifierCallable.__init__
Section titled “method VerifierCallable.__init__”__init__( fn: 'Callable[..., Any]', params: 'dict', param_names: 'list[str]', factory: 'Callable[..., Any]')