docs: complete run step budget slice
This commit is contained in:
@@ -5,8 +5,8 @@ from typing import Any
|
||||
|
||||
from wf_core.errors import WorkflowExecutionError
|
||||
from wf_core.models.workflow import Workflow
|
||||
from wf_core.run_limits import RunLimits
|
||||
from wf_core.run_state import ROOT_SCOPE_ID, RunState, RunStatus
|
||||
from wf_core.runtime.limits import RunLimits
|
||||
from wf_core.runtime.ops.flow import finalize_run
|
||||
from wf_core.runtime.ops.merges import ReducerDefinition
|
||||
from wf_core.runtime.ops.nodes import AsyncNodeHandler, NodeHandler
|
||||
|
||||
@@ -10,7 +10,6 @@ checkpoints; the counter is persisted inside the existing stopped-run envelope.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from wf_core.errors import WorkflowStepLimitExceeded
|
||||
@@ -19,19 +18,6 @@ if TYPE_CHECKING:
|
||||
from wf_core.run_state import ExecutionFrame, RunState
|
||||
|
||||
|
||||
@dataclass(frozen=True, slots=True)
|
||||
class RunLimits:
|
||||
"""Immutable step budget captured when a run is created."""
|
||||
|
||||
max_steps: int = 10_000
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
if isinstance(self.max_steps, bool) or not isinstance(self.max_steps, int):
|
||||
raise TypeError("max_steps must be an integer")
|
||||
if self.max_steps < 1:
|
||||
raise ValueError("max_steps must be positive")
|
||||
|
||||
|
||||
def admit_step_attempt(run: RunState, frame: ExecutionFrame, node_id: str) -> int:
|
||||
"""Admit one step attempt for ``frame`` about to dispatch ``node_id``.
|
||||
|
||||
@@ -50,4 +36,4 @@ def admit_step_attempt(run: RunState, frame: ExecutionFrame, node_id: str) -> in
|
||||
|
||||
def remaining_step_attempts(run: RunState) -> int:
|
||||
"""Return the unspent budget, floored at zero (never negative)."""
|
||||
return max(run.limits.max_steps - run.steps_executed, 0)
|
||||
return run.steps_remaining
|
||||
|
||||
@@ -4,6 +4,7 @@ from copy import deepcopy
|
||||
|
||||
from wf_core.models.workflow import Workflow
|
||||
from wf_core.paths import set_nested_value
|
||||
from wf_core.run_limits import RunLimits
|
||||
from wf_core.run_state import (
|
||||
ROOT_FRAME_ID,
|
||||
ROOT_LINEAGE_ID,
|
||||
@@ -15,7 +16,6 @@ from wf_core.run_state import (
|
||||
RunStatus,
|
||||
RuntimeScope,
|
||||
)
|
||||
from wf_core.runtime.limits import RunLimits
|
||||
from wf_core.runtime.scheduler import add_frame
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user