galaxyproject / galaxyproject/total-perspective-vortex

Missing attributes for mock `Tool` during dry-run

Open
#194 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
18
Forks
19
Avg merge
4d 9h
Merged PRs (30d)
5

Description

Although this is not necessarily a bug given how TPV is designed, it is sufficiently problematic to consider finding a satisfying solution together to this problem.

On Galaxy EU, we run the TPV dry-run whenever the settings for a tool are changed as a GitHub workflow. Oftentimes, our rules, including rules applied to the default tool are complex enough to trigger edge cases caused by the discrepancies between the mock `Tool` class used during dry-runs and Galaxy's real `Tool`.

Have a look, for example, at PR [usegalaxy-eu/infrastructure-playbook#2022](https://github.com/usegalaxy-eu/infrastructure-playbook/pull/2022). It works around this error.

```python
Traceback (most recent call last):
File "/opt/hostedtoolcache/Python/3.13.13/x64/bin/tpv", line 10, in
sys.exit(main())
~~~~^^
File "/opt/hostedtoolcache/Python/3.13.13/x64/lib/python3.13/site-packages/tpv/commands/shell.py", line 238, in main
return args.func(args)
~~~~~~~~~^^^^^^
File "/opt/hostedtoolcache/Python/3.13.13/x64/lib/python3.13/site-packages/tpv/commands/shell.py", line 72, in tpv_dry_run_config_files
destination, collector = dry_runner.run(explain=explain)
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.13.13/x64/lib/python3.13/site-packages/tpv/commands/dryrunner.py", line 49, in run
destination = gateway.map_tool_to_destination(
self.galaxy_app, # type: ignore[arg-type]
...<4 lines>...
explain_collector=collector,
)
File "/opt/hostedtoolcache/Python/3.13.13/x64/lib/python3.13/site-packages/tpv/rules/gateway.py", line 125, in map_tool_to_destination
return destination_mapper.map_to_destination(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
app,
^^^^
...<6 lines>...
explain_collector=explain_collector,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/opt/hostedtoolcache/Python/3.13.13/x64/lib/python3.13/site-packages/tpv/core/mapper.py", line 350, in map_to_destination
evaluated_entity = self.match_combine_evaluate_entities(context, tool, user)
File "/opt/hostedtoolcache/Python/3.13.13/x64/lib/python3.13/site-packages/tpv/core/mapper.py", line 308, in match_combine_evaluate_entities
evaluated_entity = combined_entity.evaluate_rules(context)
File "/opt/hostedtoolcache/Python/3.13.13/x64/lib/python3.13/site-packages/tpv/core/entities.py", line 561, in evaluate_rules
if rule.is_matching(context):
~~~~~~~~~~~~~~~~^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.13.13/x64/lib/python3.13/site-packages/tpv/core/entities.py", line 511, in is_matching
if self.evaluator.eval_code_block(str(self.if_condition), context):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.13.13/x64/lib/python3.13/site-packages/tpv/core/loader.py", line 78, in eval_code_block
return eval(eval_block, locals)
File "", line 1, in
AttributeError: 'Tool' object has no attribute 'requires_galaxy_python_environment'
```

Just defining the attribute for the mock `Tool` looks like a cat and mouse game for me. Maybe we should move towards a tighter integration with Galaxy (e.g. using part of its code to read tool definition files), although I do not know if that would be lightweight enough.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.