capabilityref: less string matching more model
This commit is contained in:
@@ -3,6 +3,7 @@ from __future__ import annotations
|
||||
from collections.abc import Mapping
|
||||
|
||||
from wf_core import ReducerRef, Workflow
|
||||
from wf_platform import CapabilityRef
|
||||
|
||||
from .models import ArtifactKind, JsonObject, RequiredCapability, WorkflowArtifact
|
||||
from .references import normalize_plan_node_refs
|
||||
@@ -101,14 +102,13 @@ def _required_reducers_from_plan(plan: JsonObject) -> dict[str, RequiredCapabili
|
||||
reducer = ReducerRef.model_validate(reducer_payload)
|
||||
except ValueError:
|
||||
continue
|
||||
if "." not in reducer.name:
|
||||
try:
|
||||
reducer_ref = CapabilityRef.parse(reducer.name)
|
||||
except ValueError:
|
||||
continue
|
||||
if "." not in reducer.name:
|
||||
continue
|
||||
logical_source, _, capability_name = reducer.name.rpartition(".")
|
||||
requirements[reducer.name] = RequiredCapability(
|
||||
logical_source=logical_source,
|
||||
capability_name=capability_name,
|
||||
logical_source=str(reducer_ref.source),
|
||||
capability_name=reducer_ref.name,
|
||||
kind="reducer",
|
||||
)
|
||||
return requirements
|
||||
|
||||
@@ -3,6 +3,8 @@ from __future__ import annotations
|
||||
from collections.abc import Mapping
|
||||
from copy import deepcopy
|
||||
|
||||
from wf_platform import CapabilityRef, SourceRef
|
||||
|
||||
from .models import JsonObject, RequiredCapability
|
||||
|
||||
|
||||
@@ -68,6 +70,8 @@ def logical_ref_for_concrete_ref(
|
||||
capability_name = concrete_ref[len(prefix) :]
|
||||
if not capability_name:
|
||||
continue
|
||||
logical_ref = f"{logical_source}.{capability_name}"
|
||||
logical_ref = str(
|
||||
CapabilityRef(source=SourceRef.parse(logical_source), name=capability_name)
|
||||
)
|
||||
return logical_ref, logical_source, capability_name, concrete_source
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user