migrate all everything to the new stuff
This commit is contained in:
@@ -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",
|
||||
]
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user