From 62f792ea142419b5b02d5b350c74a61c4649fa81 Mon Sep 17 00:00:00 2001 From: -LAN- Date: Tue, 31 Dec 2024 17:02:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20ensure=20workflow=5Frun=5Fid=20is=20alwa?= =?UTF-8?q?ys=20set=20and=20improve=20handling=20in=20Wor=E2=80=A6=20(#122?= =?UTF-8?q?64)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: -LAN- --- api/core/app/apps/workflow/app_generator.py | 1 + api/core/app/entities/app_invoke_entities.py | 2 +- api/core/app/task_pipeline/workflow_cycle_manage.py | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/api/core/app/apps/workflow/app_generator.py b/api/core/app/apps/workflow/app_generator.py index 42bc17277f..0c532f47cf 100644 --- a/api/core/app/apps/workflow/app_generator.py +++ b/api/core/app/apps/workflow/app_generator.py @@ -221,6 +221,7 @@ class WorkflowAppGenerator(BaseAppGenerator): single_iteration_run=WorkflowAppGenerateEntity.SingleIterationRunEntity( node_id=node_id, inputs=args["inputs"] ), + workflow_run_id=str(uuid.uuid4()), ) contexts.tenant_id.set(application_generate_entity.app_config.tenant_id) diff --git a/api/core/app/entities/app_invoke_entities.py b/api/core/app/entities/app_invoke_entities.py index 16dc91bb77..7cb4e59032 100644 --- a/api/core/app/entities/app_invoke_entities.py +++ b/api/core/app/entities/app_invoke_entities.py @@ -195,7 +195,7 @@ class WorkflowAppGenerateEntity(AppGenerateEntity): # app config app_config: WorkflowUIBasedAppConfig - workflow_run_id: Optional[str] = None + workflow_run_id: str class SingleIterationRunEntity(BaseModel): """ diff --git a/api/core/app/task_pipeline/workflow_cycle_manage.py b/api/core/app/task_pipeline/workflow_cycle_manage.py index e21475271a..885b341196 100644 --- a/api/core/app/task_pipeline/workflow_cycle_manage.py +++ b/api/core/app/task_pipeline/workflow_cycle_manage.py @@ -102,7 +102,8 @@ class WorkflowCycleManage: inputs = dict(WorkflowEntry.handle_special_values(inputs) or {}) # init workflow run - workflow_run_id = str(self._workflow_system_variables.get(SystemVariableKey.WORKFLOW_RUN_ID, uuid4())) + # TODO: This workflow_run_id should always not be None, maybe we can use a more elegant way to handle this + workflow_run_id = str(self._workflow_system_variables.get(SystemVariableKey.WORKFLOW_RUN_ID) or uuid4()) workflow_run = WorkflowRun() workflow_run.id = workflow_run_id