galaxyproject / galaxyproject/total-perspective-vortex
Allow resources in rules evaluation (i.e., repeated reevaluation of resources)
- Dominant language
- Python
- Stars
- 18
- Forks
- 19
- Avg merge
- 4d 9h
- Merged PRs (30d)
- 5
Description
Hi,
As discussed on the matrix, I'm reporting this error:
```
galaxy.jobs.mapper ERROR 2026-02-26 13:13:20,096 [pN:handler_1,p:3301537,tN:JobHandlerQueue.monitor_thread] Caught unhandled exception while attempting to cache
job destination:
Traceback (most recent call last):
File "/srv/galaxy/server/lib/galaxy/jobs/mapper.py", line 225, in __handle_rule
job_destination = self.__invoke_expand_function(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/srv/galaxy/server/lib/galaxy/jobs/mapper.py", line 141, in __invoke_expand_function
return expand_function(**actual_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/srv/galaxy/venv/lib/python3.11/site-packages/tpv/rules/gateway.py", line 109, in map_tool_to_destination
return destination_mapper.map_to_destination(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/srv/galaxy/venv/lib/python3.11/site-packages/tpv/core/mapper.py", line 241, in map_to_destination
evaluated_entity = self.match_combine_evaluate_entities(context, tool, user)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/srv/galaxy/venv/lib/python3.11/site-packages/tpv/core/mapper.py", line 204, in match_combine_evaluate_entities
evaluated_entity = combined_entity.evaluate_rules(context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/srv/galaxy/venv/lib/python3.11/site-packages/tpv/core/entities.py", line 571, in evaluate_rules
if rule.is_matching(context):
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/srv/galaxy/venv/lib/python3.11/site-packages/tpv/core/entities.py", line 522, in is_matching
if self.evaluator.eval_code_block(str(self.if_condition), context):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/srv/galaxy/venv/lib/python3.11/site-packages/tpv/core/loader.py", line 78, in eval_code_block
return eval(eval_block, locals)
^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1, in
NameError: name 'mem' is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/srv/galaxy/server/lib/galaxy/jobs/mapper.py", line 268, in __cache_job_destination
self.cached_job_destination = self.__determine_job_destination(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/srv/galaxy/server/lib/galaxy/jobs/mapper.py", line 252, in __determine_job_destination
job_destination = self.__handle_dynamic_job_destination(raw_job_destination)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/srv/galaxy/server/lib/galaxy/jobs/mapper.py", line 215, in __handle_dynamic_job_destination
return self.__handle_rule(expand_function, destination)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/srv/galaxy/server/lib/galaxy/jobs/mapper.py", line 230, in __handle_rule
raise e
File "/srv/galaxy/server/lib/galaxy/jobs/mapper.py", line 219, in __handle_rule
job_destination = self.__invoke_expand_function(rule_function, destination)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/srv/galaxy/server/lib/galaxy/jobs/mapper.py", line 141, in __invoke_expand_function
return expand_function(**actual_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/srv/galaxy/venv/lib/python3.11/site-packages/tpv/rules/gateway.py", line 109, in map_tool_to_destination
return destination_mapper.map_to_destination(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/srv/galaxy/venv/lib/python3.11/site-packages/tpv/core/mapper.py", line 241, in map_to_destination
evaluated_entity = self.match_combine_evaluate_entities(context, tool, user)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/srv/galaxy/venv/lib/python3.11/site-packages/tpv/core/mapper.py", line 204, in match_combine_evaluate_entities
evaluated_entity = combined_entity.evaluate_rules(context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/srv/galaxy/venv/lib/python3.11/site-packages/tpv/core/entities.py", line 571, in evaluate_rules
if rule.is_matching(context):
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/srv/galaxy/venv/lib/python3.11/site-packages/tpv/core/entities.py", line 522, in is_matching
if self.evaluator.eval_code_block(str(self.if_condition), context):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/srv/galaxy/venv/lib/python3.11/site-packages/tpv/core/loader.py", line 78, in eval_code_block
return eval(eval_block, locals)
^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1, in
NameError: name 'mem' is not defined
galaxy.jobs.handler DEBUG 2026-02-26 13:13:20,113 [pN:handler_1,p:3301537,tN:JobHandlerQueue.monitor_thread] Intentionally failing job with message (Encountered an unhandled exception while caching job destination dynamic rule.)
```
The following example doesn't work, and it would be great if it could:
```
rules:
if: mem > 180
scheduling:
require:
- highmem
```
Thank you,
Martin
Contributor guide
Research direction
Start by reading tpv/core/entities.py around Rule.is_matching and evaluate_rules, then follow tpv/core/loader.py where eval_code_block receives its context. Check how resources such as mem are represented during map_to_destination in tpv/core/mapper.py. Done means the example rule can access and repeatedly reevaluate a resource value without raising NameError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100