Commit b93f1053 authored by Wout De Nolf's avatar Wout De Nolf

[JobFactory] setters for name and log_base

parent 29c77a38
......@@ -55,7 +55,7 @@ class Job(object):
"""
self._jobid = jobid
self._fixed_stats = None
"""Used to store store stats when using the `fixed_stats` context
"""Used to store stats when using the `fixed_stats` context
manager"""
@property
......@@ -136,7 +136,7 @@ class Job(object):
state
:param silent: if False then write to stdout advancement ('.')
"""
# make sure _until will always be iterable (dea with str, bytes...)
# make sure _until will always be iterable (deal with str, bytes...)
_states = states
if isinstance(_states, (tuple, list, dict)) is False:
_states = (_states,)
......@@ -392,18 +392,41 @@ class JobFactory(object):
def __init__(self, command=None, resource=None, name=None, project=None,
working_directory=None, log_directory=None, log_base=None):
self._name = None
self._log_base = None
self.command = command
self.resource = resource
self.name = name
self.project = project
self.working_directory = working_directory
self.log_directory = log_directory
if log_base:
self.log_base = log_base
self.log_base = log_base
@property
def name(self):
return self._name
@name.setter
def name(self,value):
self._name = value
self._default_name()
@property
def log_base(self):
return self._log_base
@log_base.setter
def log_base(self,value):
if value:
self._log_base = value
else:
self.log_base = '%jobname%.%jobid%'
if not self.name and '%jobname%' in self.log_base:
self.name = 'OAR'
self._log_base = '%jobname%.%jobid%'
self._default_name()
def _default_name(self):
if not self.name and self.log_base:
if '%jobname%' in self.log_base:
self.name = 'OAR'
@property
def cli_arguments(self):
......
......@@ -114,7 +114,7 @@ class test_oarjob(unittest.TestCase):
job = jobdef.submit()
job.wait(states=('Running', 'Terminated', 'Error'), silent=True)
self.assertRaises(RuntimeError, job.suspend)
#job.wait_needsresume(states=('Hold', 'Suspended'), silent=True)
#job.wait(states=('Hold', 'Suspended'), silent=True)
#job.resume()
#job.wait(silent=True)
#self.assertEqual(job.exit_code,0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment