mirror of
https://github.com/Skyvern-AI/skyvern.git
synced 2025-09-14 01:09:43 +00:00
implement an endpoint for running one or more labelled blocks in a workflow (#2878)
This commit is contained in:
parent
993d0eaf45
commit
dd666d7e8e
6 changed files with 204 additions and 6 deletions
|
@ -10,6 +10,7 @@ from skyvern import analytics
|
|||
from skyvern.config import settings
|
||||
from skyvern.constants import GET_DOWNLOADED_FILES_TIMEOUT, SAVE_DOWNLOADED_FILES_TIMEOUT
|
||||
from skyvern.exceptions import (
|
||||
BlockNotFound,
|
||||
BrowserSessionNotFound,
|
||||
FailedToSendWebhook,
|
||||
InvalidCredentialId,
|
||||
|
@ -252,6 +253,7 @@ class WorkflowService:
|
|||
workflow_run_id: str,
|
||||
api_key: str,
|
||||
organization: Organization,
|
||||
block_labels: list[str] | None = None,
|
||||
browser_session_id: str | None = None,
|
||||
) -> WorkflowRun:
|
||||
"""Execute a workflow."""
|
||||
|
@ -326,8 +328,32 @@ class WorkflowService:
|
|||
)
|
||||
return workflow_run
|
||||
|
||||
all_blocks = workflow.workflow_definition.blocks
|
||||
|
||||
if block_labels and len(block_labels):
|
||||
blocks: list[BlockTypeVar] = []
|
||||
all_labels = {block.label: block for block in all_blocks}
|
||||
|
||||
for label in block_labels:
|
||||
if label not in all_labels:
|
||||
raise BlockNotFound(block_label=label)
|
||||
|
||||
blocks.append(all_labels[label])
|
||||
|
||||
LOG.info(
|
||||
"Executing workflow blocks via whitelist",
|
||||
workflow_run_id=workflow_run.workflow_run_id,
|
||||
block_cnt=len(blocks),
|
||||
block_labels=block_labels,
|
||||
)
|
||||
|
||||
else:
|
||||
blocks = all_blocks
|
||||
|
||||
if not blocks:
|
||||
raise SkyvernException(f"No blocks found for the given block labels: {block_labels}")
|
||||
|
||||
# Execute workflow blocks
|
||||
blocks = workflow.workflow_definition.blocks
|
||||
blocks_cnt = len(blocks)
|
||||
block_result = None
|
||||
for block_idx, block in enumerate(blocks):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue