Debugger Continuity (BE) (#3314)
This commit is contained in:
@@ -1,9 +1,14 @@
|
||||
import typing as t
|
||||
|
||||
import structlog
|
||||
from fastapi import BackgroundTasks, Request
|
||||
|
||||
from skyvern.exceptions import OutputParameterNotFound, WorkflowNotFound
|
||||
from skyvern.forge import app
|
||||
from skyvern.forge.sdk.core import skyvern_context
|
||||
from skyvern.forge.sdk.executor.factory import AsyncExecutorFactory
|
||||
from skyvern.forge.sdk.schemas.organizations import Organization
|
||||
from skyvern.forge.sdk.workflow.models.parameter import OutputParameter
|
||||
from skyvern.forge.sdk.workflow.models.workflow import WorkflowRequestBody, WorkflowRun
|
||||
from skyvern.schemas.runs import WorkflowRunRequest
|
||||
from skyvern.services import workflow_service
|
||||
@@ -53,17 +58,47 @@ async def execute_blocks(
|
||||
workflow_run_id: str,
|
||||
workflow_permanent_id: str,
|
||||
organization: Organization,
|
||||
user_id: str,
|
||||
browser_session_id: str | None = None,
|
||||
block_outputs: dict[str, t.Any] | None = None,
|
||||
) -> None:
|
||||
"""
|
||||
Runs one or more blocks of a workflow.
|
||||
"""
|
||||
|
||||
workflow = await app.DATABASE.get_workflow_by_permanent_id(
|
||||
workflow_permanent_id=workflow_id,
|
||||
organization_id=organization.organization_id,
|
||||
)
|
||||
|
||||
if not workflow:
|
||||
raise WorkflowNotFound(workflow_permanent_id=workflow_id)
|
||||
|
||||
block_output_parameters: dict[str, OutputParameter] = {}
|
||||
|
||||
for block_label in block_labels:
|
||||
output_parameter = workflow.get_output_parameter(block_label)
|
||||
|
||||
if not output_parameter:
|
||||
raise OutputParameterNotFound(block_label=block_label, workflow_permanent_id=workflow_id)
|
||||
|
||||
block_output_parameters[block_label] = output_parameter
|
||||
|
||||
for block_label, output_parameter in block_output_parameters.items():
|
||||
await app.DATABASE.create_block_run(
|
||||
organization_id=organization.organization_id,
|
||||
user_id=user_id,
|
||||
block_label=block_label,
|
||||
output_parameter_id=output_parameter.output_parameter_id,
|
||||
workflow_run_id=workflow_run_id,
|
||||
)
|
||||
|
||||
LOG.info(
|
||||
"Executing block(s)",
|
||||
organization_id=organization.organization_id,
|
||||
workflow_run_id=workflow_run_id,
|
||||
block_labels=block_labels,
|
||||
block_outputs=block_outputs,
|
||||
)
|
||||
|
||||
await AsyncExecutorFactory.get_executor().execute_workflow(
|
||||
@@ -77,4 +112,5 @@ async def execute_blocks(
|
||||
browser_session_id=browser_session_id,
|
||||
api_key=api_key,
|
||||
block_labels=block_labels,
|
||||
block_outputs=block_outputs,
|
||||
)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import typing as t
|
||||
|
||||
import structlog
|
||||
from fastapi import BackgroundTasks, Request
|
||||
|
||||
@@ -69,6 +71,7 @@ async def run_workflow(
|
||||
request: Request | None = None,
|
||||
background_tasks: BackgroundTasks | None = None,
|
||||
block_labels: list[str] | None = None,
|
||||
block_outputs: dict[str, t.Any] | None = None,
|
||||
) -> WorkflowRun:
|
||||
workflow_run = await prepare_workflow(
|
||||
workflow_id=workflow_id,
|
||||
@@ -91,6 +94,7 @@ async def run_workflow(
|
||||
browser_session_id=workflow_request.browser_session_id,
|
||||
api_key=api_key,
|
||||
block_labels=block_labels,
|
||||
block_outputs=block_outputs,
|
||||
)
|
||||
|
||||
return workflow_run
|
||||
|
||||
Reference in New Issue
Block a user