mirror of
https://github.com/langgenius/dify.git
synced 2026-05-04 01:18:05 +08:00
chore(api): remove backend utcnow usage (#34131)
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from contextlib import contextmanager
|
||||
from datetime import datetime
|
||||
from types import SimpleNamespace
|
||||
|
||||
import pytest
|
||||
@ -45,6 +44,7 @@ from core.base.tts.app_generator_tts_publisher import AudioTrunk
|
||||
from core.workflow.system_variables import build_system_variables
|
||||
from graphon.enums import BuiltinNodeTypes
|
||||
from graphon.runtime import GraphRuntimeState, VariablePool
|
||||
from libs.datetime_utils import naive_utc_now
|
||||
from models.enums import MessageStatus
|
||||
from models.model import AppMode, EndUser
|
||||
from tests.workflow_test_utils import build_test_variable_pool
|
||||
@ -76,7 +76,7 @@ def _make_pipeline():
|
||||
message = SimpleNamespace(
|
||||
id="message-id",
|
||||
query="hello",
|
||||
created_at=datetime.utcnow(),
|
||||
created_at=naive_utc_now(),
|
||||
status=MessageStatus.NORMAL,
|
||||
answer="",
|
||||
)
|
||||
@ -257,7 +257,7 @@ class TestAdvancedChatGenerateTaskPipeline:
|
||||
node_id="node",
|
||||
node_type=BuiltinNodeTypes.LLM,
|
||||
node_title="LLM",
|
||||
start_at=datetime.utcnow(),
|
||||
start_at=naive_utc_now(),
|
||||
node_run_index=1,
|
||||
)
|
||||
iter_next = QueueIterationNextEvent(
|
||||
@ -273,7 +273,7 @@ class TestAdvancedChatGenerateTaskPipeline:
|
||||
node_id="node",
|
||||
node_type=BuiltinNodeTypes.LLM,
|
||||
node_title="LLM",
|
||||
start_at=datetime.utcnow(),
|
||||
start_at=naive_utc_now(),
|
||||
node_run_index=1,
|
||||
)
|
||||
loop_start = QueueLoopStartEvent(
|
||||
@ -281,7 +281,7 @@ class TestAdvancedChatGenerateTaskPipeline:
|
||||
node_id="node",
|
||||
node_type=BuiltinNodeTypes.LLM,
|
||||
node_title="LLM",
|
||||
start_at=datetime.utcnow(),
|
||||
start_at=naive_utc_now(),
|
||||
node_run_index=1,
|
||||
)
|
||||
loop_next = QueueLoopNextEvent(
|
||||
@ -297,7 +297,7 @@ class TestAdvancedChatGenerateTaskPipeline:
|
||||
node_id="node",
|
||||
node_type=BuiltinNodeTypes.LLM,
|
||||
node_title="LLM",
|
||||
start_at=datetime.utcnow(),
|
||||
start_at=naive_utc_now(),
|
||||
node_run_index=1,
|
||||
)
|
||||
|
||||
@ -360,7 +360,7 @@ class TestAdvancedChatGenerateTaskPipeline:
|
||||
node_execution_id="exec",
|
||||
node_id="node",
|
||||
node_type=BuiltinNodeTypes.LLM,
|
||||
start_at=datetime.utcnow(),
|
||||
start_at=naive_utc_now(),
|
||||
inputs={},
|
||||
outputs={},
|
||||
process_data={},
|
||||
@ -370,7 +370,7 @@ class TestAdvancedChatGenerateTaskPipeline:
|
||||
node_execution_id="exec",
|
||||
node_id="node",
|
||||
node_type=BuiltinNodeTypes.LLM,
|
||||
start_at=datetime.utcnow(),
|
||||
start_at=naive_utc_now(),
|
||||
inputs={},
|
||||
outputs={},
|
||||
process_data={},
|
||||
@ -473,7 +473,7 @@ class TestAdvancedChatGenerateTaskPipeline:
|
||||
node_id="node",
|
||||
node_type=BuiltinNodeTypes.LLM,
|
||||
node_title="title",
|
||||
expiration_time=datetime.utcnow(),
|
||||
expiration_time=naive_utc_now(),
|
||||
)
|
||||
|
||||
assert list(pipeline._handle_human_input_form_filled_event(filled_event)) == ["filled"]
|
||||
@ -591,7 +591,7 @@ class TestAdvancedChatGenerateTaskPipeline:
|
||||
node_execution_id="exec",
|
||||
node_id="node",
|
||||
node_type=BuiltinNodeTypes.LLM,
|
||||
start_at=datetime.utcnow(),
|
||||
start_at=naive_utc_now(),
|
||||
inputs={},
|
||||
outputs={},
|
||||
process_data={},
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from contextlib import contextmanager
|
||||
from datetime import datetime
|
||||
from types import SimpleNamespace
|
||||
|
||||
import pytest
|
||||
@ -47,6 +46,7 @@ from core.base.tts.app_generator_tts_publisher import AudioTrunk
|
||||
from core.workflow.system_variables import build_system_variables, system_variables_to_mapping
|
||||
from graphon.enums import BuiltinNodeTypes, WorkflowExecutionStatus
|
||||
from graphon.runtime import GraphRuntimeState, VariablePool
|
||||
from libs.datetime_utils import naive_utc_now
|
||||
from models.enums import CreatorUserRole
|
||||
from models.model import AppMode, EndUser
|
||||
from tests.workflow_test_utils import build_test_variable_pool
|
||||
@ -192,7 +192,7 @@ class TestWorkflowGenerateTaskPipeline:
|
||||
node_execution_id="exec",
|
||||
node_id="node",
|
||||
node_type=BuiltinNodeTypes.START,
|
||||
start_at=datetime.utcnow(),
|
||||
start_at=naive_utc_now(),
|
||||
inputs={},
|
||||
outputs={},
|
||||
process_data={},
|
||||
@ -245,7 +245,7 @@ class TestWorkflowGenerateTaskPipeline:
|
||||
node_execution_id="exec",
|
||||
node_id="node",
|
||||
node_type=BuiltinNodeTypes.START,
|
||||
start_at=datetime.utcnow(),
|
||||
start_at=naive_utc_now(),
|
||||
inputs={},
|
||||
outputs={},
|
||||
process_data={},
|
||||
@ -303,7 +303,7 @@ class TestWorkflowGenerateTaskPipeline:
|
||||
node_id="node",
|
||||
node_type=BuiltinNodeTypes.LLM,
|
||||
node_title="LLM",
|
||||
start_at=datetime.utcnow(),
|
||||
start_at=naive_utc_now(),
|
||||
node_run_index=1,
|
||||
)
|
||||
iter_next = QueueIterationNextEvent(
|
||||
@ -319,7 +319,7 @@ class TestWorkflowGenerateTaskPipeline:
|
||||
node_id="node",
|
||||
node_type=BuiltinNodeTypes.LLM,
|
||||
node_title="LLM",
|
||||
start_at=datetime.utcnow(),
|
||||
start_at=naive_utc_now(),
|
||||
node_run_index=1,
|
||||
)
|
||||
loop_start = QueueLoopStartEvent(
|
||||
@ -327,7 +327,7 @@ class TestWorkflowGenerateTaskPipeline:
|
||||
node_id="node",
|
||||
node_type=BuiltinNodeTypes.LLM,
|
||||
node_title="LLM",
|
||||
start_at=datetime.utcnow(),
|
||||
start_at=naive_utc_now(),
|
||||
node_run_index=1,
|
||||
)
|
||||
loop_next = QueueLoopNextEvent(
|
||||
@ -343,7 +343,7 @@ class TestWorkflowGenerateTaskPipeline:
|
||||
node_id="node",
|
||||
node_type=BuiltinNodeTypes.LLM,
|
||||
node_title="LLM",
|
||||
start_at=datetime.utcnow(),
|
||||
start_at=naive_utc_now(),
|
||||
node_run_index=1,
|
||||
)
|
||||
filled_event = QueueHumanInputFormFilledEvent(
|
||||
@ -359,7 +359,7 @@ class TestWorkflowGenerateTaskPipeline:
|
||||
node_id="node",
|
||||
node_type=BuiltinNodeTypes.LLM,
|
||||
node_title="title",
|
||||
expiration_time=datetime.utcnow(),
|
||||
expiration_time=naive_utc_now(),
|
||||
)
|
||||
agent_event = QueueAgentLogEvent(
|
||||
id="log",
|
||||
@ -648,7 +648,7 @@ class TestWorkflowGenerateTaskPipeline:
|
||||
node_title="title",
|
||||
node_type=BuiltinNodeTypes.LLM,
|
||||
node_run_index=1,
|
||||
start_at=datetime.utcnow(),
|
||||
start_at=naive_utc_now(),
|
||||
provider_type="provider",
|
||||
provider_id="provider-id",
|
||||
error="error",
|
||||
@ -660,7 +660,7 @@ class TestWorkflowGenerateTaskPipeline:
|
||||
node_title="title",
|
||||
node_type=BuiltinNodeTypes.LLM,
|
||||
node_run_index=1,
|
||||
start_at=datetime.utcnow(),
|
||||
start_at=naive_utc_now(),
|
||||
provider_type="provider",
|
||||
provider_id="provider-id",
|
||||
)
|
||||
@ -685,7 +685,7 @@ class TestWorkflowGenerateTaskPipeline:
|
||||
node_execution_id="exec-id",
|
||||
node_id="node",
|
||||
node_type=BuiltinNodeTypes.START,
|
||||
start_at=datetime.utcnow(),
|
||||
start_at=naive_utc_now(),
|
||||
inputs={},
|
||||
outputs={},
|
||||
process_data={},
|
||||
@ -836,7 +836,7 @@ class TestWorkflowGenerateTaskPipeline:
|
||||
node_id="node-id",
|
||||
node_type=BuiltinNodeTypes.START,
|
||||
in_loop_id="loop-id",
|
||||
start_at=datetime.utcnow(),
|
||||
start_at=naive_utc_now(),
|
||||
process_data={"k": "v"},
|
||||
outputs={"out": 1},
|
||||
)
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
from collections.abc import Sequence
|
||||
from datetime import datetime
|
||||
from unittest.mock import Mock
|
||||
|
||||
from core.app.layers.conversation_variable_persist_layer import ConversationVariablePersistenceLayer
|
||||
@ -12,6 +11,7 @@ from graphon.node_events import NodeRunResult
|
||||
from graphon.runtime.graph_runtime_state_protocol import ReadOnlyGraphRuntimeState
|
||||
from graphon.variables import StringVariable
|
||||
from graphon.variables.segments import Segment, StringSegment
|
||||
from libs.datetime_utils import naive_utc_now
|
||||
|
||||
|
||||
class MockReadOnlyVariablePool:
|
||||
@ -48,7 +48,7 @@ def _build_node_run_succeeded_event() -> NodeRunSucceededEvent:
|
||||
id="node-exec-id",
|
||||
node_id="assigner",
|
||||
node_type=BuiltinNodeTypes.LLM,
|
||||
start_at=datetime.utcnow(),
|
||||
start_at=naive_utc_now(),
|
||||
node_run_result=NodeRunResult(
|
||||
status=WorkflowNodeExecutionStatus.SUCCEEDED,
|
||||
outputs={},
|
||||
|
||||
@ -274,7 +274,7 @@ def _make_form_definition() -> str:
|
||||
inputs=[],
|
||||
user_actions=[UserAction(id="submit", title="Submit")],
|
||||
rendered_content="<p>hello</p>",
|
||||
expiration_time=datetime.utcnow(),
|
||||
expiration_time=naive_utc_now(),
|
||||
).model_dump_json()
|
||||
|
||||
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import queue
|
||||
from datetime import datetime
|
||||
|
||||
from graphon.enums import BuiltinNodeTypes, WorkflowNodeExecutionStatus
|
||||
from graphon.graph_engine.orchestration.dispatcher import Dispatcher
|
||||
from graphon.graph_events import NodeRunSucceededEvent
|
||||
from graphon.node_events import NodeRunResult
|
||||
from libs.datetime_utils import naive_utc_now
|
||||
|
||||
|
||||
class StubExecutionCoordinator:
|
||||
@ -52,7 +52,7 @@ def test_dispatcher_drains_events_when_paused() -> None:
|
||||
id="exec-1",
|
||||
node_id="node-1",
|
||||
node_type=BuiltinNodeTypes.START,
|
||||
start_at=datetime.utcnow(),
|
||||
start_at=naive_utc_now(),
|
||||
node_run_result=NodeRunResult(status=WorkflowNodeExecutionStatus.SUCCEEDED),
|
||||
)
|
||||
event_queue.put(event)
|
||||
|
||||
Reference in New Issue
Block a user