refactor(workflow): Rename NodeRunMetadataKey to WorkflowNodeExecutionMetadataKey (#20457)

Signed-off-by: -LAN- <laipz8200@outlook.com>
This commit is contained in:
-LAN-
2025-05-30 04:47:56 +08:00
committed by GitHub
parent 482e50aae9
commit 32e779eef3
22 changed files with 145 additions and 128 deletions

View File

@@ -4,7 +4,7 @@ import pytest
from flask import Flask
from core.app.entities.app_invoke_entities import InvokeFrom
from core.workflow.entities.node_entities import NodeRunMetadataKey, NodeRunResult
from core.workflow.entities.node_entities import NodeRunResult, WorkflowNodeExecutionMetadataKey
from core.workflow.entities.variable_pool import VariablePool
from core.workflow.entities.workflow_node_execution import WorkflowNodeExecutionStatus
from core.workflow.enums import SystemVariableKey
@@ -202,9 +202,9 @@ def test_run_parallel_in_workflow(mock_close, mock_remove):
process_data={},
outputs={},
metadata={
NodeRunMetadataKey.TOTAL_TOKENS: 1,
NodeRunMetadataKey.TOTAL_PRICE: 1,
NodeRunMetadataKey.CURRENCY: "USD",
WorkflowNodeExecutionMetadataKey.TOTAL_TOKENS: 1,
WorkflowNodeExecutionMetadataKey.TOTAL_PRICE: 1,
WorkflowNodeExecutionMetadataKey.CURRENCY: "USD",
},
)
)
@@ -837,9 +837,9 @@ def test_condition_parallel_correct_output(mock_close, mock_remove, app):
process_data={},
outputs={"class_name": "financial", "class_id": "1"},
metadata={
NodeRunMetadataKey.TOTAL_TOKENS: 1,
NodeRunMetadataKey.TOTAL_PRICE: 1,
NodeRunMetadataKey.CURRENCY: "USD",
WorkflowNodeExecutionMetadataKey.TOTAL_TOKENS: 1,
WorkflowNodeExecutionMetadataKey.TOTAL_PRICE: 1,
WorkflowNodeExecutionMetadataKey.CURRENCY: "USD",
},
edge_source_handle="1",
)
@@ -853,9 +853,9 @@ def test_condition_parallel_correct_output(mock_close, mock_remove, app):
process_data={},
outputs={"result": "dify 123"},
metadata={
NodeRunMetadataKey.TOTAL_TOKENS: 1,
NodeRunMetadataKey.TOTAL_PRICE: 1,
NodeRunMetadataKey.CURRENCY: "USD",
WorkflowNodeExecutionMetadataKey.TOTAL_TOKENS: 1,
WorkflowNodeExecutionMetadataKey.TOTAL_PRICE: 1,
WorkflowNodeExecutionMetadataKey.CURRENCY: "USD",
},
)
)

View File

@@ -1,7 +1,7 @@
from unittest.mock import patch
from core.app.entities.app_invoke_entities import InvokeFrom
from core.workflow.entities.node_entities import NodeRunMetadataKey, NodeRunResult
from core.workflow.entities.node_entities import NodeRunResult, WorkflowNodeExecutionMetadataKey
from core.workflow.entities.workflow_node_execution import WorkflowNodeExecutionStatus
from core.workflow.enums import SystemVariableKey
from core.workflow.graph_engine.entities.event import (
@@ -543,9 +543,9 @@ def test_stream_output_with_fail_branch_continue_on_error():
process_data={},
outputs={},
metadata={
NodeRunMetadataKey.TOTAL_TOKENS: 1,
NodeRunMetadataKey.TOTAL_PRICE: 1,
NodeRunMetadataKey.CURRENCY: "USD",
WorkflowNodeExecutionMetadataKey.TOTAL_TOKENS: 1,
WorkflowNodeExecutionMetadataKey.TOTAL_PRICE: 1,
WorkflowNodeExecutionMetadataKey.CURRENCY: "USD",
},
)
)

View File

@@ -15,7 +15,7 @@ from core.app.entities.queue_entities import (
from core.workflow.entities.workflow_execution import WorkflowExecution, WorkflowExecutionStatus, WorkflowType
from core.workflow.entities.workflow_node_execution import (
NodeExecution,
NodeRunMetadataKey,
WorkflowNodeExecutionMetadataKey,
WorkflowNodeExecutionStatus,
)
from core.workflow.enums import SystemVariableKey
@@ -318,7 +318,7 @@ def test_handle_node_execution_start(workflow_cycle_manager, mock_workflow_execu
# Verify the result
assert result.workflow_id == workflow_execution.workflow_id
assert result.workflow_run_id == workflow_execution.id_
assert result.workflow_execution_id == workflow_execution.id_
assert result.node_execution_id == event.node_execution_id
assert result.node_id == event.node_id
assert result.node_type == event.node_type
@@ -368,7 +368,7 @@ def test_handle_workflow_node_execution_success(workflow_cycle_manager):
event.inputs = {"input": "test input"}
event.process_data = {"process": "test process"}
event.outputs = {"output": "test output"}
event.execution_metadata = {NodeRunMetadataKey.TOTAL_TOKENS: 100}
event.execution_metadata = {WorkflowNodeExecutionMetadataKey.TOTAL_TOKENS: 100}
event.start_at = datetime.now(UTC).replace(tzinfo=None)
# Create a real node execution
@@ -377,7 +377,7 @@ def test_handle_workflow_node_execution_success(workflow_cycle_manager):
id="test-node-execution-record-id",
node_execution_id="test-node-execution-id",
workflow_id="test-workflow-id",
workflow_run_id="test-workflow-run-id",
workflow_execution_id="test-workflow-run-id",
index=1,
node_id="test-node-id",
node_type=NodeType.LLM,
@@ -445,7 +445,7 @@ def test_handle_workflow_node_execution_failed(workflow_cycle_manager):
event.inputs = {"input": "test input"}
event.process_data = {"process": "test process"}
event.outputs = {"output": "test output"}
event.execution_metadata = {NodeRunMetadataKey.TOTAL_TOKENS: 100}
event.execution_metadata = {WorkflowNodeExecutionMetadataKey.TOTAL_TOKENS: 100}
event.start_at = datetime.now(UTC).replace(tzinfo=None)
event.error = "Test error message"
@@ -455,7 +455,7 @@ def test_handle_workflow_node_execution_failed(workflow_cycle_manager):
id="test-node-execution-record-id",
node_execution_id="test-node-execution-id",
workflow_id="test-workflow-id",
workflow_run_id="test-workflow-run-id",
workflow_execution_id="test-workflow-run-id",
index=1,
node_id="test-node-id",
node_type=NodeType.LLM,