拓展分析运行已发布时个别样例报前缀不对的问题
This commit is contained in:
@@ -1039,6 +1039,77 @@ def test_symlink_runtime_input_keeps_its_lexical_new_name(
|
||||
assert (tmp_path / "run/work/output.output.txt").read_text(encoding="utf-8") == "value\n"
|
||||
|
||||
|
||||
def test_input_derived_output_prefix_renames_participating_input(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
raw_code = tmp_path / "raw_code"
|
||||
runtime_input = _write(
|
||||
tmp_path,
|
||||
"runtime/Ft.SPL.pep.fasta",
|
||||
">a\nAAA\n>b\nBBB\n>c\nCCC\n",
|
||||
)
|
||||
# seqkit split derives output names from the input basename; the input
|
||||
# literal appears once and the output paths never appear verbatim.
|
||||
script = (
|
||||
"mkparts() {\n"
|
||||
" local in=\"$1\" outdir=\"$2\" base\n"
|
||||
" base=\"$(basename \"$in\" .fasta)\"\n"
|
||||
" mkdir -p \"$outdir\"\n"
|
||||
" head -n 2 \"$in\" > \"$outdir/${base}.part_001.fasta\"\n"
|
||||
" sed -n '3,4p' \"$in\" > \"$outdir/${base}.part_002.fasta\"\n"
|
||||
" sed -n '5,$p' \"$in\" > \"$outdir/${base}.part_003.fasta\"\n"
|
||||
"}\n"
|
||||
"mkparts Ft.SPL.pep.fasta split_fasta\n"
|
||||
)
|
||||
script_hash = _sha256_bytes(script.encode())
|
||||
outputs = [
|
||||
{
|
||||
"fact_id": f"output:file:{i:03d}",
|
||||
"original_path": f"split_fasta/Ft.SPL.pep.part_{i:03d}.fasta",
|
||||
"transformed": True,
|
||||
}
|
||||
for i in (1, 2, 3)
|
||||
]
|
||||
contract, resolved = _contract_and_resolved(
|
||||
raw_code,
|
||||
runtime_input,
|
||||
script=script,
|
||||
original_input="Ft.SPL.pep.fasta",
|
||||
output_bindings=outputs,
|
||||
patch_targets=[
|
||||
_target(
|
||||
binding_key="path:Ft.SPL.pep.fasta",
|
||||
literal="Ft.SPL.pep.fasta",
|
||||
kind="input_path",
|
||||
script_hash=script_hash,
|
||||
fact_ids=["input:1"],
|
||||
)
|
||||
],
|
||||
)
|
||||
|
||||
rendered = render_runtime_package(
|
||||
contract, raw_code, resolved, tmp_path / "run"
|
||||
)
|
||||
|
||||
assert resolved["prefix_binding"]["old_prefix"] == "Ft.SPL.pep"
|
||||
assert {item["runtime_path"] for item in rendered["expected_outputs"]} == {
|
||||
"split_fasta/output.part_001.fasta",
|
||||
"split_fasta/output.part_002.fasta",
|
||||
"split_fasta/output.part_003.fasta",
|
||||
}
|
||||
patched = (tmp_path / "run/work/run.sh").read_text(encoding="utf-8")
|
||||
assert "mkparts output.fasta split_fasta" in patched
|
||||
assert (tmp_path / "run/work/output.fasta").is_symlink()
|
||||
|
||||
result = replay_runtime_binding(rendered)
|
||||
assert result["contract_passed"] is True
|
||||
assert {item["runtime_path"] for item in result["outputs"]} == {
|
||||
"split_fasta/output.part_001.fasta",
|
||||
"split_fasta/output.part_002.fasta",
|
||||
"split_fasta/output.part_003.fasta",
|
||||
}
|
||||
|
||||
|
||||
def test_explicit_output_reference_covers_its_implicit_multi_outputs(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
|
||||
Reference in New Issue
Block a user