add debug_session_id column to workflow_runs table, and accept from a… (#3571)
This commit is contained in:
@@ -1698,6 +1698,7 @@ class AgentDB:
|
||||
browser_address: str | None = None,
|
||||
sequential_key: str | None = None,
|
||||
run_with: str | None = None,
|
||||
debug_session_id: str | None = None,
|
||||
) -> WorkflowRun:
|
||||
try:
|
||||
async with self.Session() as session:
|
||||
@@ -1717,6 +1718,7 @@ class AgentDB:
|
||||
browser_address=browser_address,
|
||||
sequential_key=sequential_key,
|
||||
run_with=run_with,
|
||||
debug_session_id=debug_session_id,
|
||||
)
|
||||
session.add(workflow_run)
|
||||
await session.commit()
|
||||
|
||||
@@ -290,6 +290,7 @@ class WorkflowRunModel(Base):
|
||||
job_id = Column(String, nullable=True)
|
||||
sequential_key = Column(String, nullable=True)
|
||||
run_with = Column(String, nullable=True) # 'agent' or 'code'
|
||||
debug_session_id: Column = Column(String, nullable=True)
|
||||
|
||||
queued_at = Column(DateTime, nullable=True)
|
||||
started_at = Column(DateTime, nullable=True)
|
||||
|
||||
@@ -991,7 +991,7 @@ async def run_block(
|
||||
organization=organization,
|
||||
template=template,
|
||||
workflow_permanent_id=block_run_request.workflow_id,
|
||||
workflow_run_request=block_run_request,
|
||||
block_run_request=block_run_request,
|
||||
)
|
||||
|
||||
browser_session_id = block_run_request.browser_session_id
|
||||
|
||||
@@ -126,6 +126,7 @@ class WorkflowRun(BaseModel):
|
||||
workflow_permanent_id: str
|
||||
organization_id: str
|
||||
browser_session_id: str | None = None
|
||||
debug_session_id: str | None = None
|
||||
status: WorkflowRunStatus
|
||||
extra_http_headers: dict[str, str] | None = None
|
||||
proxy_location: ProxyLocation | None = None
|
||||
|
||||
@@ -148,6 +148,7 @@ class WorkflowService:
|
||||
version: int | None = None,
|
||||
max_steps_override: int | None = None,
|
||||
parent_workflow_run_id: str | None = None,
|
||||
debug_session_id: str | None = None,
|
||||
) -> WorkflowRun:
|
||||
"""
|
||||
Create a workflow run and its parameters. Validate the workflow and the organization. If there are missing
|
||||
@@ -181,6 +182,7 @@ class WorkflowService:
|
||||
organization_id=organization.organization_id,
|
||||
parent_workflow_run_id=parent_workflow_run_id,
|
||||
sequential_key=workflow.sequential_key,
|
||||
debug_session_id=debug_session_id,
|
||||
)
|
||||
LOG.info(
|
||||
f"Created workflow run {workflow_run.workflow_run_id} for workflow {workflow.workflow_id}",
|
||||
@@ -950,6 +952,7 @@ class WorkflowService:
|
||||
organization_id: str,
|
||||
parent_workflow_run_id: str | None = None,
|
||||
sequential_key: str | None = None,
|
||||
debug_session_id: str | None = None,
|
||||
) -> WorkflowRun:
|
||||
# validate the browser session id
|
||||
if workflow_request.browser_session_id:
|
||||
@@ -975,6 +978,7 @@ class WorkflowService:
|
||||
browser_address=workflow_request.browser_address,
|
||||
sequential_key=sequential_key,
|
||||
run_with=workflow_request.run_with,
|
||||
debug_session_id=debug_session_id,
|
||||
)
|
||||
|
||||
async def _update_workflow_run_status(
|
||||
|
||||
@@ -378,6 +378,10 @@ class BlockRunRequest(WorkflowRunRequest):
|
||||
# org_id/user_id, or an override supplied by the user
|
||||
description="Any active outputs of blocks in a workflow being debugged",
|
||||
)
|
||||
debug_session_id: str | None = Field(
|
||||
default=None,
|
||||
description="ID of the debug session to use for this block run",
|
||||
)
|
||||
|
||||
|
||||
class ScriptRunResponse(BaseModel):
|
||||
|
||||
@@ -10,7 +10,7 @@ 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.schemas.runs import BlockRunRequest
|
||||
from skyvern.services import workflow_service
|
||||
|
||||
LOG = structlog.get_logger()
|
||||
@@ -20,20 +20,20 @@ async def ensure_workflow_run(
|
||||
organization: Organization,
|
||||
template: bool,
|
||||
workflow_permanent_id: str,
|
||||
workflow_run_request: WorkflowRunRequest,
|
||||
block_run_request: BlockRunRequest,
|
||||
x_max_steps_override: int | None = None,
|
||||
) -> WorkflowRun:
|
||||
context = skyvern_context.ensure_context()
|
||||
|
||||
legacy_workflow_request = WorkflowRequestBody(
|
||||
data=workflow_run_request.parameters,
|
||||
proxy_location=workflow_run_request.proxy_location,
|
||||
webhook_callback_url=workflow_run_request.webhook_url,
|
||||
totp_identifier=workflow_run_request.totp_identifier,
|
||||
totp_verification_url=workflow_run_request.totp_url,
|
||||
browser_session_id=workflow_run_request.browser_session_id,
|
||||
max_screenshot_scrolls=workflow_run_request.max_screenshot_scrolls,
|
||||
extra_http_headers=workflow_run_request.extra_http_headers,
|
||||
data=block_run_request.parameters,
|
||||
proxy_location=block_run_request.proxy_location,
|
||||
webhook_callback_url=block_run_request.webhook_url,
|
||||
totp_identifier=block_run_request.totp_identifier,
|
||||
totp_verification_url=block_run_request.totp_url,
|
||||
browser_session_id=block_run_request.browser_session_id,
|
||||
max_screenshot_scrolls=block_run_request.max_screenshot_scrolls,
|
||||
extra_http_headers=block_run_request.extra_http_headers,
|
||||
)
|
||||
|
||||
workflow_run = await workflow_service.prepare_workflow(
|
||||
@@ -44,6 +44,7 @@ async def ensure_workflow_run(
|
||||
version=None,
|
||||
max_steps=x_max_steps_override,
|
||||
request_id=context.request_id,
|
||||
debug_session_id=block_run_request.debug_session_id,
|
||||
)
|
||||
|
||||
return workflow_run
|
||||
|
||||
@@ -22,6 +22,7 @@ async def prepare_workflow(
|
||||
version: int | None = None,
|
||||
max_steps: int | None = None,
|
||||
request_id: str | None = None,
|
||||
debug_session_id: str | None = None,
|
||||
) -> WorkflowRun:
|
||||
"""
|
||||
Prepare a workflow to be run.
|
||||
@@ -38,6 +39,7 @@ async def prepare_workflow(
|
||||
version=version,
|
||||
max_steps_override=max_steps,
|
||||
is_template_workflow=template,
|
||||
debug_session_id=debug_session_id,
|
||||
)
|
||||
|
||||
workflow = await app.WORKFLOW_SERVICE.get_workflow_by_permanent_id(
|
||||
|
||||
Reference in New Issue
Block a user