use workflow_permanent_id for workflow execution api (#366)

This commit is contained in:
Kerem Yilmaz 2024-05-25 19:32:25 -07:00 committed by GitHub
parent a36b65b894
commit abca808e6c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 11 deletions

View file

@ -68,8 +68,9 @@ class WorkflowService:
self,
request_id: str | None,
workflow_request: WorkflowRequestBody,
workflow_id: str,
workflow_permanent_id: str,
organization_id: str,
version: int | None = None,
max_steps_override: int | None = None,
) -> WorkflowRun:
"""
@ -83,13 +84,15 @@ class WorkflowService:
:return: The created workflow run.
"""
# Validate the workflow and the organization
workflow = await self.get_workflow(workflow_id=workflow_id, organization_id=organization_id)
workflow = await self.get_workflow_by_permanent_id(
workflow_permanent_id=workflow_permanent_id,
organization_id=organization_id,
version=version,
)
if workflow is None:
LOG.error(f"Workflow {workflow_id} not found")
raise WorkflowNotFound(workflow_id=workflow_id)
if workflow.organization_id != organization_id:
LOG.error(f"Workflow {workflow_id} does not belong to organization {organization_id}")
raise WorkflowOrganizationMismatch(workflow_id=workflow_id, organization_id=organization_id)
LOG.error(f"Workflow {workflow_permanent_id} not found", workflow_version=version)
raise WorkflowNotFound(workflow_permanent_id=workflow_permanent_id, version=version)
workflow_id = workflow.workflow_id
if workflow_request.proxy_location is None and workflow.proxy_location is not None:
workflow_request.proxy_location = workflow.proxy_location
if workflow_request.webhook_callback_url is None and workflow.webhook_callback_url is not None:
@ -583,7 +586,7 @@ class WorkflowService:
)
outputs = None
return WorkflowRunStatusResponse(
workflow_id=workflow_id,
workflow_id=workflow.workflow_permanent_id,
workflow_run_id=workflow_run_id,
status=workflow_run.status,
proxy_location=workflow_run.proxy_location,