Repository navigation
Expand file tree
/
Copy pathworkflow_run.py
More file actions
71 lines (60 loc) · 2.77 KB
/
Copy pathworkflow_run.py
File metadata and controls
71 lines (60 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
from sqlalchemy import JSON, Boolean, ForeignKey, Index, Integer, String
from sqlalchemy.orm import Mapped, mapped_column, relationship
from backend.models.base import TimestampMixin
class WorkflowRun(TimestampMixin):
"""Persisted WorkflowProject run projection and restart input."""
__tablename__ = "workflow_runs"
workflow_id: Mapped[str] = mapped_column(String(255), nullable=False, index=True)
workflow_version_id: Mapped[str | None] = mapped_column(
String(36),
ForeignKey("workflow_versions.id", ondelete="RESTRICT"),
nullable=True,
index=True,
)
studio_workflow_version_id: Mapped[str | None] = mapped_column(
String(36),
ForeignKey("studio_workflow_versions.id", ondelete="RESTRICT"),
nullable=True,
index=True,
)
trace_id: Mapped[str] = mapped_column(String(255), nullable=False, index=True)
status: Mapped[str] = mapped_column(String(50), nullable=False)
valid: Mapped[bool] = mapped_column(Boolean, nullable=False, default=True)
package_node_id: Mapped[str | None] = mapped_column(String(255), nullable=True)
request: Mapped[dict] = mapped_column(JSON, nullable=False, default=dict)
projection: Mapped[dict] = mapped_column(JSON, nullable=False, default=dict)
next_event_sequence: Mapped[int] = mapped_column(
Integer,
nullable=False,
default=1,
server_default="1",
)
events: Mapped[list["WorkflowRunEvent"]] = relationship(
"WorkflowRunEvent",
back_populates="run",
cascade="all, delete-orphan",
order_by="WorkflowRunEvent.sequence",
)
class WorkflowRunEvent(TimestampMixin):
"""A replayable node-level event emitted by the workflow runtime."""
__tablename__ = "workflow_run_events"
__table_args__ = (
Index(
"ux_workflow_run_events_run_id_sequence",
"run_id",
"sequence",
unique=True,
),
Index("ix_workflow_run_events_event_id", "event_id", unique=True),
)
run_id: Mapped[str] = mapped_column(
String(36), ForeignKey("workflow_runs.id", ondelete="CASCADE"), nullable=False, index=True
)
workflow_id: Mapped[str] = mapped_column(String(255), nullable=False, index=True)
trace_id: Mapped[str] = mapped_column(String(255), nullable=False, index=True)
event_id: Mapped[str] = mapped_column(String(512), nullable=False)
node_id: Mapped[str] = mapped_column(String(255), nullable=False, index=True)
sequence: Mapped[int] = mapped_column(Integer, nullable=False)
event_type: Mapped[str] = mapped_column(String(50), nullable=False)
payload: Mapped[dict] = mapped_column(JSON, nullable=False, default=dict)
run: Mapped["WorkflowRun"] = relationship("WorkflowRun", back_populates="events")