shu/script status pending (#3481)

This commit is contained in:
Shuchang Zheng
2025-09-19 09:00:48 -07:00
committed by GitHub
parent c5280782b0
commit 5a0a228b56
5 changed files with 17 additions and 17 deletions

View File

@@ -52,7 +52,7 @@ function WorkflowRunCode(props?: Props) {
cacheKeyValue,
workflowPermanentId,
pollIntervalMs: !isFinalized ? 3000 : undefined,
status: "draft",
status: "pending",
workflowRunId: workflowRun?.workflow_run_id,
});
const orderedBlockLabels = getOrderedBlockLabels(workflow);
@@ -87,7 +87,7 @@ function WorkflowRunCode(props?: Props) {
cacheKey,
cacheKeyValue,
undefined,
"draft",
"pending",
workflowRun?.workflow_run_id,
],
});

View File

@@ -1605,7 +1605,7 @@ async def generate_workflow_script_python_code(
run_id: str | None = None,
script_id: str | None = None,
script_revision_id: str | None = None,
draft: bool = False,
pending: bool = False,
) -> str:
"""
Build a LibCST Module and emit .code (PEP-8-formatted source).
@@ -1685,7 +1685,7 @@ async def generate_workflow_script_python_code(
script_id=script_id,
organization_id=organization_id,
block_label=block_name,
update=draft,
update=pending,
)
except Exception as e:
LOG.error("Failed to create script block", error=str(e), exc_info=True)
@@ -1800,7 +1800,7 @@ async def generate_workflow_script_python_code(
script_id=script_id,
organization_id=organization_id,
block_label=settings.WORKFLOW_START_BLOCK_LABEL,
update=draft,
update=pending,
)
except Exception as e:
LOG.error("Failed to create __start_block__", error=str(e), exc_info=True)

View File

@@ -641,7 +641,7 @@ class AgentFunction:
root_workflow_run_id=context.root_workflow_run_id,
organization_id=context.organization_id,
)
await workflow_script_service.generate_or_update_draft_workflow_script(
await workflow_script_service.generate_or_update_pending_workflow_script(
workflow_run=workflow_run,
workflow=workflow,
)

View File

@@ -58,7 +58,7 @@ async def build_file_tree(
script_id: str,
script_version: int,
script_revision_id: str,
draft: bool = False,
pending: bool = False,
) -> dict[str, FileNode]:
"""Build a hierarchical file tree from a list of files and upload the files to s3 with the same tree structure."""
file_tree: dict[str, FileNode] = {}
@@ -71,7 +71,7 @@ async def build_file_tree(
# Create artifact and upload to S3
try:
if draft:
if pending:
# get the script file object
script_file = await app.DATABASE.get_script_file_by_path(
script_revision_id=script_revision_id,

View File

@@ -15,7 +15,7 @@ LOG = structlog.get_logger()
jinja_sandbox_env = SandboxedEnvironment()
async def generate_or_update_draft_workflow_script(
async def generate_or_update_pending_workflow_script(
workflow_run: WorkflowRun,
workflow: Workflow,
) -> None:
@@ -44,7 +44,7 @@ async def generate_or_update_draft_workflow_script(
workflow=workflow,
script=script,
rendered_cache_key_value=rendered_cache_key_value,
draft=True,
pending=True,
)
@@ -111,7 +111,7 @@ async def generate_workflow_script(
workflow: Workflow,
script: Script,
rendered_cache_key_value: str,
draft: bool = False,
pending: bool = False,
) -> None:
try:
LOG.info(
@@ -135,7 +135,7 @@ async def generate_workflow_script(
organization_id=workflow.organization_id,
script_id=script.script_id,
script_revision_id=script.script_revision_id,
draft=draft,
pending=pending,
)
except Exception:
LOG.error("Failed to generate workflow script source", exc_info=True)
@@ -160,21 +160,21 @@ async def generate_workflow_script(
script_id=script.script_id,
script_version=script.version,
script_revision_id=script.script_revision_id,
draft=draft,
pending=pending,
)
# check if an existing drfat workflow script exists for this workflow run
existing_draft_workflow_script = None
existing_pending_workflow_script = None
status = ScriptStatus.published
if draft:
if pending:
status = ScriptStatus.pending
existing_draft_workflow_script = await app.DATABASE.get_workflow_script(
existing_pending_workflow_script = await app.DATABASE.get_workflow_script(
organization_id=workflow.organization_id,
workflow_permanent_id=workflow.workflow_permanent_id,
workflow_run_id=workflow_run.workflow_run_id,
statuses=[status],
)
if not existing_draft_workflow_script:
if not existing_pending_workflow_script:
# Record the workflow->script mapping for cache lookup
await app.DATABASE.create_workflow_script(
organization_id=workflow.organization_id,