Skip to content

salvus.flow.acta.normalize

salvus.flow.acta.normalize salvus flow acta normalize

Composable normalization of task arguments for cache keys and manifests.

For example, pass ignore_args(["site"]) | round_to_significant_digits(["x"], digits=6) as a task’s normalize= option. Stages run from left to right and may include custom mapping callables on either side of |. Task bodies still receive their original arguments.

Every named argument must exist when its stage runs, including arguments removed by an earlier stage. Defaults are available before normalization; default elision happens afterward. Rich inputs arrive as artifact digests, so rounding applies only to numeric scalar arguments.

Functions

ignore_args()

def ignore_args(names: Sequence[str]) -> Normalizer: ...

Exclude selected arguments from cache keys and manifests.

Parameters
  • names Sequence[str] — Argument names to remove. Duplicates are ignored; an empty sequence leaves arguments unchanged. A bare string is invalid.
Returns Normalizer

round_to_significant_digits()

def round_to_significant_digits(
    names: Sequence[str], digits: int
) -> Normalizer: ...

Round selected integer or float scalars for cache keys and manifests.

Floats use Python’s g formatting and retain float type. Integers use exact integer rounding with ties to even and retain integer type. Booleans, containers, and other numeric types are unsupported.

Parameters
  • names Sequence[str] — Argument names to round, with the same rules as ignore_args.
  • digits int — Positive number of significant digits; booleans are invalid.
Returns Normalizer

Classes

Normalizer

class Normalizer(builtins.object):
    def __init__(self, stages: tuple[_Stage, ...]) -> None: ...

A reusable pipeline of argument transformations.

Combine helpers or custom callables with | in execution order. Each stage receives a fresh shallow dictionary copy. Custom callables are responsible for avoiding mutation of nested values.

Parameters
  • stages tuple[_Stage, ...] — The transformations to apply in order.