Skip to content

Decorators

Convenience factories and decorators for core classes.

  • BASELINE_CONDITION
  • CONDITION_KEY
  • METADATA_FILENAME
  • REPLICATE_KEY
  • SEED_USED_KEY

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.


pipeline_step(cacheable: 'bool' = False) → Callable[..., PipelineStep]

Decorate a function and convert it into a :class:PipelineStep factory.


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.


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.


data_source(fn: 'Callable[..., Any]') → Callable[..., DataSource]

Decorate a function to produce a :class:DataSource factory.


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.


pipeline(*steps: 'PipelineStep') → Pipeline

Instantiate a :class:Pipeline from the given steps.


A picklable, callable class that wraps a resource-creating function.

__init__(fn: 'Callable[[FrozenContext], Any]', key: 'str | None' = None)

A picklable callable that wraps the verifier function with fixed parameters.

__init__(
fn: 'Callable[..., Any]',
params: 'dict',
param_names: 'list[str]',
factory: 'Callable[..., Any]'
)