Add attempt to resubmission expression language.

This commit is contained in:
John Chilton
2016-12-14 13:41:29 -05:00
parent 949d122489
commit 7e338d7909
5 changed files with 27 additions and 2 deletions
@@ -29,6 +29,7 @@ def eval_condition(condition, job_state):
"unknown_error": JobState.runner_states.UNKNOWN_ERROR,
"any_failure": True,
"any_potential_job_failure": True, # Add a hook here - later on allow tools to describe things that are definitely input problems.
"attempt": job_state.job_wrapper.get_job().attempt,
}
# Small optimization to eliminate the need to parse AST and eval for simple variables.
+9
View File
@@ -618,6 +618,15 @@ class Job( object, JobLike, Dictifiable ):
self.state = state
self.state_history.append( JobStateHistory( self ) )
@property
def attempt( self ):
attempt_count = 1
for state in self.state_history:
if state.state == Job.states.RESUBMITTED:
attempt_count = attempt_count + 1
return attempt_count
def get_param_values( self, app, ignore_errors=False ):
"""
Read encoded parameter values from the database and turn back into a
+8 -2
View File
@@ -1,7 +1,6 @@
<?xml version="1.0"?>
<!--
- Test resubmit without a condition.
- Add variable ``attempt`` to condition language which is the resubmission count for the current destination.
- Test resubmit without a condition.
- Add variables ``time_since_queued`` and ``time_running`` to condition language.
-->
<job_conf>
@@ -40,6 +39,13 @@
<resubmit condition="any_failure" destination="retry_test_generic" />
</destination>
<!-- This will fail twice and succeed on walltime reached and will fail twice and fail hard else. -->
<destination id="fail_two_attempts" runner="failure_runner">
<param id="test_param">test_value</param>
<resubmit condition="attempt &lt; 3" destination="fail_two_attempts" />
<resubmit condition="attempt == 3 and walltime_reached" destination="retry_test_generic" />
</destination>
<destination id="fails_without_resubmission" runner="failure_runner">
</destination>
+1
View File
@@ -17,6 +17,7 @@ class FailsJobRunner(LocalJobRunner):
)
if failure_state is not None:
job_state.runner_state = failure_state
job_state.stop_job = False
self.fail_job(job_state, exception=True)
@@ -57,6 +57,14 @@ class JobResubmissionIntegrationTestCase(integration_util.IntegrationTestCase):
"initial_destination": "fail_first_any_failure",
"failure_state": "unknown_error"})
def test_condition_attempt(self):
self._assert_job_fails(resource_parameters={"test_name": "test_condition_attempt",
"initial_destination": "fail_two_attempts",
"failure_state": "unknown_error"})
self._assert_job_passes(resource_parameters={"test_name": "test_condition_attempt",
"initial_destination": "fail_two_attempts",
"failure_state": "walltime_reached"})
def _assert_job_passes(self, resource_parameters):
self._run_tool_test("simple_constructs", resource_parameters=resource_parameters)