mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Merge pull request #3319 from jmchilton/job_resubmission_refinement_0
Make it easier to use job re-submission conditions.
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
Slimmed down resubmission_job_conf.xml for testing default resubmission rules.
|
||||
-->
|
||||
<job_conf>
|
||||
<plugins>
|
||||
<plugin id="local" type="runner" load="galaxy.jobs.runners.local:LocalJobRunner" workers="2"/>
|
||||
<plugin id="first_failure_runner" type="runner" load="integration.resubmission_runners:FailOnlyFirstJobRunner" workers="2">
|
||||
</plugin>
|
||||
<plugin id="dynamic" type="runner">
|
||||
<param id="rules_module">integration.resubmission_rules</param>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
<handlers>
|
||||
<handler id="main"/>
|
||||
</handlers>
|
||||
|
||||
<destinations default="initial_destination">
|
||||
<destination id="initial_destination" runner="dynamic">
|
||||
<param id="type">python</param>
|
||||
<param id="function">initial_destination</param>
|
||||
</destination>
|
||||
|
||||
<destination id="fail_first_try" runner="first_failure_runner">
|
||||
</destination>
|
||||
|
||||
<!-- Upload destination. -->
|
||||
<destination id="local" runner="local">
|
||||
</destination>
|
||||
|
||||
</destinations>
|
||||
|
||||
<resources default="test">
|
||||
<group id="upload"></group>
|
||||
<group id="test">test_name,failure_state,initial_destination,run_for</group>
|
||||
</resources>
|
||||
|
||||
<tools>
|
||||
<tool id="upload1" destination="local" resources="upload" />
|
||||
</tools>
|
||||
|
||||
</job_conf>
|
||||
@@ -63,4 +63,24 @@ class AssertionJobRunner(LocalJobRunner):
|
||||
super(AssertionJobRunner, self).queue_job(job_wrapper)
|
||||
|
||||
|
||||
class FailOnlyFirstJobRunner(LocalJobRunner):
|
||||
"""Job runner that knows about test cases and checks final state assumptions."""
|
||||
|
||||
tests_seen = []
|
||||
|
||||
def queue_job(self, job_wrapper):
|
||||
resource_parameters = job_wrapper.get_resource_parameters()
|
||||
try:
|
||||
test_name = resource_parameters["test_name"]
|
||||
except KeyError:
|
||||
job_wrapper.fail("Job resource parameter test_name not set as required for this job runner.")
|
||||
return
|
||||
|
||||
if test_name in self.tests_seen:
|
||||
super(FailOnlyFirstJobRunner, self).queue_job(job_wrapper)
|
||||
else:
|
||||
self.tests_seen.append(test_name)
|
||||
self._fail_job_local(job_wrapper, "Failing first attempt")
|
||||
|
||||
|
||||
__all__ = ('FailsJobRunner', 'AssertionJobRunner')
|
||||
|
||||
@@ -6,10 +6,27 @@ from base import integration_util
|
||||
|
||||
SCRIPT_DIRECTORY = os.path.abspath(os.path.dirname(__file__))
|
||||
JOB_RESUBMISSION_JOB_CONFIG_FILE = os.path.join(SCRIPT_DIRECTORY, "resubmission_job_conf.xml")
|
||||
JOB_RESUBMISSION_DEFAULT_JOB_CONFIG_FILE = os.path.join(SCRIPT_DIRECTORY, "resubmission_default_job_conf.xml")
|
||||
JOB_RESUBMISSION_JOB_RESOURCES_CONFIG_FILE = os.path.join(SCRIPT_DIRECTORY, "resubmission_job_resource_parameters_conf.xml")
|
||||
|
||||
|
||||
class JobResubmissionIntegrationTestCase(integration_util.IntegrationTestCase):
|
||||
class _BaseResubmissionIntegerationTestCase(integration_util.IntegrationTestCase):
|
||||
framework_tool_and_types = True
|
||||
|
||||
def _assert_job_passes(self, resource_parameters):
|
||||
self._run_tool_test("simple_constructs", resource_parameters=resource_parameters)
|
||||
|
||||
def _assert_job_fails(self, resource_parameters):
|
||||
exception_thrown = False
|
||||
try:
|
||||
self._run_tool_test("simple_constructs", resource_parameters=resource_parameters)
|
||||
except Exception:
|
||||
exception_thrown = True
|
||||
|
||||
assert exception_thrown
|
||||
|
||||
|
||||
class JobResubmissionIntegrationTestCase(_BaseResubmissionIntegerationTestCase):
|
||||
|
||||
framework_tool_and_types = True
|
||||
|
||||
@@ -85,14 +102,16 @@ class JobResubmissionIntegrationTestCase(integration_util.IntegrationTestCase):
|
||||
"initial_destination": "resubmit_after_two_delays",
|
||||
"failure_state": "unknown_error"})
|
||||
|
||||
def _assert_job_passes(self, resource_parameters):
|
||||
self._run_tool_test("simple_constructs", resource_parameters=resource_parameters)
|
||||
|
||||
def _assert_job_fails(self, resource_parameters):
|
||||
exception_thrown = False
|
||||
try:
|
||||
self._run_tool_test("simple_constructs", resource_parameters=resource_parameters)
|
||||
except Exception:
|
||||
exception_thrown = True
|
||||
class JobResubmissionDefaultIntegrationTestCase(_BaseResubmissionIntegerationTestCase):
|
||||
|
||||
assert exception_thrown
|
||||
framework_tool_and_types = True
|
||||
|
||||
@classmethod
|
||||
def handle_galaxy_config_kwds(cls, config):
|
||||
config["default_job_resubmission_condition"] = "attempt < 2"
|
||||
config["job_config_file"] = JOB_RESUBMISSION_DEFAULT_JOB_CONFIG_FILE
|
||||
config["job_resource_params_file"] = JOB_RESUBMISSION_JOB_RESOURCES_CONFIG_FILE
|
||||
|
||||
def test_default_resubmission(self):
|
||||
self._assert_job_passes(resource_parameters={"test_name": "test_default_resubmission"})
|
||||
|
||||
@@ -22,6 +22,7 @@ class JobConfXmlParserTestCase( unittest.TestCase ):
|
||||
use_tasked_jobs=False,
|
||||
job_resource_params_file="/tmp/fake_absent_path",
|
||||
config_dict={},
|
||||
default_job_resubmission_condition="",
|
||||
)
|
||||
self.__write_config_from( SIMPLE_JOB_CONF )
|
||||
self.app = bunch.Bunch( config=self.config, job_metrics=MockJobMetrics() )
|
||||
|
||||
Reference in New Issue
Block a user