feat: add safe artifact delete
This commit is contained in:
@@ -38,3 +38,11 @@ class RpcArtifactClientMixin:
|
||||
self: RpcCaller, artifact: dict[str, Any]
|
||||
) -> dict[str, Any]:
|
||||
return await self._call("workflow.artifacts.save", {"artifact": artifact})
|
||||
|
||||
async def delete_artifact(
|
||||
self: RpcCaller, *, artifact_id: str, version: int
|
||||
) -> dict[str, Any]:
|
||||
return await self._call(
|
||||
"workflow.artifacts.delete",
|
||||
{"artifact_id": artifact_id, "version": version},
|
||||
)
|
||||
|
||||
@@ -7,7 +7,12 @@ import fastapi_jsonrpc as jsonrpc
|
||||
from wf_server import WorkflowServer
|
||||
|
||||
from ..errors import WorkflowRpcError, raise_workflow_rpc_error
|
||||
from ..models import InspectArtifactParams, ListArtifactsParams, SaveArtifactParams
|
||||
from ..models import (
|
||||
DeleteArtifactParams,
|
||||
InspectArtifactParams,
|
||||
ListArtifactsParams,
|
||||
SaveArtifactParams,
|
||||
)
|
||||
from ..params import RpcParams
|
||||
|
||||
|
||||
@@ -51,3 +56,15 @@ def register_methods(
|
||||
)
|
||||
except (ValueError, KeyError, LookupError, FileNotFoundError) as exc:
|
||||
raise_workflow_rpc_error(exc)
|
||||
|
||||
@entrypoint.method(name="workflow.artifacts.delete", errors=[WorkflowRpcError])
|
||||
async def workflow_artifacts_delete(
|
||||
params: DeleteArtifactParams = RpcParams(),
|
||||
) -> dict[str, Any]:
|
||||
try:
|
||||
return await server.api.delete_artifact(
|
||||
artifact_id=params.artifact_id,
|
||||
version=params.version,
|
||||
)
|
||||
except (ValueError, KeyError, LookupError, FileNotFoundError) as exc:
|
||||
raise_workflow_rpc_error(exc)
|
||||
|
||||
@@ -152,6 +152,11 @@ class InspectArtifactParams(RpcParamsModel):
|
||||
version: int = Field(ge=1)
|
||||
|
||||
|
||||
class DeleteArtifactParams(RpcParamsModel):
|
||||
artifact_id: str = Field(min_length=1)
|
||||
version: int = Field(ge=1)
|
||||
|
||||
|
||||
class ListDeploymentsParams(RpcParamsModel):
|
||||
pass
|
||||
|
||||
|
||||
Reference in New Issue
Block a user