Skip to content

Commit

Permalink
Merge pull request #89 from cat-bro/show-fastqc-with-rules
Browse files Browse the repository at this point in the history
If a tool has file size rules, a role rule has no access to tool's scheduling tags
  • Loading branch information
nuwang authored Mar 30, 2023
2 parents 6ed8098 + 6e5a702 commit 060ff9e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
17 changes: 17 additions & 0 deletions tests/fixtures/mapping-role.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,23 @@ tools:
- pulsar-training-large
require:
- pulsar
fastqc:
cores: 8
mem: 30.7
env:
_JAVA_OPTIONS: -Xmx{int(mem)}G -Xms1G
scheduling:
require:
- pulsar
rules:
- id: fastqc_small_input_rule
if: input_size < 0.01
cores: 2
mem: 7.6
- id: fastqc_medium_input_rule
if: 0.01 <= input_size < 2
cores: 4
mem: 15.3
users:
default:
max_cores: 3
Expand Down
2 changes: 1 addition & 1 deletion tests/test_mapper_role.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def test_map_role_training_matching_tag_values(self):
self.assertEqual(destination.params['native_spec'], '--mem 1 --cores 1')

# test training small pulsar rule
tool = mock_galaxy.Tool('bwa')
tool = mock_galaxy.Tool('fastqc')
destination = self._map_to_destination(tool, user)
self.assertEqual(destination.params['native_spec'], '--mem 2 --cores 2')

Expand Down
6 changes: 3 additions & 3 deletions tpv/core/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,14 +484,14 @@ def evaluate(self, context):
for rule in self.rules.values():
if rule.is_matching(context):
rule = rule.evaluate(context)
context.update({
'entity': rule
})
new_entity = rule.inherit(new_entity)
new_entity.gpus = rule.gpus or self.gpus
new_entity.cores = rule.cores or self.cores
new_entity.mem = rule.mem or self.mem
new_entity.id = f"{new_entity.id}, Rule: {rule.id}"
context.update({
'entity': new_entity
})
return super(EntityWithRules, new_entity).evaluate(context)

def __repr__(self):
Expand Down

0 comments on commit 060ff9e

Please sign in to comment.