Skip to content

flow

flow

Author-facing loop and trigger configuration.

Attributes

MAX_LOOP_ITERATIONS module-attribute

MAX_LOOP_ITERATIONS = 10000

Upper bound on max_iterations and on a cap resolved from a prompt variable (#568).

A literal max_iterations and a count or max_iterations read from a prompt variable must not exceed it. A literal count has no upper bound.

Classes

FlowIssue dataclass

FlowIssue(check, span, message, hint=None)

One independently actionable flow configuration error.

FlowConfigError

FlowConfigError(issues)

Bases: ValueError

Carries all flow violations through Pydantic to the S3 renderer.

Source code in src/marianne/core/config/flow.py
def __init__(self, issues: tuple[FlowIssue, ...]) -> None:
    self.issues = issues
    super().__init__("; ".join(issue.message for issue in issues))

Functions:

canonical_span

canonical_span(value)

Normalize inclusive sheet spans, rejecting ambiguous spelling.

Source code in src/marianne/core/config/flow.py
def canonical_span(value: Any) -> str:
    """Normalize inclusive sheet spans, rejecting ambiguous spelling."""
    if isinstance(value, bool):
        raise ValueError("a boolean is not a sheet span")
    if isinstance(value, int):
        if value < 1:
            raise ValueError("sheet span must start at 1 or above")
        return str(value)
    if not isinstance(value, str):
        raise ValueError("sheet span must be an integer or a string 'N' or 'N-M'")
    match = _SPAN_RE.fullmatch(value)
    if match is None:
        raise ValueError(f"invalid sheet span {value!r}: use N or N-M with ASCII digits, no spaces")
    start = int(match.group(1))
    end = int(match.group(2) or start)
    if start < 1 or end < start:
        raise ValueError(f"invalid sheet span {value!r}: need 1 <= N <= M")
    return str(start) if start == end else f"{start}-{end}"