migrate all everything to the new stuff

This commit is contained in:
lda
2026-05-21 06:16:58 +07:00 Verified
parent 0a079ec5f1
commit 274bf34edf
16 changed files with 532 additions and 341 deletions
+6
View File
@@ -10,9 +10,12 @@ from .dsl import (
expr,
graph_path,
input,
input_from,
input_path,
input_value,
merge_maps,
not_,
output_to,
state,
state_path,
)
@@ -111,7 +114,9 @@ __all__ = [
"first_item_or_none",
"graph_path",
"input",
"input_from",
"input_path",
"input_value",
"is_empty",
"last_item",
"last_item_or_none",
@@ -124,6 +129,7 @@ __all__ = [
"node",
"not_",
"outcome",
"output_to",
"reducer",
"state",
"state_field",
+13 -1
View File
@@ -9,7 +9,16 @@ from .conditions import (
not_,
state,
)
from .mapping import PathArg, bind_fields, bind_state, merge_maps, normalize_path
from .mapping import (
PathArg,
bind_fields,
bind_state,
input_from,
input_value,
merge_maps,
normalize_path,
output_to,
)
from .paths import GraphPath, context_path, graph_path, input_path, state_path
__all__ = [
@@ -26,10 +35,13 @@ __all__ = [
"expr",
"graph_path",
"input",
"input_from",
"input_path",
"input_value",
"merge_maps",
"normalize_path",
"not_",
"output_to",
"state",
"state_path",
]
+33 -2
View File
@@ -1,10 +1,17 @@
from __future__ import annotations
from collections.abc import Mapping
from typing import TypeAlias
from typing import Any, TypeAlias
from wf_core.models.steps import InputPathBinding, InputValueBinding, OutputBinding
from .path_inputs import (
PathInput,
coerce_graph_path,
coerce_local_path,
coerce_state_path,
)
from .paths import GraphPath
from .path_inputs import PathInput, coerce_graph_path, coerce_state_path
PathArg: TypeAlias = PathInput | GraphPath
@@ -41,6 +48,30 @@ def bind_state(**mapping: PathArg) -> dict[str, str]:
}
def input_from(path: PathArg, target: PathInput) -> InputPathBinding:
"""Bind a workflow graph path into a node-local input path."""
return InputPathBinding(
target=coerce_local_path(target),
path=coerce_graph_path(path.path if isinstance(path, GraphPath) else path),
)
def input_value(target: PathInput, value: Any) -> InputValueBinding:
"""Bind a literal value into a node-local input path."""
return InputValueBinding(target=coerce_local_path(target), value=value)
def output_to(source: PathInput, target: PathArg) -> OutputBinding:
"""Bind a node-local output path back into workflow state."""
return OutputBinding(
source=coerce_local_path(source),
target=coerce_state_path(
target.path if isinstance(target, GraphPath) else target,
allow_legacy_root=True,
),
)
def merge_maps(*maps: Mapping[str, str]) -> dict[str, str]:
merged: dict[str, str] = {}
for mapping in maps: