mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-01-18 12:06:08 +00:00
framework: Have Job hold its own JobState
JobState, previously handled by RunState, is now held in the Job. Changes and accesses to a Job's status access the Job's JobState directly, so that there is only one place now that each Job's state data is tracked. This also means there is no use for update_job in RunState.
This commit is contained in:
parent
8640f4f69a
commit
7c6ebfb49c
@ -23,6 +23,7 @@ from datetime import datetime
|
||||
from wa.framework import pluginloader, signal, instrument
|
||||
from wa.framework.configuration.core import Status
|
||||
from wa.utils.log import indentcontext
|
||||
from wa.framework.run import JobState
|
||||
|
||||
|
||||
class Job(object):
|
||||
@ -39,18 +40,27 @@ class Job(object):
|
||||
|
||||
@property
|
||||
def status(self):
|
||||
return self._status
|
||||
return self.state.status
|
||||
|
||||
@property
|
||||
def has_been_initialized(self):
|
||||
return self._has_been_initialized
|
||||
|
||||
@property
|
||||
def retries(self):
|
||||
return self.state.retries
|
||||
|
||||
@status.setter
|
||||
def status(self, value):
|
||||
self._status = value
|
||||
self.state.status = value
|
||||
self.state.timestamp = datetime.utcnow()
|
||||
if self.output:
|
||||
self.output.status = value
|
||||
|
||||
@retries.setter
|
||||
def retries(self, value):
|
||||
self.state.retries = value
|
||||
|
||||
def __init__(self, spec, iteration, context):
|
||||
self.logger = logging.getLogger('job')
|
||||
self.spec = spec
|
||||
@ -59,10 +69,9 @@ class Job(object):
|
||||
self.workload = None
|
||||
self.output = None
|
||||
self.run_time = None
|
||||
self.retries = 0
|
||||
self.classifiers = copy(self.spec.classifiers)
|
||||
self._has_been_initialized = False
|
||||
self._status = Status.NEW
|
||||
self.state = JobState(self.id, self.label, self.iteration, Status.NEW)
|
||||
|
||||
def load(self, target, loader=pluginloader):
|
||||
self.logger.info('Loading job {}'.format(self))
|
||||
@ -88,7 +97,6 @@ class Job(object):
|
||||
self.workload.initialize(context)
|
||||
self.set_status(Status.PENDING)
|
||||
self._has_been_initialized = True
|
||||
context.update_job_state(self)
|
||||
|
||||
def configure_augmentations(self, context, pm):
|
||||
self.logger.info('Configuring augmentations')
|
||||
|
@ -102,13 +102,7 @@ class RunState(Podable):
|
||||
self.timestamp = datetime.utcnow()
|
||||
|
||||
def add_job(self, job):
|
||||
job_state = JobState(job.id, job.label, job.iteration, job.status)
|
||||
self.jobs[(job_state.id, job_state.iteration)] = job_state
|
||||
|
||||
def update_job(self, job):
|
||||
state = self.jobs[(job.id, job.iteration)]
|
||||
state.status = job.status
|
||||
state.timestamp = datetime.utcnow()
|
||||
self.jobs[(job.state.id, job.state.iteration)] = job.state
|
||||
|
||||
def get_status_counts(self):
|
||||
counter = Counter()
|
||||
|
Loading…
x
Reference in New Issue
Block a user