shu/script status pending (#3481)
This commit is contained in:
@@ -52,7 +52,7 @@ function WorkflowRunCode(props?: Props) {
|
|||||||
cacheKeyValue,
|
cacheKeyValue,
|
||||||
workflowPermanentId,
|
workflowPermanentId,
|
||||||
pollIntervalMs: !isFinalized ? 3000 : undefined,
|
pollIntervalMs: !isFinalized ? 3000 : undefined,
|
||||||
status: "draft",
|
status: "pending",
|
||||||
workflowRunId: workflowRun?.workflow_run_id,
|
workflowRunId: workflowRun?.workflow_run_id,
|
||||||
});
|
});
|
||||||
const orderedBlockLabels = getOrderedBlockLabels(workflow);
|
const orderedBlockLabels = getOrderedBlockLabels(workflow);
|
||||||
@@ -87,7 +87,7 @@ function WorkflowRunCode(props?: Props) {
|
|||||||
cacheKey,
|
cacheKey,
|
||||||
cacheKeyValue,
|
cacheKeyValue,
|
||||||
undefined,
|
undefined,
|
||||||
"draft",
|
"pending",
|
||||||
workflowRun?.workflow_run_id,
|
workflowRun?.workflow_run_id,
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1605,7 +1605,7 @@ async def generate_workflow_script_python_code(
|
|||||||
run_id: str | None = None,
|
run_id: str | None = None,
|
||||||
script_id: str | None = None,
|
script_id: str | None = None,
|
||||||
script_revision_id: str | None = None,
|
script_revision_id: str | None = None,
|
||||||
draft: bool = False,
|
pending: bool = False,
|
||||||
) -> str:
|
) -> str:
|
||||||
"""
|
"""
|
||||||
Build a LibCST Module and emit .code (PEP-8-formatted source).
|
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,
|
script_id=script_id,
|
||||||
organization_id=organization_id,
|
organization_id=organization_id,
|
||||||
block_label=block_name,
|
block_label=block_name,
|
||||||
update=draft,
|
update=pending,
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOG.error("Failed to create script block", error=str(e), exc_info=True)
|
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,
|
script_id=script_id,
|
||||||
organization_id=organization_id,
|
organization_id=organization_id,
|
||||||
block_label=settings.WORKFLOW_START_BLOCK_LABEL,
|
block_label=settings.WORKFLOW_START_BLOCK_LABEL,
|
||||||
update=draft,
|
update=pending,
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOG.error("Failed to create __start_block__", error=str(e), exc_info=True)
|
LOG.error("Failed to create __start_block__", error=str(e), exc_info=True)
|
||||||
|
|||||||
@@ -641,7 +641,7 @@ class AgentFunction:
|
|||||||
root_workflow_run_id=context.root_workflow_run_id,
|
root_workflow_run_id=context.root_workflow_run_id,
|
||||||
organization_id=context.organization_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_run=workflow_run,
|
||||||
workflow=workflow,
|
workflow=workflow,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ async def build_file_tree(
|
|||||||
script_id: str,
|
script_id: str,
|
||||||
script_version: int,
|
script_version: int,
|
||||||
script_revision_id: str,
|
script_revision_id: str,
|
||||||
draft: bool = False,
|
pending: bool = False,
|
||||||
) -> dict[str, FileNode]:
|
) -> dict[str, FileNode]:
|
||||||
"""Build a hierarchical file tree from a list of files and upload the files to s3 with the same tree structure."""
|
"""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] = {}
|
file_tree: dict[str, FileNode] = {}
|
||||||
@@ -71,7 +71,7 @@ async def build_file_tree(
|
|||||||
|
|
||||||
# Create artifact and upload to S3
|
# Create artifact and upload to S3
|
||||||
try:
|
try:
|
||||||
if draft:
|
if pending:
|
||||||
# get the script file object
|
# get the script file object
|
||||||
script_file = await app.DATABASE.get_script_file_by_path(
|
script_file = await app.DATABASE.get_script_file_by_path(
|
||||||
script_revision_id=script_revision_id,
|
script_revision_id=script_revision_id,
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ LOG = structlog.get_logger()
|
|||||||
jinja_sandbox_env = SandboxedEnvironment()
|
jinja_sandbox_env = SandboxedEnvironment()
|
||||||
|
|
||||||
|
|
||||||
async def generate_or_update_draft_workflow_script(
|
async def generate_or_update_pending_workflow_script(
|
||||||
workflow_run: WorkflowRun,
|
workflow_run: WorkflowRun,
|
||||||
workflow: Workflow,
|
workflow: Workflow,
|
||||||
) -> None:
|
) -> None:
|
||||||
@@ -44,7 +44,7 @@ async def generate_or_update_draft_workflow_script(
|
|||||||
workflow=workflow,
|
workflow=workflow,
|
||||||
script=script,
|
script=script,
|
||||||
rendered_cache_key_value=rendered_cache_key_value,
|
rendered_cache_key_value=rendered_cache_key_value,
|
||||||
draft=True,
|
pending=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -111,7 +111,7 @@ async def generate_workflow_script(
|
|||||||
workflow: Workflow,
|
workflow: Workflow,
|
||||||
script: Script,
|
script: Script,
|
||||||
rendered_cache_key_value: str,
|
rendered_cache_key_value: str,
|
||||||
draft: bool = False,
|
pending: bool = False,
|
||||||
) -> None:
|
) -> None:
|
||||||
try:
|
try:
|
||||||
LOG.info(
|
LOG.info(
|
||||||
@@ -135,7 +135,7 @@ async def generate_workflow_script(
|
|||||||
organization_id=workflow.organization_id,
|
organization_id=workflow.organization_id,
|
||||||
script_id=script.script_id,
|
script_id=script.script_id,
|
||||||
script_revision_id=script.script_revision_id,
|
script_revision_id=script.script_revision_id,
|
||||||
draft=draft,
|
pending=pending,
|
||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.error("Failed to generate workflow script source", exc_info=True)
|
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_id=script.script_id,
|
||||||
script_version=script.version,
|
script_version=script.version,
|
||||||
script_revision_id=script.script_revision_id,
|
script_revision_id=script.script_revision_id,
|
||||||
draft=draft,
|
pending=pending,
|
||||||
)
|
)
|
||||||
|
|
||||||
# check if an existing drfat workflow script exists for this workflow run
|
# 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
|
status = ScriptStatus.published
|
||||||
if draft:
|
if pending:
|
||||||
status = ScriptStatus.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,
|
organization_id=workflow.organization_id,
|
||||||
workflow_permanent_id=workflow.workflow_permanent_id,
|
workflow_permanent_id=workflow.workflow_permanent_id,
|
||||||
workflow_run_id=workflow_run.workflow_run_id,
|
workflow_run_id=workflow_run.workflow_run_id,
|
||||||
statuses=[status],
|
statuses=[status],
|
||||||
)
|
)
|
||||||
if not existing_draft_workflow_script:
|
if not existing_pending_workflow_script:
|
||||||
# Record the workflow->script mapping for cache lookup
|
# Record the workflow->script mapping for cache lookup
|
||||||
await app.DATABASE.create_workflow_script(
|
await app.DATABASE.create_workflow_script(
|
||||||
organization_id=workflow.organization_id,
|
organization_id=workflow.organization_id,
|
||||||
|
|||||||
Reference in New Issue
Block a user