fix workflow run get with workflow_permanent_id (#415)
This commit is contained in:
@@ -533,7 +533,7 @@ async def get_workflow_run(
|
|||||||
) -> WorkflowRunStatusResponse:
|
) -> WorkflowRunStatusResponse:
|
||||||
analytics.capture("skyvern-oss-agent-workflow-run-get")
|
analytics.capture("skyvern-oss-agent-workflow-run-get")
|
||||||
return await app.WORKFLOW_SERVICE.build_workflow_run_status_response(
|
return await app.WORKFLOW_SERVICE.build_workflow_run_status_response(
|
||||||
workflow_id=workflow_id,
|
workflow_permanent_id=workflow_id,
|
||||||
workflow_run_id=workflow_run_id,
|
workflow_run_id=workflow_run_id,
|
||||||
organization_id=current_org.organization_id,
|
organization_id=current_org.organization_id,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -6,13 +6,7 @@ import requests
|
|||||||
import structlog
|
import structlog
|
||||||
|
|
||||||
from skyvern import analytics
|
from skyvern import analytics
|
||||||
from skyvern.exceptions import (
|
from skyvern.exceptions import FailedToSendWebhook, MissingValueForParameter, WorkflowNotFound, WorkflowRunNotFound
|
||||||
FailedToSendWebhook,
|
|
||||||
MissingValueForParameter,
|
|
||||||
WorkflowNotFound,
|
|
||||||
WorkflowOrganizationMismatch,
|
|
||||||
WorkflowRunNotFound,
|
|
||||||
)
|
|
||||||
from skyvern.forge import app
|
from skyvern.forge import app
|
||||||
from skyvern.forge.sdk.artifact.models import ArtifactType
|
from skyvern.forge.sdk.artifact.models import ArtifactType
|
||||||
from skyvern.forge.sdk.core import skyvern_context
|
from skyvern.forge.sdk.core import skyvern_context
|
||||||
@@ -527,17 +521,14 @@ class WorkflowService:
|
|||||||
|
|
||||||
async def build_workflow_run_status_response(
|
async def build_workflow_run_status_response(
|
||||||
self,
|
self,
|
||||||
workflow_id: str,
|
workflow_permanent_id: str,
|
||||||
workflow_run_id: str,
|
workflow_run_id: str,
|
||||||
organization_id: str,
|
organization_id: str,
|
||||||
) -> WorkflowRunStatusResponse:
|
) -> WorkflowRunStatusResponse:
|
||||||
workflow = await self.get_workflow(workflow_id=workflow_id, organization_id=organization_id)
|
workflow = await self.get_workflow_by_permanent_id(workflow_permanent_id, organization_id=organization_id)
|
||||||
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")
|
||||||
raise WorkflowNotFound(workflow_id=workflow_id)
|
raise WorkflowNotFound(workflow_permanent_id=workflow_permanent_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)
|
|
||||||
|
|
||||||
workflow_run = await self.get_workflow_run(workflow_run_id=workflow_run_id)
|
workflow_run = await self.get_workflow_run(workflow_run_id=workflow_run_id)
|
||||||
workflow_run_tasks = await app.DATABASE.get_tasks_by_workflow_run_id(workflow_run_id=workflow_run_id)
|
workflow_run_tasks = await app.DATABASE.get_tasks_by_workflow_run_id(workflow_run_id=workflow_run_id)
|
||||||
@@ -574,14 +565,14 @@ class WorkflowService:
|
|||||||
output_parameter_tuples: list[
|
output_parameter_tuples: list[
|
||||||
tuple[OutputParameter, WorkflowRunOutputParameter]
|
tuple[OutputParameter, WorkflowRunOutputParameter]
|
||||||
] = await self.get_output_parameter_workflow_run_output_parameter_tuples(
|
] = await self.get_output_parameter_workflow_run_output_parameter_tuples(
|
||||||
workflow_id=workflow_id, workflow_run_id=workflow_run_id
|
workflow_id=workflow_run.workflow_id, workflow_run_id=workflow_run_id
|
||||||
)
|
)
|
||||||
if output_parameter_tuples:
|
if output_parameter_tuples:
|
||||||
outputs = {output_parameter.key: output.value for output_parameter, output in output_parameter_tuples}
|
outputs = {output_parameter.key: output.value for output_parameter, output in output_parameter_tuples}
|
||||||
else:
|
else:
|
||||||
LOG.error(
|
LOG.error(
|
||||||
"No output parameters found for workflow run",
|
"No output parameters found for workflow run",
|
||||||
workflow_id=workflow_id,
|
workflow_permanent_id=workflow_permanent_id,
|
||||||
workflow_run_id=workflow_run_id,
|
workflow_run_id=workflow_run_id,
|
||||||
)
|
)
|
||||||
outputs = None
|
outputs = None
|
||||||
@@ -621,7 +612,7 @@ class WorkflowService:
|
|||||||
await app.ARTIFACT_MANAGER.wait_for_upload_aiotasks_for_tasks(all_workflow_task_ids)
|
await app.ARTIFACT_MANAGER.wait_for_upload_aiotasks_for_tasks(all_workflow_task_ids)
|
||||||
|
|
||||||
workflow_run_status_response = await self.build_workflow_run_status_response(
|
workflow_run_status_response = await self.build_workflow_run_status_response(
|
||||||
workflow_id=workflow.workflow_id,
|
workflow_permanent_id=workflow.workflow_permanent_id,
|
||||||
workflow_run_id=workflow_run.workflow_run_id,
|
workflow_run_id=workflow_run.workflow_run_id,
|
||||||
organization_id=workflow.organization_id,
|
organization_id=workflow.organization_id,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user