mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-01-18 12:06:08 +00:00
I lint, therefore I am
Implement fixes for the most recent pylint version.
This commit is contained in:
parent
0e0d4e0ff0
commit
c410d2e1a1
@ -17,7 +17,7 @@ from wa.framework import pluginloader, signal
|
||||
from wa.framework.command import Command, ComplexCommand, SubCommand
|
||||
from wa.framework.configuration import settings
|
||||
from wa.framework.configuration.core import Status
|
||||
from wa.framework.exception import (CommandError, ConfigError, HostError, InstrumentError,
|
||||
from wa.framework.exception import (CommandError, ConfigError, HostError, InstrumentError, #pylint: disable=redefined-builtin
|
||||
JobError, NotFoundError, OutputProcessorError,
|
||||
PluginLoaderError, ResourceError, TargetError,
|
||||
TargetNotRespondingError, TimeoutError, ToolError,
|
||||
|
@ -64,7 +64,7 @@ class ProcessCommand(Command):
|
||||
instead of just processing the root.
|
||||
""")
|
||||
|
||||
def execute(self, config, args):
|
||||
def execute(self, config, args): # pylint: disable=arguments-differ,too-many-branches,too-many-statements
|
||||
process_directory = os.path.expandvars(args.directory)
|
||||
self.logger.debug('Using process directory: {}'.format(process_directory))
|
||||
if not os.path.exists(process_directory):
|
||||
|
@ -84,7 +84,7 @@ class RunCommand(Command):
|
||||
be specified multiple times.
|
||||
""")
|
||||
|
||||
def execute(self, config, args):
|
||||
def execute(self, config, args): # pylint: disable=arguments-differ
|
||||
output = self.set_up_output_directory(config, args)
|
||||
log.add_file(output.logfile)
|
||||
output.add_artifact('runlog', output.logfile, kind='log',
|
||||
|
@ -13,7 +13,7 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
# pylint: disable=unused-import
|
||||
from devlib.exception import (DevlibError, HostError, TimeoutError,
|
||||
from devlib.exception import (DevlibError, HostError, TimeoutError, # pylint: disable=redefined-builtin
|
||||
TargetError, TargetNotRespondingError)
|
||||
|
||||
from wa.utils.misc import get_traceback
|
||||
|
@ -26,7 +26,7 @@ import wa.framework.signal as signal
|
||||
from wa.framework import instrument
|
||||
from wa.framework.configuration.core import Status
|
||||
from wa.framework.exception import TargetError, HostError, WorkloadError
|
||||
from wa.framework.exception import TargetNotRespondingError, TimeoutError
|
||||
from wa.framework.exception import TargetNotRespondingError, TimeoutError # pylint: disable=redefined-builtin
|
||||
from wa.framework.job import Job
|
||||
from wa.framework.output import init_job_output
|
||||
from wa.framework.output_processor import ProcessorManager
|
||||
@ -437,11 +437,11 @@ class Executor(object):
|
||||
self.logger.info('Results can be found in {}'.format(output.basepath))
|
||||
|
||||
if self.error_logged:
|
||||
self.logger.warn('There were errors during execution.')
|
||||
self.logger.warn('Please see {}'.format(output.logfile))
|
||||
self.logger.warning('There were errors during execution.')
|
||||
self.logger.warning('Please see {}'.format(output.logfile))
|
||||
elif self.warning_logged:
|
||||
self.logger.warn('There were warnings during execution.')
|
||||
self.logger.warn('Please see {}'.format(output.logfile))
|
||||
self.logger.warning('There were warnings during execution.')
|
||||
self.logger.warning('Please see {}'.format(output.logfile))
|
||||
|
||||
def _error_signalled_callback(self, _):
|
||||
self.error_logged = True
|
||||
|
@ -104,7 +104,7 @@ from collections import OrderedDict
|
||||
|
||||
from wa.framework import signal
|
||||
from wa.framework.plugin import Plugin
|
||||
from wa.framework.exception import (TargetNotRespondingError, TimeoutError,
|
||||
from wa.framework.exception import (TargetNotRespondingError, TimeoutError, # pylint: disable=redefined-builtin
|
||||
WorkloadError, TargetError)
|
||||
from wa.utils.log import log_error
|
||||
from wa.utils.misc import isiterable
|
||||
@ -324,7 +324,7 @@ def install(instrument, context):
|
||||
if not callable(attr):
|
||||
msg = 'Attribute {} not callable in {}.'
|
||||
raise ValueError(msg.format(attr_name, instrument))
|
||||
argspec = inspect.getargspec(attr)
|
||||
argspec = inspect.getfullargspec(attr)
|
||||
arg_num = len(argspec.args)
|
||||
# Instrument callbacks will be passed exactly two arguments: self
|
||||
# (the instrument instance to which the callback is bound) and
|
||||
|
@ -16,8 +16,7 @@ import logging
|
||||
import os
|
||||
import time
|
||||
|
||||
from wa import Parameter
|
||||
from wa.framework.plugin import TargetedPlugin
|
||||
from wa.framework.plugin import TargetedPlugin, Parameter
|
||||
from wa.framework.resource import (ApkFile, ReventFile,
|
||||
File, loose_version_matching)
|
||||
from wa.framework.exception import WorkloadError, ConfigError
|
||||
@ -78,7 +77,7 @@ class Workload(TargetedPlugin):
|
||||
raise WorkloadError(msg.format(self.name, ' '.join(self.supported_platforms),
|
||||
self.target.os))
|
||||
|
||||
def init_resources(self, resolver):
|
||||
def init_resources(self, context):
|
||||
"""
|
||||
This method may be used to perform early resource discovery and
|
||||
initialization. This is invoked during the initial loading stage and
|
||||
@ -88,7 +87,7 @@ class Workload(TargetedPlugin):
|
||||
|
||||
"""
|
||||
for asset in self.deployable_assets:
|
||||
self.asset_files.append(resolver.get(File(self, asset)))
|
||||
self.asset_files.append(context.get(File(self, asset)))
|
||||
|
||||
@once_per_instance
|
||||
def initialize(self, context):
|
||||
@ -298,9 +297,9 @@ class ApkUIWorkload(ApkWorkload):
|
||||
super(ApkUIWorkload, self).__init__(target, **kwargs)
|
||||
self.gui = None
|
||||
|
||||
def init_resources(self, resolver):
|
||||
super(ApkUIWorkload, self).init_resources(resolver)
|
||||
self.gui.init_resources(resolver)
|
||||
def init_resources(self, context):
|
||||
super(ApkUIWorkload, self).init_resources(context)
|
||||
self.gui.init_resources(context)
|
||||
|
||||
@once_per_instance
|
||||
def initialize(self, context):
|
||||
@ -378,9 +377,9 @@ class UIWorkload(Workload):
|
||||
super(UIWorkload, self).__init__(target, **kwargs)
|
||||
self.gui = None
|
||||
|
||||
def init_resources(self, resolver):
|
||||
super(UIWorkload, self).init_resources(resolver)
|
||||
self.gui.init_resources(resolver)
|
||||
def init_resources(self, context):
|
||||
super(UIWorkload, self).init_resources(context)
|
||||
self.gui.init_resources(context)
|
||||
|
||||
@once_per_instance
|
||||
def initialize(self, context):
|
||||
@ -819,7 +818,7 @@ class PackageHandler(object):
|
||||
if 'Failure' in output:
|
||||
if 'ALREADY_EXISTS' in output:
|
||||
msg = 'Using already installed APK (did not uninstall properly?)'
|
||||
self.logger.warn(msg)
|
||||
self.logger.warning(msg)
|
||||
else:
|
||||
raise WorkloadError(output)
|
||||
else:
|
||||
|
@ -119,7 +119,6 @@ class FpsInstrument(Instrument):
|
||||
return
|
||||
|
||||
self._is_enabled = True
|
||||
# pylint: disable=redefined-variable-type
|
||||
if use_gfxinfo:
|
||||
self.collector = GfxInfoFramesInstrument(self.target, collector_target, self.period)
|
||||
self.processor = DerivedGfxInfoStats(self.drop_threshold, filename='fps.csv')
|
||||
|
@ -86,7 +86,7 @@ class CpuStatesProcessor(OutputProcessor):
|
||||
]
|
||||
|
||||
def initialize(self):
|
||||
self.iteration_reports = OrderedDict()
|
||||
self.iteration_reports = OrderedDict() # pylint: disable=attribute-defined-outside-init
|
||||
|
||||
def process_job_output(self, output, target_info, run_output): # pylint: disable=unused-argument
|
||||
trace_file = output.get_artifact_path('trace-cmd-txt')
|
||||
|
@ -57,7 +57,8 @@ class CsvReportProcessor(OutputProcessor):
|
||||
raise ConfigError(msg)
|
||||
|
||||
def initialize(self):
|
||||
self.outputs_so_far = [] # pylint: disable=attribute-defined-outside-init
|
||||
# pylint: disable=attribute-defined-outside-init
|
||||
self.outputs_so_far = []
|
||||
self.artifact_added = False
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
@ -66,14 +67,14 @@ class CsvReportProcessor(OutputProcessor):
|
||||
self._write_outputs(self.outputs_so_far, run_output)
|
||||
if not self.artifact_added:
|
||||
run_output.add_artifact('run_result_csv', 'results.csv', 'export')
|
||||
self.artifact_added = True
|
||||
self.artifact_added = True # pylint: disable=attribute-defined-outside-init
|
||||
|
||||
def process_run_output(self, output, target_info): # pylint: disable=unused-argument
|
||||
self.outputs_so_far.append(output)
|
||||
self._write_outputs(self.outputs_so_far, output)
|
||||
if not self.artifact_added:
|
||||
output.add_artifact('run_result_csv', 'results.csv', 'export')
|
||||
self.artifact_added = True
|
||||
self.artifact_added = True # pylint: disable=attribute-defined-outside-init
|
||||
|
||||
def _write_outputs(self, outputs, output):
|
||||
if self.use_all_classifiers:
|
||||
|
@ -22,7 +22,6 @@ from datetime import datetime, timedelta
|
||||
from contextlib import contextmanager
|
||||
|
||||
from wa import OutputProcessor, Parameter, OutputProcessorError
|
||||
from wa.framework.exception import OutputProcessorError
|
||||
from wa.utils.serializer import json
|
||||
from wa.utils.types import boolean
|
||||
|
||||
|
@ -18,7 +18,8 @@
|
||||
import time
|
||||
from collections import Counter
|
||||
|
||||
from wa import OutputProcessor, Status
|
||||
from wa.framework.output import Status
|
||||
from wa.framework.output_processor import OutputProcessor
|
||||
from wa.utils.misc import write_table
|
||||
|
||||
|
||||
|
@ -72,10 +72,9 @@ class LogcatParser(object):
|
||||
tid = int(parts.pop(0))
|
||||
level = LogcatLogLevel.levels[log_level_map.index(parts.pop(0))]
|
||||
tag = (parts.pop(0) if parts else '').strip()
|
||||
except Exception as e:
|
||||
except Exception as e: # pylint: disable=broad-except
|
||||
message = 'Invalid metadata for line:\n\t{}\n\tgot: "{}"'
|
||||
logger.warning(message.format(line, e))
|
||||
return None
|
||||
|
||||
return LogcatEvent(timestamp, pid, tid, level, tag, message)
|
||||
|
||||
|
@ -449,7 +449,7 @@ class ParallelStats(object):
|
||||
running_time_pc *= 100
|
||||
else:
|
||||
running_time_pc = 0
|
||||
precision = self.use_ratios and 3 or 1
|
||||
precision = 3 if self.use_ratios else 1
|
||||
fmt = '{{:.{}f}}'.format(precision)
|
||||
report.add([cluster, n,
|
||||
fmt.format(time),
|
||||
@ -524,7 +524,7 @@ class PowerStateStats(object):
|
||||
time_pc *= 100
|
||||
state_stats[state][cpu] = time_pc
|
||||
|
||||
precision = self.use_ratios and 3 or 1
|
||||
precision = 3 if self.use_ratios else 1
|
||||
return PowerStateStatsReport(self.filepath, state_stats, self.core_names, precision)
|
||||
|
||||
|
||||
@ -592,7 +592,7 @@ def build_idle_state_map(cpus):
|
||||
return idle_state_map
|
||||
|
||||
|
||||
def report_power_stats(trace_file, cpus, output_basedir, use_ratios=False, no_idle=None,
|
||||
def report_power_stats(trace_file, cpus, output_basedir, use_ratios=False, no_idle=None, # pylint: disable=too-many-locals
|
||||
split_wfi_states=False):
|
||||
"""
|
||||
Process trace-cmd output to generate timelines and statistics of CPU power
|
||||
@ -704,4 +704,3 @@ def report_power_stats(trace_file, cpus, output_basedir, use_ratios=False, no_id
|
||||
report.write()
|
||||
reports[report.name] = report
|
||||
return reports
|
||||
|
||||
|
@ -193,7 +193,7 @@ def log_error(e, logger, critical=False):
|
||||
old_level = set_indent_level(0)
|
||||
logger.info('Got CTRL-C. Aborting.')
|
||||
set_indent_level(old_level)
|
||||
elif isinstance(e, WAError) or isinstance(e, DevlibError):
|
||||
elif isinstance(e, (WAError, DevlibError)):
|
||||
log_func(str(e))
|
||||
elif isinstance(e, subprocess.CalledProcessError):
|
||||
tb = get_traceback()
|
||||
|
@ -31,11 +31,13 @@ import subprocess
|
||||
import sys
|
||||
import traceback
|
||||
from datetime import datetime, timedelta
|
||||
from functools import reduce
|
||||
from operator import mul
|
||||
if sys.version_info[0] == 3:
|
||||
from io import StringIO
|
||||
else:
|
||||
from io import BytesIO as StringIO
|
||||
# pylint: disable=wrong-import-position,unused-import
|
||||
from itertools import chain, cycle
|
||||
from distutils.spawn import find_executable
|
||||
|
||||
@ -257,13 +259,13 @@ def format_duration(seconds, sep=' ', order=['day', 'hour', 'minute', 'second'])
|
||||
result = []
|
||||
for item in order:
|
||||
value = getattr(dt, item, None)
|
||||
if item is 'day':
|
||||
if item == 'day':
|
||||
value -= 1
|
||||
if not value:
|
||||
continue
|
||||
suffix = '' if value == 1 else 's'
|
||||
result.append('{} {}{}'.format(value, item, suffix))
|
||||
return result and sep.join(result) or 'N/A'
|
||||
return sep.join(result) if result else 'N/A'
|
||||
|
||||
|
||||
def get_article(word):
|
||||
|
@ -66,7 +66,7 @@ import yaml as _yaml
|
||||
import dateutil.parser
|
||||
|
||||
# pylint: disable=redefined-builtin
|
||||
from past.builtins import basestring
|
||||
from past.builtins import basestring # pylint: disable=wrong-import-order
|
||||
|
||||
from wa.framework.exception import SerializerSyntaxError
|
||||
from wa.utils.misc import isiterable
|
||||
@ -104,7 +104,7 @@ POD_TYPES = [
|
||||
|
||||
class WAJSONEncoder(_json.JSONEncoder):
|
||||
|
||||
def default(self, obj): # pylint: disable=method-hidden
|
||||
def default(self, obj): # pylint: disable=method-hidden,arguments-differ
|
||||
if isinstance(obj, regex_type):
|
||||
return 'REGEX:{}:{}'.format(obj.flags, obj.pattern)
|
||||
elif isinstance(obj, datetime):
|
||||
@ -119,7 +119,7 @@ class WAJSONEncoder(_json.JSONEncoder):
|
||||
|
||||
class WAJSONDecoder(_json.JSONDecoder):
|
||||
|
||||
def decode(self, s, **kwargs):
|
||||
def decode(self, s, **kwargs): # pylint: disable=arguments-differ
|
||||
d = _json.JSONDecoder.decode(self, s, **kwargs)
|
||||
|
||||
def try_parse_object(v):
|
||||
|
@ -323,7 +323,7 @@ class TraceCmdParser(object):
|
||||
continue
|
||||
|
||||
body_parser = EVENT_PARSER_MAP.get(event_name, default_body_parser)
|
||||
if isinstance(body_parser, str) or isinstance(body_parser, re._pattern_type): # pylint: disable=protected-access
|
||||
if isinstance(body_parser, (str, re._pattern_type)): # pylint: disable=protected-access
|
||||
body_parser = regex_body_parser(body_parser)
|
||||
yield TraceCmdEvent(parser=body_parser, **match.groupdict())
|
||||
|
||||
|
@ -36,7 +36,7 @@ if sys.version_info[0] == 3:
|
||||
from past.builtins import basestring # pylint: disable=redefined-builtin
|
||||
long = int
|
||||
else:
|
||||
from urllib import quote, unquote
|
||||
from urllib import quote, unquote # pylint: disable=no-name-in-module
|
||||
# pylint: disable=wrong-import-position
|
||||
from collections import defaultdict, MutableMapping
|
||||
from copy import copy
|
||||
@ -325,7 +325,7 @@ class prioritylist(object):
|
||||
def _delete(self, priority, priority_index):
|
||||
del self.elements[priority][priority_index]
|
||||
self.size -= 1
|
||||
if len(self.elements[priority]) == 0:
|
||||
if not self.elements[priority]:
|
||||
self.priorities.remove(priority)
|
||||
self._cached_elements = None
|
||||
|
||||
|
@ -55,7 +55,7 @@ class Antutu(ApkUiautoWorkload):
|
||||
try:
|
||||
result = float(match.group(1))
|
||||
except ValueError:
|
||||
result = 'NaN' # pylint: disable=redefined-variable-type
|
||||
result = float('NaN')
|
||||
entry = regex.pattern.rsplit(None, 1)[0]
|
||||
context.add_metric(entry, result, lower_is_better=False)
|
||||
expected_results -= 1
|
||||
|
@ -150,10 +150,10 @@ class ExoPlayer(ApkWorkload):
|
||||
return filepath
|
||||
else:
|
||||
if len(files) > 1:
|
||||
self.logger.warn('Multiple files found for {} format. Using {}.'
|
||||
.format(self.format, files[0]))
|
||||
self.logger.warn('Use "filename"parameter instead of '
|
||||
'"format" to specify a different file.')
|
||||
self.logger.warning('Multiple files found for {} format. Using {}.'
|
||||
.format(self.format, files[0]))
|
||||
self.logger.warning('Use "filename"parameter instead of '
|
||||
'"format" to specify a different file.')
|
||||
return files[0]
|
||||
|
||||
def init_resources(self, context): # pylint: disable=unused-argument
|
||||
|
@ -193,9 +193,9 @@ class VellamoResultParser(HTMLParser):
|
||||
self.failed = False
|
||||
self.benchmarks = []
|
||||
|
||||
def feed(self, text):
|
||||
def feed(self, data):
|
||||
try:
|
||||
HTMLParser.feed(self, text)
|
||||
HTMLParser.feed(self, data)
|
||||
except self.StopParsingException:
|
||||
pass
|
||||
|
||||
@ -230,3 +230,6 @@ class VellamoResultParser(HTMLParser):
|
||||
self.benchmarks[-1].add_metric(data)
|
||||
else:
|
||||
self.failed = True
|
||||
|
||||
def error(self, message):
|
||||
raise WorkloadError('Error parsing raw output: {}'.format(message))
|
||||
|
Loading…
x
Reference in New Issue
Block a user