adjusters_api#

class AdjusterKind(value)[source]#

Bases: str, Enum

INSTANCE_OWNER = 'instance_owner'#
OTHER = 'other'#
STATIC_FILLER = 'static_filler'#
class AdjusterSpec(name: 'str', fn: 'AdjusterFn', step: 'Step', phase: 'Phase', watched_keys: 'Optional[Tuple[ConfigKeys, ...]]', owned_keys: 'Optional[Tuple[ConfigKeys, ...]]', kind: 'AdjusterKind' = <AdjusterKind.OTHER: 'other'>, scope: 'AdjusterScope' = <AdjusterScope.EXPERIMENT: 'experiment'>, requires_sample_manager: 'bool' = True, order: 'int' = 100)[source]#

Bases: object

fn: Callable[[Mapping[str, Any], AdjustmentContext], Dict[str, Any]]#
kind: AdjusterKind = 'other'#
name: str#
order: int = 100#
owned_keys: Tuple[tuple[str, ...], ...] | None#
phase: Phase#
requires_sample_manager: bool = True#
scope: AdjusterScope = 'experiment'#
step: Step#
watched_keys: Tuple[tuple[str, ...], ...] | None#
class Phase(value)[source]#

Bases: str, Enum

POST_COMMIT = 'post-commit'#
POST_VALIDATE = 'post-validate'#
PRE_COMMIT = 'pre-commit'#
PRE_VALIDATE = 'pre-validate'#
class Step(value)[source]#

Bases: str, Enum

ADJUST = 'adjust'#
APPLY_RENAMES = 'apply-renames'#
CREATE_CHANNELS_RECONCILE = 'create-channels-reconcile'#
CREATE_PIPELINE_SECTIONS = 'create-pipeline-sections'#
ENSURE_STATIC_BLOCKS = 'ensure-static-blocks'#
POPULATE_DEFAULTS_MATERIALIZE = 'populate-defaults-materialize'#
patch_adjuster(*, step: Step | str, phase: Phase | str = Phase.PRE_VALIDATE, scope: AdjusterScope | str = AdjusterScope.EXPERIMENT, requires_sample_manager: bool = True, watched_keys: Iterable[str | tuple[str, ...]] | None = None, owned_keys: Iterable[str | tuple[str, ...]] | None = None, kind: AdjusterKind | str = AdjusterKind.OTHER, order: int = 100) Callable[[Callable[[Mapping[str, Any], AdjustmentContext], Dict[str, Any]]], Callable[[Mapping[str, Any], AdjustmentContext], Dict[str, Any]]][source]#

Decorator for adjusters. Decorate a pure, idempotent (view, sm) -> patch function.

Parameters:
  • step (Step | str) –

    The step (one of APPLY_RENAMES, CREATE_PIPELINE_SECTIONS, CREATE_CHANNELS_RECONCILE,
    ENSURE_STATIC_BLOCKS, POPULATE_DEFAULTS_MATERIALIZE, ADJUST)

    at which to run this adjuster.

  • phase (Phase | str) –

    The lifecycle phase (one of PRE_VALIDATE, POST_VALIDATE, PRE_COMMIT, POST_COMMIT)

    at which to run this adjuster.

  • watched_keys (Optional[Iterable[ConfigKeysLike]]) – If provided, only run this adjuster if any of these config key prefixes overlap with the changed keys in the current adjustment context.

  • owned_keys (Optional[Iterable[ConfigKeysLike]]) – The config key prefixes that this adjuster may modify. Attempting to modify keys outside this set is an error.

  • kind (AdjusterKind | str) – The kind of adjuster (STATIC_FILLER, INSTANCE_OWNER, OTHER).

  • order (int) – The order in which to run this adjuster relative to others. This is to break ties when multiple adjusters are registered for the same step/phase. Lower order runs first.

to_config_keys(x: str | tuple[str, ...]) tuple[str, ...][source]#
to_config_keys_tuples(xs: Iterable[str | tuple[str, ...]] | None) Tuple[tuple[str, ...]] | None[source]#