|
2 | 2 |
|
3 | 3 | import os |
4 | 4 |
|
| 5 | +import yaml |
| 6 | + |
5 | 7 | from galaxy.tool_util_models import UserToolSource |
6 | 8 | from galaxy_test.api.test_tools import TestsTools |
7 | 9 | from galaxy_test.base.populators import ( |
|
12 | 14 |
|
13 | 15 | SCRIPT_DIRECTORY = os.path.abspath(os.path.dirname(__file__)) |
14 | 16 | EMBEDDED_PULSAR_JOB_CONFIG_FILE = os.path.join(SCRIPT_DIRECTORY, "embedded_pulsar_job_conf.yml") |
| 17 | +EMBEDDED_PULSAR_TPV_JOB_CONFIG_FILE = os.path.join(SCRIPT_DIRECTORY, "embedded_pulsar_tpv_job_conf.yml") |
| 18 | +TOOL_WITH_RESOURCE_SPECIFICATION = yaml.safe_load( |
| 19 | + """class: GalaxyUserTool |
| 20 | +id: resource_requirement |
| 21 | +version: "0.1" |
| 22 | +name: resource_requirement |
| 23 | +description: test resource requirement |
| 24 | +container: busybox |
| 25 | +requirements: |
| 26 | + - type: resource |
| 27 | + cores_min: 2 |
| 28 | +shell_command: | |
| 29 | + echo $GALAXY_SLOTS > galaxy_cores.txt |
| 30 | +outputs: |
| 31 | + - name: output2 |
| 32 | + type: data |
| 33 | + format: txt |
| 34 | + from_work_dir: galaxy_cores.txt |
| 35 | +""" |
| 36 | +) |
15 | 37 |
|
16 | 38 |
|
17 | 39 | class TestUserDefinedToolRecommendedJobSetup(integration_util.IntegrationTestCase, TestsTools): |
18 | 40 | """Exercies how user defined tools could be run in production.""" |
19 | 41 |
|
20 | 42 | framework_tool_and_types = True |
| 43 | + job_config_file = EMBEDDED_PULSAR_JOB_CONFIG_FILE |
21 | 44 | dataset_populator: DatasetPopulator |
22 | 45 |
|
23 | 46 | @classmethod |
24 | 47 | def handle_galaxy_config_kwds(cls, config): |
25 | 48 | super().handle_galaxy_config_kwds(config) |
26 | | - config["job_config_file"] = EMBEDDED_PULSAR_JOB_CONFIG_FILE |
| 49 | + config["job_config_file"] = cls.job_config_file |
27 | 50 | config["enable_celery_tasks"] = False |
28 | 51 | config["metadata_strategy"] = "directory" |
29 | 52 | config[ "admin_users"] = "[email protected]" |
@@ -57,3 +80,30 @@ def test_user_defined_runs_in_correct_destination(self): |
57 | 80 |
|
58 | 81 | assert destination_params["Runner"] == "pulsar_embed" |
59 | 82 | assert destination_params["require_container"] |
| 83 | + |
| 84 | + |
| 85 | +class TestUserDefinedToolRecommendedJobSetupTPV(TestUserDefinedToolRecommendedJobSetup): |
| 86 | + |
| 87 | + job_config_file = EMBEDDED_PULSAR_TPV_JOB_CONFIG_FILE |
| 88 | + |
| 89 | + def test_user_defined_applies_resource_requirements(self): |
| 90 | + with ( |
| 91 | + self.dataset_populator.test_history() as history_id, |
| 92 | + self.dataset_populator.user_tool_execute_permissions(), |
| 93 | + ): |
| 94 | + # Create a new dynamic tool. |
| 95 | + # This is a shell command tool that will echo the input dataset. |
| 96 | + dynamic_tool = self.dataset_populator.create_unprivileged_tool( |
| 97 | + UserToolSource(**TOOL_WITH_RESOURCE_SPECIFICATION) |
| 98 | + ) |
| 99 | + # Run tool. |
| 100 | + response = self._run( |
| 101 | + history_id=history_id, |
| 102 | + tool_uuid=dynamic_tool["uuid"], |
| 103 | + inputs={}, |
| 104 | + wait_for_job=True, |
| 105 | + assert_ok=True, |
| 106 | + ) |
| 107 | + cores = response["outputs"][0] |
| 108 | + cores_content = self.dataset_populator.get_history_dataset_content(history_id, content_id=cores["id"]) |
| 109 | + assert cores_content == "2.0\n" |
0 commit comments