From 6a4db21891b88beb78c67db5c36a217b7daf904f Mon Sep 17 00:00:00 2001 From: potaser Date: Sat, 29 Aug 2026 23:30:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E5=99=A8=E6=B5=8B=E8=AF=95=E6=95=B0=E6=8D=AE=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E5=AF=BC=E5=85=A5=E4=BF=9D=E7=95=99=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=20basename=EF=BC=88proteomes/=20=E5=B1=82=E7=BA=A7?= =?UTF-8?q?=E4=B8=8D=E5=86=8D=E4=B8=A2=E5=A4=B1=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gfa_core/extension_stage_lightweight/api.py | 2 +- .../test_extension_stage_lightweight_api.py | 28 +++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/gfa_core/extension_stage_lightweight/api.py b/gfa_core/extension_stage_lightweight/api.py index d57108ac8..11f94800e 100644 --- a/gfa_core/extension_stage_lightweight/api.py +++ b/gfa_core/extension_stage_lightweight/api.py @@ -68,7 +68,7 @@ def _server_data_files(value: str | None) -> list[tuple[Path, Path]]: if not source.is_dir(): raise ValueError(f"测试数据路径不是普通文件或目录:{text}") files.extend( - (item.relative_to(source), item.resolve()) + (item.relative_to(source.parent), item.resolve()) for item in sorted(source.rglob("*")) if item.is_file() ) diff --git a/tests/unit/test_extension_stage_lightweight_api.py b/tests/unit/test_extension_stage_lightweight_api.py index 5ab656ad7..84cfaf349 100644 --- a/tests/unit/test_extension_stage_lightweight_api.py +++ b/tests/unit/test_extension_stage_lightweight_api.py @@ -272,8 +272,32 @@ def test_upload_expands_server_data_directory_preserving_relative_layout(tmp_pat assert response.status_code == 202 assert len(queued) == 1 staged = tmp_path / "store" / "staging" / "upload-server-directory" / "raw_test_data" - assert (staged / "input.fa").is_symlink() - assert (staged / "nested" / "model.hmm").is_symlink() + assert (staged / "large_case" / "input.fa").is_symlink() + assert (staged / "large_case" / "nested" / "model.hmm").is_symlink() + + +def test_upload_server_data_directory_keeps_basename_for_flat_tool_input(tmp_path: Path) -> None: + """目录导入保留目录名本身:run.sh 里写死 -f proteomes 时数据必须落在 proteomes/ 下。""" + client, queued = _client(tmp_path) + source = tmp_path / "proteomes" + source.mkdir() + (source / "01.col.fa").write_text(">a\nAAAA\n", encoding="utf-8") + (source / "02.tibet.fa").write_text(">b\nBBBB\n", encoding="utf-8") + + response = client.post( + "/api/lightweight-extension-stages/upload", + data={ + "extension_id": "flat_tool_input", + "original_command": "ls proteomes", + "operation_token": "upload-flat-tool-input", + "raw_data_paths": str(source), + }, + ) + + assert response.status_code == 202 + staged = tmp_path / "store" / "staging" / "upload-flat-tool-input" / "raw_test_data" + assert (staged / "proteomes" / "01.col.fa").is_symlink() + assert (staged / "proteomes" / "02.tibet.fa").is_symlink() def test_upload_rejects_missing_server_data_path(tmp_path: Path) -> None: