Files
galaxy/test/unit/app/tools/test_remote_tool_eval.py
davelopez 8e27a75a1c Keep failure handling for remote_tool_eval errors
Run remote_tool_eval failures through the regular stream-error path so
resubmission handlers still apply and readable streams and stdio job
messages are kept. Record the exception chain and traceback in a
structured error file, surfacing the root cause (e.g. the Cheetah
NotFound behind ToolTemplatingException) and storing the traceback on
the job. Remove a stale error file left by an earlier attempt.
2026-10-13 13:03:08 +02:00

45 lines
1.4 KiB
Python

import json
import pytest
from galaxy.tools import remote_tool_eval
@pytest.fixture
def job_directory(tmp_path, monkeypatch):
(tmp_path / "working").mkdir()
monkeypatch.chdir(tmp_path)
return tmp_path
def error_file(job_directory):
return job_directory / "metadata" / "outputs_populated" / "remote_tool_eval_error.json"
def test_failure_writes_error_with_cause(job_directory, monkeypatch):
def evaluate_tool(*args):
try:
raise KeyError("out_file2")
except KeyError as e:
raise RuntimeError("Error occurred while building command line") from e
monkeypatch.setattr(remote_tool_eval, "evaluate_tool", evaluate_tool)
with pytest.raises(RuntimeError):
remote_tool_eval.main()
error = json.loads(error_file(job_directory).read_text())
assert error["message"] == "Error occurred while building command line <- KeyError: 'out_file2'"
assert "KeyError" in error["traceback"]
assert (job_directory / "metadata" / "outputs_populated" / "traceback.txt").exists()
def test_success_removes_stale_error(job_directory, monkeypatch):
error_file(job_directory).parent.mkdir(parents=True)
error_file(job_directory).write_text("{}")
monkeypatch.setattr(remote_tool_eval, "evaluate_tool", lambda *args: None)
remote_tool_eval.main()
assert not error_file(job_directory).exists()