From 0662486bbd7359ec1bd2fbb4e84e974c7cd5140b Mon Sep 17 00:00:00 2001 From: cat-bro Date: Wed, 26 Apr 2023 02:06:15 +1000 Subject: [PATCH 1/2] Add failing test for dry_run with tool version rule --- tests/fixtures/mapping-rules.yml | 5 +++++ tests/test_shell.py | 11 +++++++++++ tpv/commands/dryrunner.py | 4 ++++ 3 files changed, 20 insertions(+) diff --git a/tests/fixtures/mapping-rules.yml b/tests/fixtures/mapping-rules.yml index 77b31ee..be5e53e 100644 --- a/tests/fixtures/mapping-rules.yml +++ b/tests/fixtures/mapping-rules.yml @@ -33,6 +33,11 @@ tools: - highmem - if: input_size >= 20 fail: Too much data, shouldn't run + toolshed.g2.bx.psu.edu/repos/iuc/bwameth/bwameth/.*: + rules: + - if: helpers.tool_version_gte(tool, '42') + env: + bwameth_is_great: yes users: fairycake@vortex.org: env: diff --git a/tests/test_shell.py b/tests/test_shell.py index 2ecbaed..d90c118 100644 --- a/tests/test_shell.py +++ b/tests/test_shell.py @@ -289,3 +289,14 @@ def test_dry_run_user_email(self): tpv_config) self.assertTrue("name: TEST_JOB_SLOTS_USER" in output, f"Expected 'name: TEST_JOB_SLOTS_USER' in destination\n{output}") + + def test_dry_run_tool_with_version(self): + job_config = os.path.join(os.path.dirname(__file__), 'fixtures/job_conf_dry_run.yml') + tpv_config = os.path.join(os.path.dirname(__file__), 'fixtures/mapping-rules.yml') + output = self.call_shell_command( + "tpv", "dry-run", "--job-conf", job_config, "--input-size", "6", "--user", "krikkitrobot@planetkrikkit.org", + "--tool", "toolshed.g2.bx.psu.edu/repos/iuc/bwameth/bwameth/42", + tpv_config) + self.assertTrue("bwameth_is_great" in output, + f"Expected 'bwameth_is_great' in destination\n{output}") + diff --git a/tpv/commands/dryrunner.py b/tpv/commands/dryrunner.py index deee0f3..5e6b07f 100644 --- a/tpv/commands/dryrunner.py +++ b/tpv/commands/dryrunner.py @@ -30,6 +30,10 @@ def from_params(job_conf, user=None, tool=None, tpv_confs=None, input_size=None) if tool: tool = mock_galaxy.Tool(tool) + # tool = mock_galaxy.Tool( + # tool, + # version=tool.split('/')[-1] if '/' in tool else '0._unversioned' + # ) else: tool = None From c2f28b9596d12c2d15cc953b3564a83c069d1dd2 Mon Sep 17 00:00:00 2001 From: cat-bro Date: Wed, 26 Apr 2023 02:08:36 +1000 Subject: [PATCH 2/2] Add tool version to dry-run --- tpv/commands/dryrunner.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tpv/commands/dryrunner.py b/tpv/commands/dryrunner.py index 5e6b07f..111bf04 100644 --- a/tpv/commands/dryrunner.py +++ b/tpv/commands/dryrunner.py @@ -29,11 +29,10 @@ def from_params(job_conf, user=None, tool=None, tpv_confs=None, input_size=None) user = None if tool: - tool = mock_galaxy.Tool(tool) - # tool = mock_galaxy.Tool( - # tool, - # version=tool.split('/')[-1] if '/' in tool else '0._unversioned' - # ) + tool = mock_galaxy.Tool( + tool, + version=tool.split('/')[-1] if '/' in tool else None + ) else: tool = None