type: annotate context analysis and workflow example

This commit is contained in:
lda
2026-08-29 18:13:02 +07:00 Verified
parent 9ab6486ed8
commit 3de29104ee
2 changed files with 6 additions and 3 deletions
+2 -1
View File
@@ -3,6 +3,7 @@ from __future__ import annotations
from pathlib import Path from pathlib import Path
from typing import Any from typing import Any
from wf_api.models import RunResult
from wf_artifacts import ( from wf_artifacts import (
FileDraftWorkspaceStore, FileDraftWorkspaceStore,
FileRunStore, FileRunStore,
@@ -198,7 +199,7 @@ def build_echo_draft() -> dict[str, Any]:
} }
async def create_and_run_echo_deployment(root: Path, *, text: str) -> dict[str, Any]: async def create_and_run_echo_deployment(root: Path, *, text: str) -> RunResult:
"""Create an artifact/deployment from the draft and run it once.""" """Create an artifact/deployment from the draft and run it once."""
service = await prepare_demo_service(root) service = await prepare_demo_service(root)
handlers = WorkflowSurfaceHandlers(service) handlers = WorkflowSurfaceHandlers(service)
+4 -2
View File
@@ -2,10 +2,12 @@ from __future__ import annotations
from wf_core import END, Edge, ForeachNode, NodeUse, SchemaRef, StateSchema, Workflow from wf_core import END, Edge, ForeachNode, NodeUse, SchemaRef, StateSchema, Workflow
from wf_core.analysis.context_scopes import ( from wf_core.analysis.context_scopes import (
ContextFieldAvailability,
context_analysis_warnings, context_analysis_warnings,
context_fields_by_node, context_fields_by_node,
) )
from wf_core.context_contracts import STANDARD_CONTEXT_FIELDS, foreach_context_fields from wf_core.context_contracts import STANDARD_CONTEXT_FIELDS, foreach_context_fields
from wf_core.models.steps import Step
from wf_core.run_state import ExecutionFrame from wf_core.run_state import ExecutionFrame
from wf_core.runtime.ops.frames import frame_context_values from wf_core.runtime.ops.frames import frame_context_values
@@ -36,7 +38,7 @@ def _foreach(
def _workflow( def _workflow(
*, *,
start: str, start: str,
nodes: list[object], nodes: list[Step],
edges: list[dict[str, str]], edges: list[dict[str, str]],
state_schema: dict[str, object] | None = None, state_schema: dict[str, object] | None = None,
) -> Workflow: ) -> Workflow:
@@ -57,7 +59,7 @@ def _workflow(
) )
def _field_map(workflow: Workflow, node_id: str) -> dict[str, object]: def _field_map(workflow: Workflow, node_id: str) -> dict[str, ContextFieldAvailability]:
return { return {
field.contract.name: field field.contract.name: field
for field in context_fields_by_node(workflow)[node_id] for field in context_fields_by_node(workflow)[node_id]