Skip to content

Commit

Permalink
Merge pull request #93 from cat-bro/failing-test-for-pulsar-user-scen…
Browse files Browse the repository at this point in the history
…ario

Failing test for pulsar user scenario
  • Loading branch information
nuwang authored Apr 25, 2023
2 parents 537bc67 + 6f3ba54 commit 3ab3f20
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/topics/tpv_by_example.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ at each destination (optional). The tools are matched by tool id, and can be a r
resource requirements can also be computed as python expressions. If resource requirements are defined at the
destination, TPV will check whether the job will fit. For example, hisat2 will not schedule on `general_pulsar_1`
as it has insufficient cores. If resource requirements are omitted in the tool or destination, it is considered a match.
Note that TPV only considers destinations defined in its own config file, and ignore destinations in job_conf.yml.
Note that TPV only considers destinations defined in its own config file, and ignores destinations in job_conf.yml.

Default inheritance
-------------------
Expand Down
24 changes: 24 additions & 0 deletions tests/fixtures/mapping-destinations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,19 @@ tools:
accept:
reject:
- pulsar
- offline
rules:
- if: input_size < 2
fail: Data size too small
bwa:
scheduling:
require:
- pulsar
toolshed_hifiasm:
cores: 1000
rules:
- if: input_size < 1000
cores: 2
inheritance_test_tool:
scheduling:
accept:
Expand Down Expand Up @@ -100,6 +106,18 @@ tools:
require:
- test_of_min_mem_accepted

users:
[email protected]:
rules:
- id: pulsar_user_mapping_rule
if: tool.id.startswith('toolshed') or tool.id.startswith('testtoolshed')
scheduling:
accept:
- pulsar # pulsar must be in require/prefer/accept for a job to be scheduled to pulsar
- offline # allow scheduling to a destination even when it is offline
require:
- pulsar-canberra

destinations:
local:
runner: local
Expand Down Expand Up @@ -240,3 +258,9 @@ destinations:
scheduling:
require:
- test_of_min_mem_accepted
pulsar-canberra:
runner: k8s
max_accepted_cores: 32
scheduling:
accept:
- pulsar-canberra
10 changes: 10 additions & 0 deletions tests/test_mapper_destinations.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,13 @@ def test_min_accepted_mem_honoured(self):
tool = mock_galaxy.Tool('tool_for_testing_min_mem_acceptance_match')
destination = self._map_to_destination(tool, user, datasets, tpv_config_paths=[config])
self.assertEqual(destination.id, "destination_with_min_mem_accepted")

def test_user_map_to_destination_accepting_offline(self):
user = mock_galaxy.User('albo', '[email protected]')

config = os.path.join(os.path.dirname(__file__), 'fixtures/mapping-destinations.yml')

tool = mock_galaxy.Tool('toolshed_hifiasm')
datasets = [mock_galaxy.DatasetAssociation("test", mock_galaxy.Dataset("test.txt", file_size=12 * 1024 ** 3))]
destination = self._map_to_destination(tool, user, datasets, tpv_config_paths=[config])
self.assertEqual(destination.id, "pulsar-canberra")
6 changes: 3 additions & 3 deletions tpv/core/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,9 +485,9 @@ def evaluate(self, context):
if rule.is_matching(context):
rule = rule.evaluate(context)
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.gpus = rule.gpus or new_entity.gpus
new_entity.cores = rule.cores or new_entity.cores
new_entity.mem = rule.mem or new_entity.mem
new_entity.id = f"{new_entity.id}, Rule: {rule.id}"
context.update({
'entity': new_entity
Expand Down

0 comments on commit 3ab3f20

Please sign in to comment.