feat: expose input bindings over rpc
This commit is contained in:
@@ -43,6 +43,7 @@ from .models import (
|
||||
SetDraftNameParams,
|
||||
SetDraftRouteParams,
|
||||
SetDraftStartParams,
|
||||
SetStepInputBindingsParams,
|
||||
SetStepInputMapParams,
|
||||
SetStepOutputMapParams,
|
||||
SetWorkflowOutputMapParams,
|
||||
@@ -93,6 +94,7 @@ __all__ = [
|
||||
"SetDraftNameParams",
|
||||
"SetDraftRouteParams",
|
||||
"SetDraftStartParams",
|
||||
"SetStepInputBindingsParams",
|
||||
"SetStepInputMapParams",
|
||||
"SetStepOutputMapParams",
|
||||
"SetWorkflowOutputMapParams",
|
||||
|
||||
@@ -5,6 +5,7 @@ from typing import Any, Literal
|
||||
|
||||
from wf_api.surface import RouteSource
|
||||
from wf_artifacts.drafts.models import DraftStep
|
||||
from wf_core.models.steps import InputBinding
|
||||
|
||||
from .base import RpcCaller
|
||||
|
||||
@@ -182,6 +183,24 @@ class RpcDraftClientMixin:
|
||||
},
|
||||
)
|
||||
|
||||
async def set_step_input_bindings(
|
||||
self: RpcCaller,
|
||||
*,
|
||||
workspace_id: str,
|
||||
revision: int,
|
||||
step_id: str,
|
||||
bindings: Sequence[InputBinding],
|
||||
) -> dict[str, Any]:
|
||||
return await self._call(
|
||||
"workflow.draft_workspaces.set_step_input_bindings",
|
||||
{
|
||||
"workspace_id": workspace_id,
|
||||
"revision": revision,
|
||||
"step_id": step_id,
|
||||
"bindings": [binding.model_dump(mode="json") for binding in bindings],
|
||||
},
|
||||
)
|
||||
|
||||
async def set_step_output_map(
|
||||
self: RpcCaller,
|
||||
*,
|
||||
|
||||
@@ -31,6 +31,7 @@ from ..models import (
|
||||
SetDraftNameParams,
|
||||
SetDraftRouteParams,
|
||||
SetDraftStartParams,
|
||||
SetStepInputBindingsParams,
|
||||
SetStepInputMapParams,
|
||||
SetStepOutputMapParams,
|
||||
SetWorkflowOutputMapParams,
|
||||
@@ -226,6 +227,23 @@ def register_methods(
|
||||
except (ValueError, KeyError, LookupError, FileNotFoundError) as exc:
|
||||
raise_workflow_rpc_error(exc)
|
||||
|
||||
@entrypoint.method(
|
||||
name="workflow.draft_workspaces.set_step_input_bindings",
|
||||
errors=[WorkflowRpcError],
|
||||
)
|
||||
async def workflow_draft_workspaces_set_step_input_bindings(
|
||||
params: SetStepInputBindingsParams = RpcParams(),
|
||||
) -> dict[str, Any]:
|
||||
try:
|
||||
return await server.api.set_step_input_bindings(
|
||||
workspace_id=params.workspace_id,
|
||||
revision=params.revision,
|
||||
step_id=params.step_id,
|
||||
bindings=params.bindings,
|
||||
)
|
||||
except (ValueError, KeyError, LookupError, FileNotFoundError) as exc:
|
||||
raise_workflow_rpc_error(exc)
|
||||
|
||||
@entrypoint.method(
|
||||
name="workflow.draft_workspaces.set_step_output_map",
|
||||
errors=[WorkflowRpcError],
|
||||
|
||||
@@ -6,6 +6,7 @@ from pydantic import BaseModel, ConfigDict, Field, model_validator
|
||||
|
||||
from wf_api.models import TraceRange
|
||||
from wf_artifacts.drafts.models import DraftStep
|
||||
from wf_core.models.steps import InputBinding
|
||||
|
||||
|
||||
class RpcParamsModel(BaseModel):
|
||||
@@ -208,6 +209,13 @@ class SetStepInputMapParams(RpcParamsModel):
|
||||
merge: bool = False
|
||||
|
||||
|
||||
class SetStepInputBindingsParams(RpcParamsModel):
|
||||
workspace_id: str = Field(min_length=1)
|
||||
revision: int = Field(ge=1)
|
||||
step_id: str = Field(min_length=1)
|
||||
bindings: list[InputBinding]
|
||||
|
||||
|
||||
class SetStepOutputMapParams(RpcParamsModel):
|
||||
workspace_id: str = Field(min_length=1)
|
||||
revision: int = Field(ge=1)
|
||||
|
||||
Reference in New Issue
Block a user