remove workflow_permanent_id from projects table + add use_cache and cache_project_id to workflows table (#3090)
This commit is contained in:
@@ -1313,6 +1313,8 @@ class AgentDB:
|
||||
version: int | None = None,
|
||||
is_saved_task: bool = False,
|
||||
status: WorkflowStatus = WorkflowStatus.published,
|
||||
use_cache: bool = False,
|
||||
cache_project_id: str | None = None,
|
||||
) -> Workflow:
|
||||
async with self.Session() as session:
|
||||
workflow = WorkflowModel(
|
||||
@@ -1330,6 +1332,8 @@ class AgentDB:
|
||||
model=model,
|
||||
is_saved_task=is_saved_task,
|
||||
status=status,
|
||||
use_cache=use_cache,
|
||||
cache_project_id=cache_project_id,
|
||||
)
|
||||
if workflow_permanent_id:
|
||||
workflow.workflow_permanent_id = workflow_permanent_id
|
||||
@@ -1508,6 +1512,8 @@ class AgentDB:
|
||||
description: str | None = None,
|
||||
workflow_definition: dict[str, Any] | None = None,
|
||||
version: int | None = None,
|
||||
use_cache: bool | None = None,
|
||||
cache_project_id: str | None = None,
|
||||
) -> Workflow:
|
||||
try:
|
||||
async with self.Session() as session:
|
||||
@@ -1517,14 +1523,18 @@ class AgentDB:
|
||||
if organization_id:
|
||||
get_workflow_query = get_workflow_query.filter_by(organization_id=organization_id)
|
||||
if workflow := (await session.scalars(get_workflow_query)).first():
|
||||
if title:
|
||||
if title is not None:
|
||||
workflow.title = title
|
||||
if description:
|
||||
if description is not None:
|
||||
workflow.description = description
|
||||
if workflow_definition:
|
||||
if workflow_definition is not None:
|
||||
workflow.workflow_definition = workflow_definition
|
||||
if version:
|
||||
if version is not None:
|
||||
workflow.version = version
|
||||
if use_cache is not None:
|
||||
workflow.use_cache = use_cache
|
||||
if cache_project_id is not None:
|
||||
workflow.cache_project_id = cache_project_id
|
||||
await session.commit()
|
||||
await session.refresh(workflow)
|
||||
return convert_to_workflow(workflow, self.debug_enabled)
|
||||
@@ -3489,7 +3499,6 @@ class AgentDB:
|
||||
async def create_project(
|
||||
self,
|
||||
organization_id: str,
|
||||
workflow_permanent_id: str | None = None,
|
||||
run_id: str | None = None,
|
||||
project_id: str | None = None,
|
||||
version: int | None = None,
|
||||
@@ -3498,7 +3507,6 @@ class AgentDB:
|
||||
async with self.Session() as session:
|
||||
project = ProjectModel(
|
||||
organization_id=organization_id,
|
||||
workflow_permanent_id=workflow_permanent_id,
|
||||
run_id=run_id,
|
||||
)
|
||||
if project_id:
|
||||
@@ -3518,7 +3526,6 @@ class AgentDB:
|
||||
project_revision_id: str,
|
||||
organization_id: str,
|
||||
artifact_id: str | None = None,
|
||||
workflow_permanent_id: str | None = None,
|
||||
run_id: str | None = None,
|
||||
version: int | None = None,
|
||||
) -> Project:
|
||||
@@ -3532,8 +3539,6 @@ class AgentDB:
|
||||
if project := (await session.scalars(get_project_query)).first():
|
||||
if artifact_id:
|
||||
project.artifact_id = artifact_id
|
||||
if workflow_permanent_id:
|
||||
project.workflow_permanent_id = workflow_permanent_id
|
||||
if run_id:
|
||||
project.run_id = run_id
|
||||
if version:
|
||||
|
||||
@@ -236,6 +236,8 @@ class WorkflowModel(Base):
|
||||
persist_browser_session = Column(Boolean, default=False, nullable=False)
|
||||
model = Column(JSON, nullable=True)
|
||||
status = Column(String, nullable=False, default="published")
|
||||
use_cache = Column(Boolean, default=False, nullable=False)
|
||||
cache_project_id = Column(String, nullable=True)
|
||||
|
||||
created_at = Column(DateTime, default=datetime.datetime.utcnow, nullable=False)
|
||||
modified_at = Column(
|
||||
@@ -777,7 +779,6 @@ class ProjectModel(Base):
|
||||
__tablename__ = "projects"
|
||||
__table_args__ = (
|
||||
Index("project_org_created_at_index", "organization_id", "created_at"),
|
||||
Index("project_org_wpid_index", "organization_id", "workflow_permanent_id"),
|
||||
Index("project_org_run_id_index", "organization_id", "run_id"),
|
||||
UniqueConstraint("organization_id", "project_id", "version", name="uc_org_project_version"),
|
||||
)
|
||||
@@ -785,8 +786,6 @@ class ProjectModel(Base):
|
||||
project_revision_id = Column(String, primary_key=True, default=generate_project_revision_id)
|
||||
project_id = Column(String, default=generate_project_id, nullable=False) # User-facing, consistent across versions
|
||||
organization_id = Column(String, nullable=False)
|
||||
# the wpid that this project is associated with
|
||||
workflow_permanent_id = Column(String, nullable=True)
|
||||
# The workflow run or task run id that this project is generated
|
||||
run_id = Column(String, nullable=True)
|
||||
version = Column(Integer, default=1, nullable=False)
|
||||
|
||||
@@ -499,7 +499,6 @@ def convert_to_project(project_model: ProjectModel) -> Project:
|
||||
project_revision_id=project_model.project_revision_id,
|
||||
project_id=project_model.project_id,
|
||||
organization_id=project_model.organization_id,
|
||||
workflow_id=project_model.workflow_permanent_id,
|
||||
run_id=project_model.run_id,
|
||||
version=project_model.version,
|
||||
created_at=project_model.created_at,
|
||||
|
||||
Reference in New Issue
Block a user