refactor(workflow): Remove context-specific fields from NodeExecution

Signed-off-by: -LAN- <laipz8200@outlook.com>
pull/19430/head
-LAN- 1 year ago
parent 48128bbffa
commit 1dd21007c9
No known key found for this signature in database
GPG Key ID: 6BA0D108DED011FF

@ -72,23 +72,6 @@ class NodeExecution(BaseModel):
created_at: datetime # When execution started created_at: datetime # When execution started
finished_at: Optional[datetime] = None # When execution completed finished_at: Optional[datetime] = None # When execution completed
def __init__(self, **data):
"""
Initialize the NodeExecution instance.
Note: Context-specific fields (triggered_from, created_by, created_by_role) are accepted
for backward compatibility but are ignored as they are now handled at the repository level.
"""
# Remove context-specific fields if present (for backward compatibility)
if "triggered_from" in data:
data.pop("triggered_from")
if "created_by" in data:
data.pop("created_by")
if "created_by_role" in data:
data.pop("created_by_role")
super().__init__(**data)
def update_from_mapping( def update_from_mapping(
self, self,
inputs: Optional[Mapping[str, Any]] = None, inputs: Optional[Mapping[str, Any]] = None,

@ -65,7 +65,6 @@ from models import (
EndUser, EndUser,
Workflow, Workflow,
WorkflowNodeExecutionStatus, WorkflowNodeExecutionStatus,
WorkflowNodeExecutionTriggeredFrom,
WorkflowRun, WorkflowRun,
WorkflowRunStatus, WorkflowRunStatus,
WorkflowRunTriggeredFrom, WorkflowRunTriggeredFrom,
@ -301,7 +300,6 @@ class WorkflowCycleManager:
domain_execution = NodeExecution( domain_execution = NodeExecution(
id=str(uuid4()), id=str(uuid4()),
workflow_id=workflow_run.workflow_id, workflow_id=workflow_run.workflow_id,
triggered_from=WorkflowNodeExecutionTriggeredFrom.WORKFLOW_RUN,
workflow_run_id=workflow_run.id, workflow_run_id=workflow_run.id,
predecessor_node_id=event.predecessor_node_id, predecessor_node_id=event.predecessor_node_id,
index=event.node_run_index, index=event.node_run_index,
@ -310,8 +308,6 @@ class WorkflowCycleManager:
node_type=event.node_type.value, node_type=event.node_type.value,
title=event.node_data.title, title=event.node_data.title,
status=NodeExecutionStatus.RUNNING, status=NodeExecutionStatus.RUNNING,
created_by_role=workflow_run.created_by_role,
created_by=workflow_run.created_by,
metadata=metadata, metadata=metadata,
created_at=created_at, created_at=created_at,
) )
@ -438,7 +434,6 @@ class WorkflowCycleManager:
domain_execution = NodeExecution( domain_execution = NodeExecution(
id=str(uuid4()), id=str(uuid4()),
workflow_id=workflow_run.workflow_id, workflow_id=workflow_run.workflow_id,
triggered_from=WorkflowNodeExecutionTriggeredFrom.WORKFLOW_RUN,
workflow_run_id=workflow_run.id, workflow_run_id=workflow_run.id,
predecessor_node_id=event.predecessor_node_id, predecessor_node_id=event.predecessor_node_id,
node_execution_id=event.node_execution_id, node_execution_id=event.node_execution_id,
@ -446,8 +441,6 @@ class WorkflowCycleManager:
node_type=event.node_type.value, node_type=event.node_type.value,
title=event.node_data.title, title=event.node_data.title,
status=NodeExecutionStatus.RETRY, status=NodeExecutionStatus.RETRY,
created_by_role=workflow_run.created_by_role,
created_by=workflow_run.created_by,
created_at=created_at, created_at=created_at,
finished_at=finished_at, finished_at=finished_at,
elapsed_time=elapsed_time, elapsed_time=elapsed_time,

@ -9,7 +9,6 @@ import pytest
from core.workflow.entities.node_execution_entities import NodeExecution, NodeExecutionStatus from core.workflow.entities.node_execution_entities import NodeExecution, NodeExecutionStatus
from core.workflow.repository.workflow_node_execution_repository import OrderConfig, WorkflowNodeExecutionRepository from core.workflow.repository.workflow_node_execution_repository import OrderConfig, WorkflowNodeExecutionRepository
from models.workflow import WorkflowNodeExecutionTriggeredFrom
@pytest.fixture @pytest.fixture
@ -31,7 +30,6 @@ def sample_node_execution():
node_execution_id="test-node-execution-id", node_execution_id="test-node-execution-id",
workflow_id="test-workflow-id", workflow_id="test-workflow-id",
workflow_run_id="test-workflow-run-id", workflow_run_id="test-workflow-run-id",
triggered_from=WorkflowNodeExecutionTriggeredFrom.WORKFLOW_RUN,
index=1, index=1,
predecessor_node_id="test-predecessor-node-id", predecessor_node_id="test-predecessor-node-id",
node_id="test-node-id", node_id="test-node-id",
@ -109,7 +107,6 @@ def test_get_by_workflow_run(repository, sample_node_execution):
node_execution_id="test-node-execution-id-2", node_execution_id="test-node-execution-id-2",
workflow_id=sample_node_execution.workflow_id, workflow_id=sample_node_execution.workflow_id,
workflow_run_id=sample_node_execution.workflow_run_id, workflow_run_id=sample_node_execution.workflow_run_id,
triggered_from=WorkflowNodeExecutionTriggeredFrom.WORKFLOW_RUN,
index=2, index=2,
predecessor_node_id=sample_node_execution.node_id, predecessor_node_id=sample_node_execution.node_id,
node_id="test-node-id-2", node_id="test-node-id-2",

Loading…
Cancel
Save