所有测试和 main.py 已切到新 import 后,删除旧路径 shim 文件。
grep -r "from backend\\.\\(scripts\\|resources\\|auth\\|jupyter\\|platform\\|admin\\|schedules\\|schedule_runs\\|runtime_client\\|rclone_rc_client\\|schedule_client\\|schedule_schemas\\|schemas\\|storage_api\\|dependencies\\|audit\\)" backend/
pytest backend/tests -q
compileall
Task: crzkkz9si8d3p2loxi70j443
tao.chen commented:
阶段4 完成:shim 全部删除,测试 import 统一到新路径,父任务 #48 整体 done。
Shim 删除清单(14 个平铺 shim + 1 个 schemas/__init__.py)
backend/src/backend/{admin,auth,dependencies,jupyter,platform,rclone_rc_client,resources,runtime_client,schedule_client,schedule_runs,schedule_schemas,schedules,scripts,storage_api}.py
backend/src/backend/schemas/__init__.py
保留
audit.py
backend.audit.configure_audit_logging
main.py
__init__.py
测试 import 迁移(5 个 test 文件)
test_list_scripts_parent_path.py
backend.scripts.*
backend.api.scripts.*
test_count_scripts.py
test_scripts.py
backend.resources.*
backend.jupyter.*
backend.schemas.UpdateScriptRequest
test_resources.py
test_runtime_client_directories.py
backend.runtime_client.*
backend.clients.runtime.*
按 CLAUDE.md "Mock patch() string targets... rewrite every hit" 教训,所有 monkeypatch.setattr 字符串参数已在阶段1迁到 backend.api.scripts.*;本次阶段4没再改它们。
monkeypatch.setattr
最终结构
backend/src/backend/ ├── __init__.py ├── audit.py ├── main.py ├── api/ │ ├── admin.py, auth.py, dependencies.py, jupyter.py, platform.py │ ├── resources.py, scripts.py, storage.py │ └── schedules/{schedules.py, runs.py} ├── schemas/ │ ├── auth.py, common.py, jupyter.py, platform.py │ ├── resources.py, schedules.py, scripts.py ├── services/ │ └── storage.py, schedules.py(已下沉 validate_dag) ├── clients/ │ └── rclone.py, runtime.py, scheduler.py
验证
uv run python -m compileall backend/src backend/tests
uv run --package backend pytest backend/tests -q
grep -r 'from backend\.\(scripts\|resources\|...\)' backend/
backend.services.schedules.validate_dag
最终迁移摘要
遗留
cron_preview
validate_script_content
compute_jupyter_relative_path
can_view
No dependencies set.
The note is not visible to the blocked user.
范围(L1 风险)
所有测试和 main.py 已切到新 import 后,删除旧路径 shim 文件。
验收
grep -r "from backend\\.\\(scripts\\|resources\\|auth\\|jupyter\\|platform\\|admin\\|schedules\\|schedule_runs\\|runtime_client\\|rclone_rc_client\\|schedule_client\\|schedule_schemas\\|schemas\\|storage_api\\|dependencies\\|audit\\)" backend/全部 0 命中pytest backend/tests -q全绿compileall无错Task: crzkkz9si8d3p2loxi70j443
tao.chen commented:
Shim 删除清单(14 个平铺 shim + 1 个 schemas/__init__.py)
backend/src/backend/{admin,auth,dependencies,jupyter,platform,rclone_rc_client,resources,runtime_client,schedule_client,schedule_runs,schedule_schemas,schedules,scripts,storage_api}.pybackend/src/backend/schemas/__init__.py保留
audit.py— 实际代码(main.py 引用backend.audit.configure_audit_logging)main.py— 应用入口__init__.py— 包标记测试 import 迁移(5 个 test 文件)
test_list_scripts_parent_path.py—backend.scripts.*→backend.api.scripts.*(6 处)test_count_scripts.py— 同上(2 处)test_scripts.py—backend.scripts.*/backend.resources.*/backend.jupyter.*/backend.schemas.UpdateScriptRequest(11 处)test_resources.py—backend.resources.*(12 处)test_runtime_client_directories.py—backend.runtime_client.*→backend.clients.runtime.*(1 处)按 CLAUDE.md "Mock patch() string targets... rewrite every hit" 教训,所有
monkeypatch.setattr字符串参数已在阶段1迁到backend.api.scripts.*;本次阶段4没再改它们。最终结构
验证
uv run python -m compileall backend/src backend/tests零错误uv run --package backend pytest backend/tests -q→ 122 passedgrep -r 'from backend\.\(scripts\|resources\|...\)' backend/0 命中backend.services.schedules.validate_dag仍被 8 个新 unit test 覆盖最终迁移摘要
遗留
cron_preview/validate_script_content/compute_jupyter_relative_path/can_view等下沉 task 可开新 PR