refactor: migrate core, models, tasks, events and schedule to sessionmaker pattern#34381
Open
xr843 wants to merge 7 commits intolanggenius:mainfrom
Open
refactor: migrate core, models, tasks, events and schedule to sessionmaker pattern#34381xr843 wants to merge 7 commits intolanggenius:mainfrom
xr843 wants to merge 7 commits intolanggenius:mainfrom
Conversation
…er pattern Part of langgenius#24245. Replace manual Session(db.engine) + session.commit() with sessionmaker(db.engine).begin() context manager in api/core/, api/models/, api/tasks/, api/events/, api/schedule/, and api/extensions/. - Replace `Session(db.engine)` with `sessionmaker(db.engine).begin()` - Replace `Session(db.engine, expire_on_commit=False)` with `sessionmaker(db.engine, expire_on_commit=False).begin()` - Remove manual `session.commit()` calls (handled automatically by context manager) - Replace `session.commit()` with `session.flush()` where followed by `session.refresh()` - Preserve `expire_on_commit=False` and `autoflush=False` where applicable - Update imports: add `sessionmaker`, remove unused `Session` imports
Contributor
|
fix conflict |
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-04-01 16:15:22.076853252 +0000
+++ /tmp/pyrefly_pr.txt 2026-04-01 16:15:09.987840123 +0000
@@ -24,12 +24,14 @@
--> controllers/console/version.py:30:2
ERROR Runtime checkable protocol `Generator` has an unsafe overlap with type `Generator[LLMResultChunk] | LLMResult` [unsafe-overlap]
--> core/agent/fc_agent_runner.py:114:35
+ERROR Could not find name `Session` [unknown-name]
+ --> core/app/apps/common/workflow_response_converter.py:331:18
ERROR Class member `EasyUIBasedGenerateTaskPipeline._application_generate_entity` overrides parent class `BasedGenerateTaskPipeline` in an inconsistent manner [bad-override]
--> core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:75:5
ERROR `+=` is not supported between `list[PromptMessageContentUnionTypes]` and `str` [unsupported-operation]
- --> core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:325:29
+ --> core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:323:29
ERROR Argument `list[Unknown]` is not assignable to parameter `value` with type `SQLCoreOperations[dict[str, Any]] | dict[str, Any]` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
- --> core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:392:27
+ --> core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:390:27
ERROR No matching overload found for function `core.model_manager.ModelInstance.invoke_llm` called with arguments: (prompt_messages=list[UserPromptMessage], model_parameters=dict[str, int], stream=Literal[False]) [no-matching-overload]
--> core/llm_generator/llm_generator.py:74:60
ERROR No matching overload found for function `core.model_manager.ModelInstance.invoke_llm` called with arguments: (prompt_messages=list[UserPromptMessage], model_parameters=dict[str, float | int], stream=Literal[False]) [no-matching-overload]
@@ -61,9 +63,9 @@
ERROR Argument `dict[str, int | str | None]` is not assignable to parameter `attributes` with type `dict[str, str] | None` in function `mlflow.tracing.fluent.start_span_no_context` [bad-argument-type]
--> core/ops/mlflow_trace/mlflow_trace.py:415:24
ERROR Class member `OpsTraceProviderConfigMap.__getitem__` overrides parent class `UserDict` in an inconsistent manner [bad-param-name-override]
- --> core/ops/ops_trace_manager.py:199:9
+ --> core/ops/ops_trace_manager.py:200:9
ERROR Object of class `dict` has no attribute `model_dump` [missing-attribute]
- --> core/ops/ops_trace_manager.py:1521:32
+ --> core/ops/ops_trace_manager.py:1522:32
ERROR Runtime checkable protocol `Generator` has an unsafe overlap with type `BaseModel | Generator[BaseModel | Mapping[Unknown, Unknown] | str] | Mapping[Unknown, Unknown]` [unsafe-overlap]
--> core/plugin/backwards_invocation/base.py:10:33
ERROR Runtime checkable protocol `Generator` has an unsafe overlap with type `Generator[LLMResultChunkWithStructuredOutput] | LLMResultWithStructuredOutput` [unsafe-overlap]
@@ -354,6 +356,18 @@
--> core/tools/utils/web_reader_tool.py:66:35
ERROR `list[Never]` is not assignable to attribute `tools` with type `Never` [bad-assignment]
--> core/tools/workflow_as_tool/provider.py:237:26
+ERROR Cannot find module `dify_graph.enums` [missing-import]
+ --> core/workflow/nodes/agent/message_transformer.py:11:1
+ERROR Cannot find module `dify_graph.file` [missing-import]
+ --> core/workflow/nodes/agent/message_transformer.py:12:1
+ERROR Cannot find module `dify_graph.model_runtime.entities.llm_entities` [missing-import]
+ --> core/workflow/nodes/agent/message_transformer.py:13:1
+ERROR Cannot find module `dify_graph.model_runtime.utils.encoders` [missing-import]
+ --> core/workflow/nodes/agent/message_transformer.py:14:1
+ERROR Cannot find module `dify_graph.node_events` [missing-import]
+ --> core/workflow/nodes/agent/message_transformer.py:15:1
+ERROR Parse error: Expected one or more symbol names after import [parse-error]
+ --> core/workflow/nodes/agent/message_transformer.py:15:37
ERROR Object of class `NoneType` has no attribute `instrument` [missing-attribute]
--> extensions/otel/runtime.py:96:9
ERROR Cannot index into `Literal['']` [bad-index]
|
…ge_transformer.py Removed stale dify_graph import block (lines 6-15) that was left over from a merge/rebase, causing an unclosed parenthesis SyntaxError at line 15. The correct graphon imports were already present below. Re-added the sessionmaker import that was part of the removed block. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-04-01 23:37:48.660975750 +0000
+++ /tmp/pyrefly_pr.txt 2026-04-01 23:37:37.222675293 +0000
@@ -24,12 +24,14 @@
--> controllers/console/version.py:30:2
ERROR Runtime checkable protocol `Generator` has an unsafe overlap with type `Generator[LLMResultChunk] | LLMResult` [unsafe-overlap]
--> core/agent/fc_agent_runner.py:114:35
+ERROR Could not find name `Session` [unknown-name]
+ --> core/app/apps/common/workflow_response_converter.py:331:18
ERROR Class member `EasyUIBasedGenerateTaskPipeline._application_generate_entity` overrides parent class `BasedGenerateTaskPipeline` in an inconsistent manner [bad-override]
--> core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:75:5
ERROR `+=` is not supported between `list[PromptMessageContentUnionTypes]` and `str` [unsupported-operation]
- --> core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:325:29
+ --> core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:323:29
ERROR Argument `list[Unknown]` is not assignable to parameter `value` with type `SQLCoreOperations[dict[str, Any]] | dict[str, Any]` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
- --> core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:392:27
+ --> core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:390:27
ERROR No matching overload found for function `core.model_manager.ModelInstance.invoke_llm` called with arguments: (prompt_messages=list[UserPromptMessage], model_parameters=dict[str, int], stream=Literal[False]) [no-matching-overload]
--> core/llm_generator/llm_generator.py:74:60
ERROR No matching overload found for function `core.model_manager.ModelInstance.invoke_llm` called with arguments: (prompt_messages=list[UserPromptMessage], model_parameters=dict[str, float | int], stream=Literal[False]) [no-matching-overload]
@@ -61,9 +63,9 @@
ERROR Argument `dict[str, int | str | None]` is not assignable to parameter `attributes` with type `dict[str, str] | None` in function `mlflow.tracing.fluent.start_span_no_context` [bad-argument-type]
--> core/ops/mlflow_trace/mlflow_trace.py:415:24
ERROR Class member `OpsTraceProviderConfigMap.__getitem__` overrides parent class `UserDict` in an inconsistent manner [bad-param-name-override]
- --> core/ops/ops_trace_manager.py:199:9
+ --> core/ops/ops_trace_manager.py:200:9
ERROR Object of class `dict` has no attribute `model_dump` [missing-attribute]
- --> core/ops/ops_trace_manager.py:1521:32
+ --> core/ops/ops_trace_manager.py:1522:32
ERROR Runtime checkable protocol `Generator` has an unsafe overlap with type `BaseModel | Generator[BaseModel | Mapping[Unknown, Unknown] | str] | Mapping[Unknown, Unknown]` [unsafe-overlap]
--> core/plugin/backwards_invocation/base.py:10:33
ERROR Runtime checkable protocol `Generator` has an unsafe overlap with type `Generator[LLMResultChunkWithStructuredOutput] | LLMResultWithStructuredOutput` [unsafe-overlap]
|
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-04-01 23:39:55.756008946 +0000
+++ /tmp/pyrefly_pr.txt 2026-04-01 23:39:45.246040575 +0000
@@ -24,12 +24,14 @@
--> controllers/console/version.py:30:2
ERROR Runtime checkable protocol `Generator` has an unsafe overlap with type `Generator[LLMResultChunk] | LLMResult` [unsafe-overlap]
--> core/agent/fc_agent_runner.py:114:35
+ERROR Could not find name `Session` [unknown-name]
+ --> core/app/apps/common/workflow_response_converter.py:330:18
ERROR Class member `EasyUIBasedGenerateTaskPipeline._application_generate_entity` overrides parent class `BasedGenerateTaskPipeline` in an inconsistent manner [bad-override]
--> core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:75:5
ERROR `+=` is not supported between `list[PromptMessageContentUnionTypes]` and `str` [unsupported-operation]
- --> core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:325:29
+ --> core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:323:29
ERROR Argument `list[Unknown]` is not assignable to parameter `value` with type `SQLCoreOperations[dict[str, Any]] | dict[str, Any]` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
- --> core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:392:27
+ --> core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:390:27
ERROR No matching overload found for function `core.model_manager.ModelInstance.invoke_llm` called with arguments: (prompt_messages=list[UserPromptMessage], model_parameters=dict[str, int], stream=Literal[False]) [no-matching-overload]
--> core/llm_generator/llm_generator.py:74:60
ERROR No matching overload found for function `core.model_manager.ModelInstance.invoke_llm` called with arguments: (prompt_messages=list[UserPromptMessage], model_parameters=dict[str, float | int], stream=Literal[False]) [no-matching-overload]
|
- Add missing `from sqlalchemy.orm import sessionmaker` import in workflow_response_converter.py and replace `Session(bind=db.engine)` with `sessionmaker(db.engine).begin()` - Update test_schedule_service.py: mock `sessionmaker` instead of `Session`, use `.return_value.begin.return_value.__enter__` chain, remove `session.commit` assertions (handled by sessionmaker.begin context) - Update test_workflow_execute_task.py: replace `_FakeSessionContext` with `_make_sessionmaker_mock` helper that mocks the sessionmaker.begin pattern - Update test_base_trace_instance.py: mock `sessionmaker` instead of `Session` with proper begin context manager chain
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-04-02 04:34:27.438316980 +0000
+++ /tmp/pyrefly_pr.txt 2026-04-02 04:34:16.883348509 +0000
@@ -27,9 +27,9 @@
ERROR Class member `EasyUIBasedGenerateTaskPipeline._application_generate_entity` overrides parent class `BasedGenerateTaskPipeline` in an inconsistent manner [bad-override]
--> core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:75:5
ERROR `+=` is not supported between `list[PromptMessageContentUnionTypes]` and `str` [unsupported-operation]
- --> core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:325:29
+ --> core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:323:29
ERROR Argument `list[Unknown]` is not assignable to parameter `value` with type `SQLCoreOperations[dict[str, Any]] | dict[str, Any]` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
- --> core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:392:27
+ --> core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:390:27
ERROR No matching overload found for function `core.model_manager.ModelInstance.invoke_llm` called with arguments: (prompt_messages=list[UserPromptMessage], model_parameters=dict[str, int], stream=Literal[False]) [no-matching-overload]
--> core/llm_generator/llm_generator.py:74:60
ERROR No matching overload found for function `core.model_manager.ModelInstance.invoke_llm` called with arguments: (prompt_messages=list[UserPromptMessage], model_parameters=dict[str, float | int], stream=Literal[False]) [no-matching-overload]
@@ -7182,11 +7182,11 @@
ERROR Argument `dict[str, bool]` is not assignable to parameter `substitutions` with type `Mapping[str, str]` in function `tasks.mail_inner_task._render_template_with_strategy` [bad-argument-type]
--> tests/unit_tests/tasks/test_mail_send_task.py:1300:64
ERROR Argument `Iterator[Any]` is not assignable to parameter `response_stream` with type `Generator[BaseModel | Mapping[str, Any] | str]` in function `tasks.app_generate.workflow_execute_task._publish_streaming_response` [bad-argument-type]
- --> tests/unit_tests/tasks/test_workflow_execute_task.py:55:33
+ --> tests/unit_tests/tasks/test_workflow_execute_task.py:54:33
ERROR Argument `UUID` is not assignable to parameter `workflow_run_id` with type `str` in function `tasks.app_generate.workflow_execute_task._publish_streaming_response` [bad-argument-type]
- --> tests/unit_tests/tasks/test_workflow_execute_task.py:55:50
+ --> tests/unit_tests/tasks/test_workflow_execute_task.py:54:50
ERROR Argument `Iterator[Any]` is not assignable to parameter `response_stream` with type `Generator[BaseModel | Mapping[str, Any] | str]` in function `tasks.app_generate.workflow_execute_task._publish_streaming_response` [bad-argument-type]
- --> tests/unit_tests/tasks/test_workflow_execute_task.py:65:33
+ --> tests/unit_tests/tasks/test_workflow_execute_task.py:64:33
ERROR Object of class `BlobChunkMessage` has no attribute `variable_name`
ERROR Object of class `BlobChunkMessage` has no attribute `variable_name`
ERROR Object of class `BlobChunkMessage` has no attribute `variable_value`
|
… models) Update mock patterns in 5 test files to match the Session -> sessionmaker refactor. The sessionmaker(engine).begin() pattern returns a context manager that auto-commits, so Session mocks are replaced with sessionmaker mocks using the factory.begin() chain, and explicit commit assertions are removed. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-04-02 09:32:22.318573991 +0000
+++ /tmp/pyrefly_pr.txt 2026-04-02 09:32:12.148668621 +0000
@@ -19,9 +19,9 @@
ERROR Class member `EasyUIBasedGenerateTaskPipeline._application_generate_entity` overrides parent class `BasedGenerateTaskPipeline` in an inconsistent manner [bad-override]
--> core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:75:5
ERROR `+=` is not supported between `list[PromptMessageContentUnionTypes]` and `str` [unsupported-operation]
- --> core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:323:29
+ --> core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:321:29
ERROR Argument `list[Unknown]` is not assignable to parameter `value` with type `SQLCoreOperations[dict[str, Any]] | dict[str, Any]` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
- --> core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:390:27
+ --> core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:388:27
ERROR No matching overload found for function `core.model_manager.ModelInstance.invoke_llm` called with arguments: (prompt_messages=list[UserPromptMessage], model_parameters=dict[str, int], stream=Literal[False]) [no-matching-overload]
--> core/llm_generator/llm_generator.py:74:60
ERROR No matching overload found for function `core.model_manager.ModelInstance.invoke_llm` called with arguments: (prompt_messages=list[UserPromptMessage], model_parameters=dict[str, float | int], stream=Literal[False]) [no-matching-overload]
@@ -5759,25 +5759,25 @@
ERROR No matching overload found for function `list.__init__` called with arguments: (Generator[Unknown] | None) [no-matching-overload]
--> tests/unit_tests/core/tools/test_tool_file_manager.py:253:24
ERROR `SimpleNamespace` is not assignable to attribute `entity` with type `ToolProviderEntityWithPlugin` [bad-assignment]
- --> tests/unit_tests/core/tools/test_tool_manager.py:300:32
+ --> tests/unit_tests/core/tools/test_tool_manager.py:307:32
ERROR Argument `SimpleNamespace` is not assignable to parameter `agent_tool` with type `AgentToolEntity` in function `core.tools.tool_manager.ToolManager.get_agent_tool_runtime` [bad-argument-type]
- --> tests/unit_tests/core/tools/test_tool_manager.py:438:32
+ --> tests/unit_tests/core/tools/test_tool_manager.py:444:32
ERROR Argument `SimpleNamespace` is not assignable to parameter `workflow_tool` with type `WorkflowToolRuntimeSpec` in function `core.tools.tool_manager.ToolManager.get_workflow_tool_runtime` [bad-argument-type]
- --> tests/unit_tests/core/tools/test_tool_manager.py:485:35
+ --> tests/unit_tests/core/tools/test_tool_manager.py:491:35
ERROR Argument `SimpleNamespace` is not assignable to parameter `agent_tool` with type `AgentToolEntity` in function `core.tools.tool_manager.ToolManager.get_agent_tool_runtime` [bad-argument-type]
- --> tests/unit_tests/core/tools/test_tool_manager.py:521:36
+ --> tests/unit_tests/core/tools/test_tool_manager.py:527:36
ERROR Cannot set item in `dict[str, I18nObject | None]` [unsupported-operation]
- --> tests/unit_tests/core/tools/test_tool_manager.py:627:55
+ --> tests/unit_tests/core/tools/test_tool_manager.py:633:55
ERROR `SimpleNamespace` is not assignable to attribute `entity` with type `ToolProviderEntityWithPlugin` [bad-assignment]
- --> tests/unit_tests/core/tools/test_tool_manager.py:654:32
+ --> tests/unit_tests/core/tools/test_tool_manager.py:660:32
ERROR Argument `Literal['']` is not assignable to parameter `typ` with type `Literal['api', 'builtin', 'mcp', 'workflow'] | None` in function `core.tools.tool_manager.ToolManager.list_providers_from_api` [bad-argument-type]
- --> tests/unit_tests/core/tools/test_tool_manager.py:678:97
+ --> tests/unit_tests/core/tools/test_tool_manager.py:684:97
ERROR `SimpleNamespace` is not assignable to attribute `entity` with type `ToolProviderEntityWithPlugin` [bad-assignment]
- --> tests/unit_tests/core/tools/test_tool_manager.py:820:30
+ --> tests/unit_tests/core/tools/test_tool_manager.py:826:30
ERROR `SimpleNamespace` is not assignable to attribute `entity` with type `ToolProviderEntityWithPlugin` [bad-assignment]
- --> tests/unit_tests/core/tools/test_tool_manager.py:844:30
+ --> tests/unit_tests/core/tools/test_tool_manager.py:850:30
ERROR Cannot index into `str` [bad-index]
- --> tests/unit_tests/core/tools/test_tool_manager.py:849:20
+ --> tests/unit_tests/core/tools/test_tool_manager.py:855:20
ERROR Argument `SimpleNamespace` is not assignable to parameter `controller` with type `ToolProviderController` in function `core.tools.utils.encryption.create_tool_provider_encrypter` [bad-argument-type]
--> tests/unit_tests/core/tools/utils/test_encryption.py:203:75
ERROR `None` is not subscriptable [unsupported-operation]
@@ -5931,17 +5931,17 @@
ERROR Object of class `BlobChunkMessage` has no attribute `json_object`
ERROR Object of class `BlobChunkMessage` has no attribute `json_object`
ERROR Argument `SimpleNamespace` is not assignable to parameter `db_provider` with type `WorkflowToolProvider` in function `core.tools.workflow_as_tool.provider.WorkflowToolProviderController._get_db_provider_tool` [bad-argument-type]
- --> tests/unit_tests/core/tools/workflow_as_tool/test_provider.py:93:49
+ --> tests/unit_tests/core/tools/workflow_as_tool/test_provider.py:89:49
ERROR Argument `SimpleNamespace` is not assignable to parameter `app` with type `App` in function `core.tools.workflow_as_tool.provider.WorkflowToolProviderController._get_db_provider_tool` [bad-argument-type]
- --> tests/unit_tests/core/tools/workflow_as_tool/test_provider.py:93:62
+ --> tests/unit_tests/core/tools/workflow_as_tool/test_provider.py:89:62
ERROR Argument `SimpleNamespace` is not assignable to parameter `user` with type `Account | None` in function `core.tools.workflow_as_tool.provider.WorkflowToolProviderController._get_db_provider_tool` [bad-argument-type]
- --> tests/unit_tests/core/tools/workflow_as_tool/test_provider.py:93:89
+ --> tests/unit_tests/core/tools/workflow_as_tool/test_provider.py:89:89
ERROR `not in` is not supported between `Literal['json']` and `object` [not-iterable]
- --> tests/unit_tests/core/tools/workflow_as_tool/test_provider.py:98:12
+ --> tests/unit_tests/core/tools/workflow_as_tool/test_provider.py:94:12
ERROR `list[SimpleNamespace]` is not assignable to attribute `tools` with type `list[WorkflowTool]` [bad-assignment]
- --> tests/unit_tests/core/tools/workflow_as_tool/test_provider.py:107:24
+ --> tests/unit_tests/core/tools/workflow_as_tool/test_provider.py:103:24
ERROR Argument `SimpleNamespace` is not assignable to parameter `db_provider` with type `WorkflowToolProvider` in function `core.tools.workflow_as_tool.provider.WorkflowToolProviderController.from_db` [bad-argument-type]
- --> tests/unit_tests/core/tools/workflow_as_tool/test_provider.py:153:60
+ --> tests/unit_tests/core/tools/workflow_as_tool/test_provider.py:149:60
ERROR Object of class `BlobChunkMessage` has no attribute `variable_name`
ERROR Object of class `BlobChunkMessage` has no attribute `variable_value`
ERROR Object of class `BlobChunkMessage` has no attribute `text`
@@ -6317,21 +6317,21 @@
ERROR Argument `_FakeSession` is not assignable to parameter `session` with type `Session | None` in function `core.workflow.human_input_forms.load_form_tokens_by_form_id` [bad-argument-type]
--> tests/unit_tests/core/workflow/test_human_input_forms.py:55:60
ERROR Argument `object` is not assignable to parameter `node_data_memory` with type `MemoryConfig | None` in function `core.workflow.node_factory.fetch_memory` [bad-argument-type]
- --> tests/unit_tests/core/workflow/test_node_factory.py:66:30
+ --> tests/unit_tests/core/workflow/test_node_factory.py:64:30
ERROR Argument `object` is not assignable to parameter `node_data_memory` with type `MemoryConfig | None` in function `core.workflow.node_factory.fetch_memory` [bad-argument-type]
- --> tests/unit_tests/core/workflow/test_node_factory.py:102:30
+ --> tests/unit_tests/core/workflow/test_node_factory.py:98:30
ERROR Argument `SimpleNamespace` is not assignable to parameter `graph_init_params` with type `GraphInitParams` in function `core.workflow.node_factory.DifyNodeFactory.__init__` [bad-argument-type]
- --> tests/unit_tests/core/workflow/test_node_factory.py:249:35
+ --> tests/unit_tests/core/workflow/test_node_factory.py:245:35
ERROR `SimpleNamespace` is not assignable to attribute `graph_runtime_state` with type `GraphRuntimeState` [bad-assignment]
- --> tests/unit_tests/core/workflow/test_node_factory.py:312:39
+ --> tests/unit_tests/core/workflow/test_node_factory.py:308:39
ERROR `SimpleNamespace` is not assignable to attribute `_dify_context` with type `DifyRunContext` [bad-assignment]
- --> tests/unit_tests/core/workflow/test_node_factory.py:313:33
+ --> tests/unit_tests/core/workflow/test_node_factory.py:309:33
ERROR `form_repository` may be uninitialized [unbound-name]
- --> tests/unit_tests/core/workflow/test_node_factory.py:452:49
+ --> tests/unit_tests/core/workflow/test_node_factory.py:448:49
ERROR `SimpleNamespace` is not assignable to attribute `_dify_context` with type `DifyRunContext` [bad-assignment]
- --> tests/unit_tests/core/workflow/test_node_factory.py:595:33
+ --> tests/unit_tests/core/workflow/test_node_factory.py:591:33
ERROR `SimpleNamespace` is not assignable to attribute `graph_runtime_state` with type `GraphRuntimeState` [bad-assignment]
- --> tests/unit_tests/core/workflow/test_node_factory.py:596:39
+ --> tests/unit_tests/core/workflow/test_node_factory.py:592:39
ERROR Object of class `ExternalRecipient` has no attribute `reference_id` [missing-attribute]
--> tests/unit_tests/core/workflow/test_node_runtime.py:88:12
ERROR Argument `object` is not assignable to parameter `method` with type `EmailDeliveryMethod | InteractiveSurfaceDeliveryMethod` in function `core.workflow.node_runtime.apply_dify_debug_email_recipient` [bad-argument-type]
@@ -7032,13 +7032,13 @@
ERROR Argument `None` is not assignable to parameter `plan` with type `CloudPlan` in function `RagPipelineTaskProxyTestDataFactory.create_mock_features` [bad-argument-type]
--> tests/unit_tests/services/test_rag_pipeline_task_proxy.py:431:109
ERROR Argument `dict[str, Any]` is not assignable to parameter `node_config` with type `NodeConfigDict` in function `services.trigger.schedule_service.ScheduleService.to_schedule_config` [bad-argument-type]
- --> tests/unit_tests/services/test_schedule_service.py:860:61
+ --> tests/unit_tests/services/test_schedule_service.py:855:61
ERROR Argument `dict[str, dict[str, str] | str]` is not assignable to parameter `node_config` with type `NodeConfigDict` in function `services.trigger.schedule_service.ScheduleService.to_schedule_config` [bad-argument-type]
- --> tests/unit_tests/services/test_schedule_service.py:874:56
+ --> tests/unit_tests/services/test_schedule_service.py:869:56
ERROR Argument `dict[str, dict[str, dict[str, str] | str] | str]` is not assignable to parameter `node_config` with type `NodeConfigDict` in function `services.trigger.schedule_service.ScheduleService.to_schedule_config` [bad-argument-type]
- --> tests/unit_tests/services/test_schedule_service.py:891:61
+ --> tests/unit_tests/services/test_schedule_service.py:886:61
ERROR Argument `dict[str, dict[str, str] | str]` is not assignable to parameter `node_config` with type `NodeConfigDict` in function `services.trigger.schedule_service.ScheduleService.to_schedule_config` [bad-argument-type]
- --> tests/unit_tests/services/test_schedule_service.py:903:56
+ --> tests/unit_tests/services/test_schedule_service.py:898:56
ERROR Argument `SimpleNamespace` is not assignable to parameter `value` with type `ModuleType` in function `_pytest.monkeypatch.MonkeyPatch.setitem` [bad-argument-type]
--> tests/unit_tests/services/test_summary_index_service.py:91:9
ERROR Missing required key `enable` for TypedDict `SummaryIndexSettingDict` [bad-typed-dict-key]
@@ -7174,11 +7174,11 @@
ERROR Argument `dict[str, bool]` is not assignable to parameter `substitutions` with type `Mapping[str, str]` in function `tasks.mail_inner_task._render_template_with_strategy` [bad-argument-type]
--> tests/unit_tests/tasks/test_mail_send_task.py:1300:64
ERROR Argument `Iterator[Any]` is not assignable to parameter `response_stream` with type `Generator[BaseModel | Mapping[str, Any] | str]` in function `tasks.app_generate.workflow_execute_task._publish_streaming_response` [bad-argument-type]
- --> tests/unit_tests/tasks/test_workflow_execute_task.py:55:33
+ --> tests/unit_tests/tasks/test_workflow_execute_task.py:54:33
ERROR Argument `UUID` is not assignable to parameter `workflow_run_id` with type `str` in function `tasks.app_generate.workflow_execute_task._publish_streaming_response` [bad-argument-type]
- --> tests/unit_tests/tasks/test_workflow_execute_task.py:55:50
+ --> tests/unit_tests/tasks/test_workflow_execute_task.py:54:50
ERROR Argument `Iterator[Any]` is not assignable to parameter `response_stream` with type `Generator[BaseModel | Mapping[str, Any] | str]` in function `tasks.app_generate.workflow_execute_task._publish_streaming_response` [bad-argument-type]
- --> tests/unit_tests/tasks/test_workflow_execute_task.py:65:33
+ --> tests/unit_tests/tasks/test_workflow_execute_task.py:64:33
ERROR Object of class `BlobChunkMessage` has no attribute `variable_name`
ERROR Object of class `BlobChunkMessage` has no attribute `variable_name`
ERROR Object of class `BlobChunkMessage` has no attribute `variable_value`
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Part of #24245. Migrate
Session(db.engine)+ manualsession.commit()tosessionmaker(db.engine).begin()context manager across core, models, tasks, events, schedule, and extensions modules.Continues the migration after #34379 (service_api + inner_api) and the services layer PR.
Changes
37 files across these directories:
api/core/— app logic, entities, tools, workflow nodes, RAG, ops, MCP, pluginapi/models/— model.py, account.pyapi/tasks/— rag_pipeline, app_generateapi/events/— event handlersapi/schedule/— scheduled tasksapi/extensions/— logstore repositoriesSpecific changes:
Session(db.engine)withsessionmaker(db.engine).begin()Session(db.engine, expire_on_commit=False)withsessionmaker(db.engine, expire_on_commit=False).begin()session.commit()calls (handled automatically by the context manager)session.commit()withsession.flush()where followed bysession.refresh()expire_on_commit=Falseandautoflush=Falsewhere applicablesessionmaker, remove unusedSessionimportsCloses part of #24245