chore: snapshot workflow migration progress
This commit is contained in:
@@ -25,7 +25,7 @@ from collections import deque
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Literal
|
||||
|
||||
from app.domains.rendering.workflow_schema import WorkflowConfig, WorkflowNode
|
||||
from app.domains.rendering.workflow_schema import WorkflowConfig, WorkflowEdge, WorkflowNode
|
||||
from app.core.process_steps import StepName
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -40,6 +40,17 @@ class WorkflowContext:
|
||||
execution_mode: WorkflowExecutionMode
|
||||
workflow_run_id: uuid.UUID | None = None
|
||||
ordered_nodes: list[WorkflowNode] = field(default_factory=list)
|
||||
edges: list[WorkflowEdge] = field(default_factory=list)
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class WorkflowTaskDispatchSpec:
|
||||
node_id: str
|
||||
task_name: str
|
||||
args: list[str]
|
||||
kwargs: dict
|
||||
task_id: str
|
||||
queue: str | None = None
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
@@ -48,6 +59,38 @@ class WorkflowDispatchResult:
|
||||
task_ids: list[str]
|
||||
node_task_ids: dict[str, str]
|
||||
skipped_node_ids: list[str]
|
||||
task_specs: list[WorkflowTaskDispatchSpec] = field(default_factory=list)
|
||||
|
||||
|
||||
class WorkflowTaskSubmissionError(RuntimeError):
|
||||
def __init__(self, message: str, *, submitted_task_ids: list[str] | None = None) -> None:
|
||||
super().__init__(message)
|
||||
self.submitted_task_ids = list(submitted_task_ids or [])
|
||||
|
||||
|
||||
def submit_prepared_workflow_tasks(dispatch_result: WorkflowDispatchResult) -> None:
|
||||
"""Submit pre-built Celery tasks after DB state has been committed."""
|
||||
from app.tasks.celery_app import celery_app
|
||||
|
||||
submitted_task_ids: list[str] = []
|
||||
for spec in dispatch_result.task_specs:
|
||||
task_options: dict[str, str] = {"task_id": spec.task_id}
|
||||
if spec.queue:
|
||||
task_options["queue"] = spec.queue
|
||||
try:
|
||||
celery_app.send_task(
|
||||
spec.task_name,
|
||||
args=spec.args,
|
||||
kwargs=spec.kwargs,
|
||||
**task_options,
|
||||
)
|
||||
except Exception as exc:
|
||||
raise WorkflowTaskSubmissionError(
|
||||
f"Failed to submit workflow task for node '{spec.node_id}': {exc}",
|
||||
submitted_task_ids=submitted_task_ids,
|
||||
) from exc
|
||||
submitted_task_ids.append(spec.task_id)
|
||||
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -65,7 +108,7 @@ STEP_TASK_MAP: dict[StepName, str] = {
|
||||
StepName.STL_CACHE_GENERATE: "app.tasks.step_tasks.process_step_file",
|
||||
# ── Thumbnail generation ─────────────────────────────────────────────
|
||||
StepName.BLENDER_RENDER: "app.tasks.step_tasks.render_step_thumbnail",
|
||||
StepName.THUMBNAIL_SAVE: "app.tasks.step_tasks.render_step_thumbnail",
|
||||
StepName.THUMBNAIL_SAVE: "app.tasks.step_tasks.render_graph_thumbnail",
|
||||
# ── Order line stills & turntables ──────────────────────────────────
|
||||
StepName.BLENDER_STILL: "app.domains.rendering.tasks.render_order_line_still_task",
|
||||
StepName.BLENDER_TURNTABLE: "app.domains.rendering.tasks.render_turntable_task",
|
||||
@@ -98,6 +141,7 @@ def prepare_workflow_context(
|
||||
execution_mode=execution_mode,
|
||||
workflow_run_id=workflow_run_id,
|
||||
ordered_nodes=ordered_nodes,
|
||||
edges=list(config.edges),
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user