mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-01-31 10:11:17 +00: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:
parent
91c49d9e95
commit
27b488cc56
@ -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))
|
||||
|
@ -24,7 +24,7 @@ from wa.framework.resource import (ApkFile, JarFile, ReventFile, NO_ONE,
|
||||
from wa.framework.exception import WorkloadError
|
||||
from wa.utils.types import ParameterDict
|
||||
from wa.utils.revent import ReventRecorder
|
||||
from wa.utils.exec_control import once
|
||||
from wa.utils.exec_control import once_per_instance
|
||||
|
||||
from devlib.utils.android import ApkInfo
|
||||
from devlib.exception import TargetError
|
||||
@ -161,6 +161,7 @@ class ApkWorkload(Workload):
|
||||
def init_resources(self, context):
|
||||
pass
|
||||
|
||||
@once_per_instance
|
||||
def initialize(self, context):
|
||||
self.apk.initialize(context)
|
||||
|
||||
@ -177,7 +178,7 @@ class ApkWorkload(Workload):
|
||||
def teardown(self, context):
|
||||
self.apk.teardown()
|
||||
|
||||
@once
|
||||
@once_per_instance
|
||||
def finalize(self, context):
|
||||
pass
|
||||
|
||||
@ -192,6 +193,7 @@ class ApkUIWorkload(ApkWorkload):
|
||||
super(ApkUIWorkload, self).init_resources(context)
|
||||
self.gui.init_resources(context.resolver)
|
||||
|
||||
@once_per_instance
|
||||
def initialize(self, context):
|
||||
super(ApkUIWorkload, self).initialize(context)
|
||||
|
||||
@ -212,7 +214,7 @@ class ApkUIWorkload(ApkWorkload):
|
||||
self.gui.teardown()
|
||||
super(ApkUIWorkload, self).teardown(context)
|
||||
|
||||
@once
|
||||
@once_per_instance
|
||||
def finalize(self, context):
|
||||
super(ApkUIWorkload, self).finalize(context)
|
||||
self.gui.remove()
|
||||
|
Loading…
x
Reference in New Issue
Block a user