mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-09-02 03:12:34 +01:00
cleaning up initialize()
- standardisded on a single context argument - removed Device.init() no longer necessary as initilize now automatically gets propagated up the hierarchy. Renamed the existing use of it to "initilize". - related pylint cleanup.
This commit is contained in:
@@ -45,12 +45,12 @@ class Command(Extension):
|
||||
parser_params['formatter_class'] = self.formatter_class
|
||||
self.parser = subparsers.add_parser(self.name, **parser_params)
|
||||
init_argument_parser(self.parser) # propagate top-level options
|
||||
self.initialize()
|
||||
self.initialize(None)
|
||||
|
||||
def initialize(self):
|
||||
def initialize(self, context):
|
||||
"""
|
||||
Perform command-specific initialisation (e.g. adding command-specific options to the command's
|
||||
parser).
|
||||
parser). ``context`` is always ``None``.
|
||||
|
||||
"""
|
||||
pass
|
||||
|
@@ -191,6 +191,14 @@ class Device(Extension):
|
||||
if len(self.core_names) != len(self.core_clusters):
|
||||
raise ConfigError('core_names and core_clusters are of different lengths.')
|
||||
|
||||
def initialize(self, context):
|
||||
"""
|
||||
Initialization that is performed at the begining of the run (after the device has
|
||||
been connecte).
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def reset(self):
|
||||
"""
|
||||
Initiate rebooting of the device.
|
||||
@@ -222,35 +230,6 @@ class Device(Extension):
|
||||
""" Close the established connection to the device. """
|
||||
raise NotImplementedError()
|
||||
|
||||
def initialize(self, context, *args, **kwargs):
|
||||
"""
|
||||
Default implementation just calls through to init(). May be overriden by specialised
|
||||
abstract sub-cleasses to implent platform-specific intialization without requiring
|
||||
concrete implementations to explicitly invoke parent's init().
|
||||
|
||||
Added in version 2.1.3.
|
||||
|
||||
"""
|
||||
self.init(context, *args, **kwargs)
|
||||
|
||||
def init(self, context, *args, **kwargs):
|
||||
"""
|
||||
Initialize the device. This method *must* be called after a device reboot before
|
||||
any other commands can be issued, however it may also be called without rebooting.
|
||||
|
||||
It is up to device-specific implementations to identify what initialisation needs
|
||||
to be preformed on a particular invocation. Bear in mind that no assumptions can be
|
||||
made about the state of the device prior to the initiation of workload execution,
|
||||
so full initialisation must be performed at least once, even if no reboot has occurred.
|
||||
After that, the device-specific implementation may choose to skip initialization if
|
||||
the device has not been rebooted; it is up to the implementation to keep track of
|
||||
that, however.
|
||||
|
||||
All arguments are device-specific (see the documentation for the your device).
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def ping(self):
|
||||
"""
|
||||
This must return successfully if the device is able to receive commands, or must
|
||||
|
@@ -553,10 +553,10 @@ class Extension(object):
|
||||
for param in self.parameters:
|
||||
param.validate(self)
|
||||
|
||||
def initialize(self, *args, **kwargs):
|
||||
def initialize(self, context):
|
||||
pass
|
||||
|
||||
def finalize(self, *args, **kwargs):
|
||||
def finalize(self, context):
|
||||
pass
|
||||
|
||||
def check_artifacts(self, context, level):
|
||||
@@ -615,7 +615,7 @@ class Extension(object):
|
||||
raise ValueError(message.format(module_spec))
|
||||
|
||||
module = loader.get_module(name, owner=self, **params)
|
||||
module.initialize()
|
||||
module.initialize(None)
|
||||
for capability in module.capabilities:
|
||||
if capability not in self.capabilities:
|
||||
self.capabilities.append(capability)
|
||||
@@ -678,6 +678,6 @@ class Module(Extension):
|
||||
if owner.name == self.name:
|
||||
raise ValueError('Circular module import for {}'.format(self.name))
|
||||
|
||||
def initialize(self):
|
||||
def initialize(self, context):
|
||||
pass
|
||||
|
||||
|
@@ -385,10 +385,10 @@ class Instrument(Extension):
|
||||
self.is_enabled = True
|
||||
self.is_broken = False
|
||||
|
||||
def initialize(self, context): # pylint: disable=arguments-differ
|
||||
def initialize(self, context):
|
||||
pass
|
||||
|
||||
def finalize(self, context): # pylint: disable=arguments-differ
|
||||
def finalize(self, context):
|
||||
pass
|
||||
|
||||
def __str__(self):
|
||||
|
@@ -140,7 +140,7 @@ class ResultProcessor(Extension):
|
||||
|
||||
"""
|
||||
|
||||
def initialize(self, context): # pylint: disable=arguments-differ
|
||||
def initialize(self, context):
|
||||
pass
|
||||
|
||||
def process_iteration_result(self, result, context):
|
||||
@@ -155,7 +155,7 @@ class ResultProcessor(Extension):
|
||||
def export_run_result(self, result, context):
|
||||
pass
|
||||
|
||||
def finalize(self, context): # pylint: disable=arguments-differ
|
||||
def finalize(self, context):
|
||||
pass
|
||||
|
||||
|
||||
|
@@ -61,7 +61,7 @@ class Workload(Extension):
|
||||
"""
|
||||
pass
|
||||
|
||||
def initialize(self, context): # pylint: disable=arguments-differ
|
||||
def initialize(self, context):
|
||||
"""
|
||||
This method should be used to perform once-per-run initialization of a workload instance, i.e.,
|
||||
unlike ``setup()`` it will not be invoked on each iteration.
|
||||
@@ -96,7 +96,7 @@ class Workload(Extension):
|
||||
""" Perform any final clean up for the Workload. """
|
||||
pass
|
||||
|
||||
def finalize(self, context): # pylint: disable=arguments-differ
|
||||
def finalize(self, context):
|
||||
pass
|
||||
|
||||
def __str__(self):
|
||||
|
Reference in New Issue
Block a user