-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from galaxyproject/add_local_context
Add support for defining local contexts
- Loading branch information
Showing
4 changed files
with
128 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
global: | ||
default_inherits: default | ||
context: | ||
small_jpb_cores: 1 | ||
medium_job_cores: 2 | ||
large_job_cores: 4 | ||
small_input_size: 2 | ||
medium_input_size: 10 | ||
large_input_size: 20 | ||
|
||
tools: | ||
default: | ||
context: | ||
medium_job_cores: 3 | ||
medium_input_size: 12 | ||
cores: medium_job_cores | ||
mem: cores * 3 | ||
gpus: 1 | ||
env: | ||
TEST_JOB_SLOTS: "{cores}" | ||
params: | ||
native_spec: "--mem {mem} --cores {cores} --gpus {gpus}" | ||
scheduling: | ||
require: [] | ||
prefer: | ||
- general | ||
accept: | ||
reject: | ||
- pulsar | ||
rules: | ||
- if: input_size < small_input_size | ||
fail: We don't run piddling datasets | ||
bwa: | ||
context: | ||
medium_job_cores: 5 | ||
gpus: 2 | ||
scheduling: | ||
require: | ||
- pulsar | ||
rules: | ||
- if: input_size <= medium_input_size | ||
gpus: 4 | ||
- if: input_size >= large_input_size | ||
fail: Too much data, shouldn't run | ||
trinity: | ||
gpus: 3 | ||
|
||
destinations: | ||
local: | ||
cores: 4 | ||
mem: 16 | ||
scheduling: | ||
prefer: | ||
- general | ||
k8s_environment: | ||
cores: 16 | ||
mem: 64 | ||
gpus: 5 | ||
scheduling: | ||
prefer: | ||
- pulsar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import os | ||
import unittest | ||
from tpv.rules import gateway | ||
from . import mock_galaxy | ||
from tpv.core.loader import InvalidParentException | ||
|
||
|
||
class TestMapperContext(unittest.TestCase): | ||
|
||
@staticmethod | ||
def _map_to_destination(tool, user, datasets, tpv_config_path=None): | ||
galaxy_app = mock_galaxy.App() | ||
job = mock_galaxy.Job() | ||
for d in datasets: | ||
job.add_input_dataset(d) | ||
tpv_config = tpv_config_path or os.path.join(os.path.dirname(__file__), | ||
'fixtures/mapping-context.yml') | ||
gateway.ACTIVE_DESTINATION_MAPPER = None | ||
return gateway.map_tool_to_destination(galaxy_app, job, tool, user, tpv_config_files=[tpv_config]) | ||
|
||
def test_map_context_default_overrides_global(self): | ||
tool = mock_galaxy.Tool('trinity') | ||
user = mock_galaxy.User('gargravarr', '[email protected]') | ||
datasets = [mock_galaxy.DatasetAssociation("test", mock_galaxy.Dataset("test.txt", file_size=5*1024**3))] | ||
|
||
destination = self._map_to_destination(tool, user, datasets) | ||
self.assertEqual(destination.id, "local") | ||
self.assertEqual([env['value'] for env in destination.env if env['name'] == 'TEST_JOB_SLOTS'], ['3']) | ||
self.assertEqual(destination.params['native_spec'], '--mem 9 --cores 3 --gpus 3') | ||
|
||
def test_map_tool_overrides_default(self): | ||
tool = mock_galaxy.Tool('bwa') | ||
user = mock_galaxy.User('gargravarr', '[email protected]') | ||
datasets = [mock_galaxy.DatasetAssociation("test", mock_galaxy.Dataset("test.txt", file_size=5*1024**3))] | ||
|
||
destination = self._map_to_destination(tool, user, datasets) | ||
self.assertEqual(destination.id, "k8s_environment") | ||
self.assertEqual([env['value'] for env in destination.env if env['name'] == 'TEST_JOB_SLOTS'], ['5']) | ||
self.assertEqual(destination.params['native_spec'], '--mem 15 --cores 5 --gpus 4') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters