feat: validate workflow plans without saving
This commit is contained in:
@@ -7,6 +7,7 @@ from wf_api.models import (
|
||||
DeleteArtifactResult,
|
||||
ListArtifactsResult,
|
||||
SaveArtifactResult,
|
||||
ValidateArtifactPlanResult,
|
||||
WorkflowArtifactPayload,
|
||||
)
|
||||
|
||||
@@ -67,6 +68,27 @@ class RpcArtifactClientMixin:
|
||||
),
|
||||
)
|
||||
|
||||
async def validate_artifact_plan(
|
||||
self: RpcCaller,
|
||||
*,
|
||||
plan: dict[str, Any],
|
||||
outcomes: Sequence[str],
|
||||
required_capabilities: dict[str, dict[str, Any]] | None = None,
|
||||
source_bindings: dict[str, str] | None = None,
|
||||
) -> ValidateArtifactPlanResult:
|
||||
return cast(
|
||||
ValidateArtifactPlanResult,
|
||||
await self._call(
|
||||
"workflow.artifacts.validate_plan",
|
||||
{
|
||||
"plan": plan,
|
||||
"outcomes": list(outcomes),
|
||||
"required_capabilities": required_capabilities,
|
||||
"source_bindings": source_bindings,
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
async def create_artifact_from_plan(
|
||||
self: RpcCaller,
|
||||
*,
|
||||
|
||||
@@ -10,6 +10,7 @@ from wf_api.models import (
|
||||
DeleteArtifactResult,
|
||||
ListArtifactsResult,
|
||||
SaveArtifactResult,
|
||||
ValidateArtifactPlanResult,
|
||||
WorkflowArtifactPayload,
|
||||
)
|
||||
from wf_server import WorkflowServer
|
||||
@@ -21,6 +22,7 @@ from ..models import (
|
||||
InspectArtifactParams,
|
||||
ListArtifactsParams,
|
||||
SaveArtifactParams,
|
||||
ValidateArtifactPlanParams,
|
||||
)
|
||||
from ..params import RpcParams
|
||||
|
||||
@@ -63,6 +65,22 @@ def register_methods(
|
||||
except (ValueError, KeyError, LookupError, FileNotFoundError) as exc:
|
||||
raise_workflow_rpc_error(exc)
|
||||
|
||||
@entrypoint.method(
|
||||
name="workflow.artifacts.validate_plan", errors=[WorkflowRpcError]
|
||||
)
|
||||
async def workflow_artifacts_validate_plan(
|
||||
params: ValidateArtifactPlanParams = RpcParams(),
|
||||
) -> ValidateArtifactPlanResult:
|
||||
try:
|
||||
return await server.api.validate_artifact_plan(
|
||||
plan=params.plan,
|
||||
outcomes=tuple(params.outcomes),
|
||||
required_capabilities=params.required_capabilities,
|
||||
source_bindings=params.source_bindings,
|
||||
)
|
||||
except (ValueError, KeyError, LookupError, FileNotFoundError) as exc:
|
||||
raise_workflow_rpc_error(exc)
|
||||
|
||||
@entrypoint.method(name="workflow.artifacts.list", errors=[WorkflowRpcError])
|
||||
async def workflow_artifacts_list(
|
||||
params: ListArtifactsParams = RpcParams(),
|
||||
|
||||
@@ -120,6 +120,13 @@ class SaveArtifactParams(RpcParamsModel):
|
||||
artifact: dict[str, Any]
|
||||
|
||||
|
||||
class ValidateArtifactPlanParams(RpcParamsModel):
|
||||
plan: dict[str, Any]
|
||||
outcomes: list[str]
|
||||
required_capabilities: dict[str, dict[str, Any]] | None = None
|
||||
source_bindings: dict[str, str] | None = None
|
||||
|
||||
|
||||
class SaveDeploymentParams(RpcParamsModel):
|
||||
deployment: dict[str, Any]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user