1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-09-02 11:22:41 +01:00

Jobs: Fixes job initialize/finalize

Previously initialize and finalize were being called for each iteration
of each workload at the start/end of the run which is incorrect
behaviour. To prevent this, each iteration of a workload now shares a
single instance of the workload combined with the 'once_per_instance' decorator
to ensure that the methods are only invoked once per set of workload
runs.
This commit is contained in:
Marc Bonnici
2017-07-04 15:44:05 +01:00
parent 91c49d9e95
commit 27b488cc56
2 changed files with 16 additions and 8 deletions

View File

@@ -6,6 +6,8 @@ from wa.framework.configuration.core import Status
class Job(object):
_workload_cache = {}
@property
def id(self):
return self.spec.id
@@ -40,11 +42,15 @@ class Job(object):
def load(self, target, loader=pluginloader):
self.logger.info('Loading job {}'.format(self.id))
self.workload = loader.get_workload(self.spec.workload_name,
target,
**self.spec.workload_parameters)
self.workload.init_resources(self.context)
self.workload.validate()
if self.iteration == 1:
self.workload = loader.get_workload(self.spec.workload_name,
target,
**self.spec.workload_parameters)
self.workload.init_resources(self.context)
self.workload.validate()
self._workload_cache[self.id] = self.workload
else:
self.workload = self._workload_cache[self.id]
def initialize(self, context):
self.logger.info('Initializing job {}'.format(self.id))