use workflow_permanent_id for workflow execution api (#366)
This commit is contained in:
@@ -481,8 +481,9 @@ async def get_task_actions(
|
|||||||
)
|
)
|
||||||
async def execute_workflow(
|
async def execute_workflow(
|
||||||
background_tasks: BackgroundTasks,
|
background_tasks: BackgroundTasks,
|
||||||
workflow_id: str,
|
workflow_id: str, # this is the workflow_permanent_id
|
||||||
workflow_request: WorkflowRequestBody,
|
workflow_request: WorkflowRequestBody,
|
||||||
|
version: int | None = None,
|
||||||
current_org: Organization = Depends(org_auth_service.get_current_org),
|
current_org: Organization = Depends(org_auth_service.get_current_org),
|
||||||
x_api_key: Annotated[str | None, Header()] = None,
|
x_api_key: Annotated[str | None, Header()] = None,
|
||||||
x_max_steps_override: Annotated[int | None, Header()] = None,
|
x_max_steps_override: Annotated[int | None, Header()] = None,
|
||||||
@@ -493,8 +494,9 @@ async def execute_workflow(
|
|||||||
workflow_run = await app.WORKFLOW_SERVICE.setup_workflow_run(
|
workflow_run = await app.WORKFLOW_SERVICE.setup_workflow_run(
|
||||||
request_id=request_id,
|
request_id=request_id,
|
||||||
workflow_request=workflow_request,
|
workflow_request=workflow_request,
|
||||||
workflow_id=workflow_id,
|
workflow_permanent_id=workflow_id,
|
||||||
organization_id=current_org.organization_id,
|
organization_id=current_org.organization_id,
|
||||||
|
version=version,
|
||||||
max_steps_override=x_max_steps_override,
|
max_steps_override=x_max_steps_override,
|
||||||
)
|
)
|
||||||
if x_max_steps_override:
|
if x_max_steps_override:
|
||||||
@@ -502,7 +504,7 @@ async def execute_workflow(
|
|||||||
await AsyncExecutorFactory.get_executor().execute_workflow(
|
await AsyncExecutorFactory.get_executor().execute_workflow(
|
||||||
background_tasks=background_tasks,
|
background_tasks=background_tasks,
|
||||||
organization_id=current_org.organization_id,
|
organization_id=current_org.organization_id,
|
||||||
workflow_id=workflow_id,
|
workflow_id=workflow_run.workflow_id,
|
||||||
workflow_run_id=workflow_run.workflow_run_id,
|
workflow_run_id=workflow_run.workflow_run_id,
|
||||||
max_steps_override=x_max_steps_override,
|
max_steps_override=x_max_steps_override,
|
||||||
api_key=x_api_key,
|
api_key=x_api_key,
|
||||||
|
|||||||
@@ -68,8 +68,9 @@ class WorkflowService:
|
|||||||
self,
|
self,
|
||||||
request_id: str | None,
|
request_id: str | None,
|
||||||
workflow_request: WorkflowRequestBody,
|
workflow_request: WorkflowRequestBody,
|
||||||
workflow_id: str,
|
workflow_permanent_id: str,
|
||||||
organization_id: str,
|
organization_id: str,
|
||||||
|
version: int | None = None,
|
||||||
max_steps_override: int | None = None,
|
max_steps_override: int | None = None,
|
||||||
) -> WorkflowRun:
|
) -> WorkflowRun:
|
||||||
"""
|
"""
|
||||||
@@ -83,13 +84,15 @@ class WorkflowService:
|
|||||||
:return: The created workflow run.
|
:return: The created workflow run.
|
||||||
"""
|
"""
|
||||||
# Validate the workflow and the organization
|
# 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:
|
if workflow is None:
|
||||||
LOG.error(f"Workflow {workflow_id} not found")
|
LOG.error(f"Workflow {workflow_permanent_id} not found", workflow_version=version)
|
||||||
raise WorkflowNotFound(workflow_id=workflow_id)
|
raise WorkflowNotFound(workflow_permanent_id=workflow_permanent_id, version=version)
|
||||||
if workflow.organization_id != organization_id:
|
workflow_id = workflow.workflow_id
|
||||||
LOG.error(f"Workflow {workflow_id} does not belong to organization {organization_id}")
|
|
||||||
raise WorkflowOrganizationMismatch(workflow_id=workflow_id, organization_id=organization_id)
|
|
||||||
if workflow_request.proxy_location is None and workflow.proxy_location is not None:
|
if workflow_request.proxy_location is None and workflow.proxy_location is not None:
|
||||||
workflow_request.proxy_location = workflow.proxy_location
|
workflow_request.proxy_location = workflow.proxy_location
|
||||||
if workflow_request.webhook_callback_url is None and workflow.webhook_callback_url is not None:
|
if workflow_request.webhook_callback_url is None and workflow.webhook_callback_url is not None:
|
||||||
@@ -583,7 +586,7 @@ class WorkflowService:
|
|||||||
)
|
)
|
||||||
outputs = None
|
outputs = None
|
||||||
return WorkflowRunStatusResponse(
|
return WorkflowRunStatusResponse(
|
||||||
workflow_id=workflow_id,
|
workflow_id=workflow.workflow_permanent_id,
|
||||||
workflow_run_id=workflow_run_id,
|
workflow_run_id=workflow_run_id,
|
||||||
status=workflow_run.status,
|
status=workflow_run.status,
|
||||||
proxy_location=workflow_run.proxy_location,
|
proxy_location=workflow_run.proxy_location,
|
||||||
|
|||||||
Reference in New Issue
Block a user