From 66e67caa2bd1c53add238de56067246370ae6e47 Mon Sep 17 00:00:00 2001 From: Novice Date: Mon, 23 Mar 2026 09:05:37 +0800 Subject: [PATCH] fix: update core.variables imports to core.workflow.variables after S2 merge Made-with: Cursor --- MERGE_LOG.md | 45 +++++++--- api/core/llm_generator/output_models.py | 2 +- .../llm_generator/output_parser/file_ref.py | 2 +- api/core/workflow/nodes/base/node.py | 1 - api/core/workflow/nodes/file_upload/node.py | 4 +- api/core/workflow/nodes/llm/node.py | 2 +- .../output_parser/test_file_ref.py | 2 +- run_tests.sh | 90 +++++++++++++++++++ 8 files changed, 127 insertions(+), 21 deletions(-) create mode 100755 run_tests.sh diff --git a/MERGE_LOG.md b/MERGE_LOG.md index 6e829f059e..61e344a284 100644 --- a/MERGE_LOG.md +++ b/MERGE_LOG.md @@ -4,8 +4,8 @@ | Segment | Target Commit | Commits | Description | Status | |---------|--------------|---------|-------------|--------| -| 1 | `657eeb65` | 50 | Early changes: deps, Switch组件, 基础重构 | ⏳ | -| 2 | `9c339239` | 129 | Mid refactors: model_runtime 等 | ⬚ | +| 1 | `657eeb65` | 50 | Early changes: deps, Switch组件, 基础重构 | ✅ | +| 2 | `9c339239` | 129 | Mid refactors: model_runtime, prompt, storage | ✅ | | 3 | `92bde350` | 56 | dify_graph 大迁移 | ⬚ | | 4 | `fb41b215` | 165 | Post-backend refactors | ⬚ | | 5 | `main HEAD` | 103 | Final changes | ⬚ | @@ -16,20 +16,37 @@ --- -## Segment 1: Early Changes (50 commits → `657eeb65`) +## Segment 1: Early Changes (50 commits → `657eeb65`) ✅ -**Started**: +### Conflicts: 33 files +- 2 modify/delete (agent runners → keep deletion) +- 10 backend content (memory, segments, file_manager, agent_node, llm_utils, etc.) +- 19 frontend content (Switch defaultValue→value, UnoCSS icons, data-testid) +- 2 lock files (pyproject.toml, uv.lock → regenerated) -### Merge Command -```bash -git merge 657eeb65 -``` +### Post-merge fixes +- Fixed `core.file` → `core.workflow.file` imports (18 files) +- Updated Switch `defaultValue` → `value` in 5 files +- Updated `ACCOUNT_SETTING_TAB.PROVIDER` → `SANDBOX_PROVIDER`/`MODEL_PROVIDER` +- Regenerated eslint-suppressions.json, added `--pass-on-unpruned-suppressions` -### Conflicts - +### Test Results: ✅ All passed -### Resolution - +--- -### Test Results - +## Segment 2: Mid Refactors (129 commits → `9c339239`) ✅ + +### Conflicts: 43 files +- 2 modify/delete (agent runners → keep deletion) +- 14 backend content (advanced_chat, prompt, llm node, storage, variable_factory, etc.) +- 22 frontend content (chat components, citation, oauth, account-setting, hitl-input-block) +- 5 lock/config files (pyproject.toml, uv.lock, pnpm-lock, package.json, eslint-suppressions) + +### Post-merge fixes +- Rewrote `post-login-redirect.spec.ts` for new in-memory API +- Added `nodeOutputVars` parameter to hitl-input-block tests +- Updated `UpdateWorkflowNodesMapPayload` usage in tests +- Added `enable_collaboration_mode`/`enable_creators_platform` to SystemFeatures mocks +- Fixed `UPDATE_WORKFLOW_NODES_MAP` import path + +### Test Results: ⏳ Pending diff --git a/api/core/llm_generator/output_models.py b/api/core/llm_generator/output_models.py index 61430867e8..ab9af37ea7 100644 --- a/api/core/llm_generator/output_models.py +++ b/api/core/llm_generator/output_models.py @@ -2,7 +2,7 @@ from __future__ import annotations from pydantic import BaseModel, ConfigDict, Field -from core.variables.types import SegmentType +from core.workflow.variables.types import SegmentType class SuggestedQuestionsOutput(BaseModel): diff --git a/api/core/llm_generator/output_parser/file_ref.py b/api/core/llm_generator/output_parser/file_ref.py index 8a29c26b58..c0c3a24a19 100644 --- a/api/core/llm_generator/output_parser/file_ref.py +++ b/api/core/llm_generator/output_parser/file_ref.py @@ -10,7 +10,7 @@ This module provides utilities to: from collections.abc import Callable, Mapping, Sequence from typing import Any, cast -from core.variables.segments import ArrayFileSegment, FileSegment +from core.workflow.variables.segments import ArrayFileSegment, FileSegment from core.workflow.file import File FILE_PATH_FORMAT = "file-path" diff --git a/api/core/workflow/nodes/base/node.py b/api/core/workflow/nodes/base/node.py index 3a0efa2ee7..12eda2c3ce 100644 --- a/api/core/workflow/nodes/base/node.py +++ b/api/core/workflow/nodes/base/node.py @@ -360,7 +360,6 @@ class Node(Generic[NodeDataT]): if not isinstance(event, NodeRunStreamChunkEvent): yield event - def run(self) -> Generator[GraphNodeEventBase, None, None]: execution_id = self.ensure_execution_id() self._start_at = naive_utc_now() diff --git a/api/core/workflow/nodes/file_upload/node.py b/api/core/workflow/nodes/file_upload/node.py index 8d8b6eae2d..396d544fb2 100644 --- a/api/core/workflow/nodes/file_upload/node.py +++ b/api/core/workflow/nodes/file_upload/node.py @@ -6,8 +6,8 @@ from pathlib import PurePosixPath from typing import Any, cast from core.sandbox.bash.session import SANDBOX_READY_TIMEOUT -from core.variables import ArrayFileSegment -from core.variables.segments import ArrayStringSegment, FileSegment +from core.workflow.variables import ArrayFileSegment +from core.workflow.variables.segments import ArrayStringSegment, FileSegment from core.virtual_environment.__base.command_future import CommandCancelledError, CommandTimeoutError from core.virtual_environment.__base.helpers import pipeline from core.workflow.enums import NodeType, WorkflowNodeExecutionStatus diff --git a/api/core/workflow/nodes/llm/node.py b/api/core/workflow/nodes/llm/node.py index 3158ba2baa..c09d5137ef 100644 --- a/api/core/workflow/nodes/llm/node.py +++ b/api/core/workflow/nodes/llm/node.py @@ -2183,7 +2183,7 @@ class LLMNode(Node[LLMNodeData]): def _extract_prompt_files(self, variable_pool: VariablePool) -> list[File]: """Extract files from prompt template variables.""" - from core.variables import ArrayFileVariable, FileVariable + from core.workflow.variables import ArrayFileVariable, FileVariable files: list[File] = [] diff --git a/api/tests/unit_tests/core/llm_generator/output_parser/test_file_ref.py b/api/tests/unit_tests/core/llm_generator/output_parser/test_file_ref.py index 8252574999..6a83105fa6 100644 --- a/api/tests/unit_tests/core/llm_generator/output_parser/test_file_ref.py +++ b/api/tests/unit_tests/core/llm_generator/output_parser/test_file_ref.py @@ -12,7 +12,7 @@ from core.llm_generator.output_parser.file_ref import ( detect_file_path_fields, is_file_path_property, ) -from core.variables.segments import ArrayFileSegment, FileSegment +from core.workflow.variables.segments import ArrayFileSegment, FileSegment from core.workflow.file import File, FileTransferMethod, FileType diff --git a/run_tests.sh b/run_tests.sh new file mode 100755 index 0000000000..7290d4254e --- /dev/null +++ b/run_tests.sh @@ -0,0 +1,90 @@ +#!/bin/bash +set -e + +ROOT_DIR="$(cd "$(dirname "$0")" && pwd)" +cd "$ROOT_DIR" + +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +NC='\033[0m' + +usage() { + echo "Usage: $0 [backend|frontend|all]" + echo "" + echo " backend - Run backend unit tests (pytest)" + echo " frontend - Run frontend unit tests (vitest)" + echo " all - Run both (default)" + exit 1 +} + +run_backend() { + echo -e "${YELLOW}====== Backend Unit Tests ======${NC}" + echo "Start: $(date '+%H:%M:%S')" + + uv run --project api pytest api/tests/unit_tests/ \ + -q \ + --timeout=30 \ + --tb=short \ + -p no:cacheprovider \ + "$@" + + local exit_code=$? + echo "End: $(date '+%H:%M:%S')" + + if [ $exit_code -eq 0 ]; then + echo -e "${GREEN}✓ Backend tests PASSED${NC}" + else + echo -e "${RED}✗ Backend tests FAILED (exit code: $exit_code)${NC}" + fi + return $exit_code +} + +run_frontend() { + echo -e "${YELLOW}====== Frontend Unit Tests ======${NC}" + echo "Start: $(date '+%H:%M:%S')" + + cd "$ROOT_DIR/web" + pnpm test -- --run "$@" + + local exit_code=$? + cd "$ROOT_DIR" + echo "End: $(date '+%H:%M:%S')" + + if [ $exit_code -eq 0 ]; then + echo -e "${GREEN}✓ Frontend tests PASSED${NC}" + else + echo -e "${RED}✗ Frontend tests FAILED (exit code: $exit_code)${NC}" + fi + return $exit_code +} + +TARGET="${1:-all}" +shift 2>/dev/null || true + +case "$TARGET" in + backend) + run_backend "$@" + ;; + frontend) + run_frontend "$@" + ;; + all) + backend_ok=0 + frontend_ok=0 + + run_backend "$@" || backend_ok=1 + echo "" + run_frontend "$@" || frontend_ok=1 + + echo "" + echo -e "${YELLOW}====== Summary ======${NC}" + [ $backend_ok -eq 0 ] && echo -e " Backend: ${GREEN}PASSED${NC}" || echo -e " Backend: ${RED}FAILED${NC}" + [ $frontend_ok -eq 0 ] && echo -e " Frontend: ${GREEN}PASSED${NC}" || echo -e " Frontend: ${RED}FAILED${NC}" + + [ $backend_ok -eq 0 ] && [ $frontend_ok -eq 0 ] && exit 0 || exit 1 + ;; + *) + usage + ;; +esac