From 8155053788eb87a7f4cd57c3f924391b244c2a9e Mon Sep 17 00:00:00 2001 From: Shuchang Zheng Date: Fri, 6 Dec 2024 00:19:48 +0000 Subject: [PATCH 1/4] =?UTF-8?q?=F0=9F=94=84=20synced=20local=20'skyvern/'?= =?UTF-8?q?=20with=20remote=20'skyvern/'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit > [!IMPORTANT] > Add `WorkflowRunBlockModel` to manage workflow run blocks in `models.py`. > > - **Models**: > - Add `WorkflowRunBlockModel` to `models.py` for managing workflow run blocks. > - Includes fields: `workflow_run_block_id`, `organization_id`, `workflow_run_id`, `block_type`, `status`, `created_at`, `modified_at`. > > This description was created by [Ellipsis](https://www.ellipsis.dev?ref=Skyvern-AI%2Fskyvern-cloud&utm_source=github&utm_medium=referral) for 73494f8bdd823778774aad7cdc4e4f9c6aca0a03. It will automatically update as commits are pushed. --- skyvern/forge/sdk/db/models.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/skyvern/forge/sdk/db/models.py b/skyvern/forge/sdk/db/models.py index 1c1d3b68fa..d99d0c1956 100644 --- a/skyvern/forge/sdk/db/models.py +++ b/skyvern/forge/sdk/db/models.py @@ -473,3 +473,24 @@ class ActionModel(Base): created_at = Column(DateTime, default=datetime.datetime.utcnow, nullable=False) modified_at = Column(DateTime, default=datetime.datetime.utcnow, onupdate=datetime.datetime.utcnow, nullable=False) + + +class WorkflowRunBlockModel(Base): + __tablename__ = "workflow_run_blocks" + __table_args__ = (Index("wfrb_org_wfr_index", "organization_id", "workflow_run_id"),) + + workflow_run_block_id = Column(String, primary_key=True) + workflow_run_id = Column(String, ForeignKey("workflow_runs.workflow_run_id"), nullable=False) + parent_workflow_run_block_id = Column( + String, ForeignKey("workflow_run_blocks.workflow_run_block_id"), nullable=True + ) + organization_id = Column(String, ForeignKey("organizations.organization_id"), nullable=True) + task_id = Column(String, ForeignKey("tasks.task_id"), nullable=True) + label = Column(String, nullable=False) + block_type = Column(String, nullable=False) + status = Column(String, nullable=False) + output = Column(JSON, nullable=True) + continue_on_failure = Column(Boolean, nullable=False, default=False) + + created_at = Column(DateTime, default=datetime.datetime.utcnow, nullable=False) + modified_at = Column(DateTime, default=datetime.datetime.utcnow, onupdate=datetime.datetime.utcnow, nullable=False) From f781e15691f5fe2923ae9af17f126a2c0a275613 Mon Sep 17 00:00:00 2001 From: Shuchang Zheng Date: Thu, 5 Dec 2024 16:48:53 -0800 Subject: [PATCH 2/4] introduce WorkflowRunBlockModel --- ...1e473eaf1_introduce_workflow_run_blocks.py | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 alembic/versions/2024_12_06_0048-7581e473eaf1_introduce_workflow_run_blocks.py diff --git a/alembic/versions/2024_12_06_0048-7581e473eaf1_introduce_workflow_run_blocks.py b/alembic/versions/2024_12_06_0048-7581e473eaf1_introduce_workflow_run_blocks.py new file mode 100644 index 0000000000..b66a1e9c84 --- /dev/null +++ b/alembic/versions/2024_12_06_0048-7581e473eaf1_introduce_workflow_run_blocks.py @@ -0,0 +1,64 @@ +"""Introduce workflow_run_blocks + +Revision ID: 7581e473eaf1 +Revises: db41106b9f1a +Create Date: 2024-12-06 00:48:39.821275+00:00 + +""" + +from typing import Sequence, Union + +import sqlalchemy as sa + +from alembic import op + +# revision identifiers, used by Alembic. +revision: str = "7581e473eaf1" +down_revision: Union[str, None] = "db41106b9f1a" +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.create_table( + "workflow_run_blocks", + sa.Column("workflow_run_block_id", sa.String(), nullable=False), + sa.Column("workflow_run_id", sa.String(), nullable=False), + sa.Column("parent_workflow_run_block_id", sa.String(), nullable=True), + sa.Column("organization_id", sa.String(), nullable=True), + sa.Column("task_id", sa.String(), nullable=True), + sa.Column("label", sa.String(), nullable=False), + sa.Column("block_type", sa.String(), nullable=False), + sa.Column("status", sa.String(), nullable=False), + sa.Column("output", sa.JSON(), nullable=True), + sa.Column("continue_on_failure", sa.Boolean(), nullable=False), + sa.Column("created_at", sa.DateTime(), nullable=False), + sa.Column("modified_at", sa.DateTime(), nullable=False), + sa.ForeignKeyConstraint( + ["organization_id"], + ["organizations.organization_id"], + ), + sa.ForeignKeyConstraint( + ["parent_workflow_run_block_id"], + ["workflow_run_blocks.workflow_run_block_id"], + ), + sa.ForeignKeyConstraint( + ["task_id"], + ["tasks.task_id"], + ), + sa.ForeignKeyConstraint( + ["workflow_run_id"], + ["workflow_runs.workflow_run_id"], + ), + sa.PrimaryKeyConstraint("workflow_run_block_id"), + ) + op.create_index("wfrb_org_wfr_index", "workflow_run_blocks", ["organization_id", "workflow_run_id"], unique=False) + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.drop_index("wfrb_org_wfr_index", table_name="workflow_run_blocks") + op.drop_table("workflow_run_blocks") + # ### end Alembic commands ### From 41371b481674ae72f1bcf10c6c67e68c9f4f21c3 Mon Sep 17 00:00:00 2001 From: Shuchang Zheng Date: Thu, 5 Dec 2024 16:51:48 -0800 Subject: [PATCH 3/4] generate_workflow_run_block_id --- skyvern/forge/sdk/db/id.py | 6 ++++++ skyvern/forge/sdk/db/models.py | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/skyvern/forge/sdk/db/id.py b/skyvern/forge/sdk/db/id.py index 36efab2a1b..da992cf538 100644 --- a/skyvern/forge/sdk/db/id.py +++ b/skyvern/forge/sdk/db/id.py @@ -36,6 +36,7 @@ WORKFLOW_PREFIX = "w" WORKFLOW_PERMANENT_ID_PREFIX = "wpid" WORKFLOW_RUN_PREFIX = "wr" +WORKFLOW_RUN_BLOCK_PREFIX = "wrb" WORKFLOW_PARAMETER_PREFIX = "wp" AWS_SECRET_PARAMETER_PREFIX = "asp" OUTPUT_PARAMETER_PREFIX = "op" @@ -55,6 +56,11 @@ def generate_workflow_permanent_id() -> str: return f"{WORKFLOW_PERMANENT_ID_PREFIX}_{int_id}" +def generate_workflow_run_block_id() -> str: + int_id = generate_id() + return f"{WORKFLOW_RUN_BLOCK_PREFIX}_{int_id}" + + def generate_workflow_run_id() -> str: int_id = generate_id() return f"{WORKFLOW_RUN_PREFIX}_{int_id}" diff --git a/skyvern/forge/sdk/db/models.py b/skyvern/forge/sdk/db/models.py index d99d0c1956..6f9876f291 100644 --- a/skyvern/forge/sdk/db/models.py +++ b/skyvern/forge/sdk/db/models.py @@ -35,6 +35,7 @@ generate_workflow_id, generate_workflow_parameter_id, generate_workflow_permanent_id, + generate_workflow_run_block_id, generate_workflow_run_id, ) from skyvern.forge.sdk.schemas.tasks import ProxyLocation @@ -479,7 +480,7 @@ class WorkflowRunBlockModel(Base): __tablename__ = "workflow_run_blocks" __table_args__ = (Index("wfrb_org_wfr_index", "organization_id", "workflow_run_id"),) - workflow_run_block_id = Column(String, primary_key=True) + workflow_run_block_id = Column(String, primary_key=True, default=generate_workflow_run_block_id) workflow_run_id = Column(String, ForeignKey("workflow_runs.workflow_run_id"), nullable=False) parent_workflow_run_block_id = Column( String, ForeignKey("workflow_run_blocks.workflow_run_block_id"), nullable=True From 91ed43551cff14820454c7310cb0e00cb00bb4aa Mon Sep 17 00:00:00 2001 From: Shuchang Zheng Date: Thu, 5 Dec 2024 17:13:28 -0800 Subject: [PATCH 4/4] label not required --- ...06_0113-de0254717601_introduce_workflow_run_blocks.py} | 8 ++++---- skyvern/forge/sdk/db/models.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) rename alembic/versions/{2024_12_06_0048-7581e473eaf1_introduce_workflow_run_blocks.py => 2024_12_06_0113-de0254717601_introduce_workflow_run_blocks.py} (93%) diff --git a/alembic/versions/2024_12_06_0048-7581e473eaf1_introduce_workflow_run_blocks.py b/alembic/versions/2024_12_06_0113-de0254717601_introduce_workflow_run_blocks.py similarity index 93% rename from alembic/versions/2024_12_06_0048-7581e473eaf1_introduce_workflow_run_blocks.py rename to alembic/versions/2024_12_06_0113-de0254717601_introduce_workflow_run_blocks.py index b66a1e9c84..ec730ec98c 100644 --- a/alembic/versions/2024_12_06_0048-7581e473eaf1_introduce_workflow_run_blocks.py +++ b/alembic/versions/2024_12_06_0113-de0254717601_introduce_workflow_run_blocks.py @@ -1,8 +1,8 @@ """Introduce workflow_run_blocks -Revision ID: 7581e473eaf1 +Revision ID: de0254717601 Revises: db41106b9f1a -Create Date: 2024-12-06 00:48:39.821275+00:00 +Create Date: 2024-12-06 01:13:07.932965+00:00 """ @@ -13,7 +13,7 @@ from alembic import op # revision identifiers, used by Alembic. -revision: str = "7581e473eaf1" +revision: str = "de0254717601" down_revision: Union[str, None] = "db41106b9f1a" branch_labels: Union[str, Sequence[str], None] = None depends_on: Union[str, Sequence[str], None] = None @@ -28,7 +28,7 @@ def upgrade() -> None: sa.Column("parent_workflow_run_block_id", sa.String(), nullable=True), sa.Column("organization_id", sa.String(), nullable=True), sa.Column("task_id", sa.String(), nullable=True), - sa.Column("label", sa.String(), nullable=False), + sa.Column("label", sa.String(), nullable=True), sa.Column("block_type", sa.String(), nullable=False), sa.Column("status", sa.String(), nullable=False), sa.Column("output", sa.JSON(), nullable=True), diff --git a/skyvern/forge/sdk/db/models.py b/skyvern/forge/sdk/db/models.py index 6f9876f291..6c61db9550 100644 --- a/skyvern/forge/sdk/db/models.py +++ b/skyvern/forge/sdk/db/models.py @@ -487,7 +487,7 @@ class WorkflowRunBlockModel(Base): ) organization_id = Column(String, ForeignKey("organizations.organization_id"), nullable=True) task_id = Column(String, ForeignKey("tasks.task_id"), nullable=True) - label = Column(String, nullable=False) + label = Column(String, nullable=True) block_type = Column(String, nullable=False) status = Column(String, nullable=False) output = Column(JSON, nullable=True)