-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add global variable support to workflows
- Loading branch information
Showing
4 changed files
with
164 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,25 @@ | ||
from typing import TYPE_CHECKING | ||
|
||
from pydantic import BaseModel | ||
|
||
if TYPE_CHECKING: | ||
from core.workflow.entities.variable_pool import ValueType | ||
|
||
|
||
class VariableSelector(BaseModel): | ||
""" | ||
Variable Selector. | ||
""" | ||
variable: str | ||
value_selector: list[str] | ||
|
||
|
||
class GlobalVariable(BaseModel): | ||
""" | ||
Global Variable. | ||
""" | ||
name: str | ||
value: str | ||
value_type: "ValueType" | ||
is_secret: bool | ||
exportable: bool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
"""add to workflows | ||
Revision ID: 5f6291109057 | ||
Revises: 4e99a8df00ff | ||
Create Date: 2024-06-14 06:30:41.326661 | ||
""" | ||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
import models as models | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = '5f6291109057' | ||
down_revision = '4e99a8df00ff' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
with op.batch_alter_table('workflows', schema=None) as batch_op: | ||
batch_op.add_column(sa.Column('global_variables', sa.Text(), nullable=True)) | ||
op.execute("UPDATE workflows SET global_variables = '{}' WHERE global_variables IS NULL") | ||
with op.batch_alter_table('workflows', schema=None) as batch_op: | ||
batch_op.alter_column('global_variables', nullable=False) | ||
|
||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
with op.batch_alter_table('workflows', schema=None) as batch_op: | ||
batch_op.drop_column('global_variables') | ||
|
||
# ### end Alembic commands ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters