Commit df6a24aa authored by Mikhail Khokhlov's avatar Mikhail Khokhlov Committed by Commit Bot

[tools/perf] Remove support for legacy formats

Results Processor now handles all output formats, so we can remove
the arguments that were used to pass some formats to Telemetry.

Bug: 981349
Change-Id: Ibf6d12a7a1814b31c11d566f607f063694ab3f38
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1901028
Commit-Queue: Mikhail Khokhlov <khokhlov@google.com>
Reviewed-by: default avatarJuan Antonio Navarro Pérez <perezju@chromium.org>
Cr-Commit-Position: refs/heads/master@{#713413}
parent 923cfb10
...@@ -15,8 +15,7 @@ from telemetry import command_line ...@@ -15,8 +15,7 @@ from telemetry import command_line
def main(config, args=None): def main(config, args=None):
results_arg_parser = results_processor.ArgumentParser( results_arg_parser = results_processor.ArgumentParser()
legacy_formats=command_line.LEGACY_OUTPUT_FORMATS)
options = command_line.ParseArgs( options = command_line.ParseArgs(
environment=config, args=args, results_arg_parser=results_arg_parser) environment=config, args=args, results_arg_parser=results_arg_parser)
results_processor.ProcessOptions(options) results_processor.ProcessOptions(options)
......
...@@ -19,19 +19,15 @@ from py_utils import cloud_storage ...@@ -19,19 +19,15 @@ from py_utils import cloud_storage
from core.results_processor import formatters from core.results_processor import formatters
# These formats are always handled natively, and never handed over to Telemetry.
HANDLED_NATIVELY = ['none', 'json-test-results', 'histograms', 'html', 'csv']
TELEMETRY_TEST_PATH_FORMAT = 'telemetry' TELEMETRY_TEST_PATH_FORMAT = 'telemetry'
GTEST_TEST_PATH_FORMAT = 'gtest' GTEST_TEST_PATH_FORMAT = 'gtest'
def ArgumentParser(standalone=False, legacy_formats=None):
def ArgumentParser(standalone=False):
"""Create an ArgumentParser defining options required by the processor.""" """Create an ArgumentParser defining options required by the processor."""
if standalone: all_output_formats = formatters.FORMATTERS.keys()
all_output_formats = formatters.FORMATTERS.keys() if not standalone:
else: all_output_formats.append('none')
all_output_formats = sorted(
set(HANDLED_NATIVELY).union(legacy_formats or ()))
parser, group = _CreateTopLevelParser(standalone) parser, group = _CreateTopLevelParser(standalone)
parser.add_argument( parser.add_argument(
'-v', '--verbose', action='count', dest='verbosity', '-v', '--verbose', action='count', dest='verbosity',
...@@ -42,7 +38,7 @@ def ArgumentParser(standalone=False, legacy_formats=None): ...@@ -42,7 +38,7 @@ def ArgumentParser(standalone=False, legacy_formats=None):
help=Sentences( help=Sentences(
'Output format to produce.', 'Output format to produce.',
'May be used multiple times to produce multiple outputs.', 'May be used multiple times to produce multiple outputs.',
'Avaliable formats: %s.' % ', '.join(all_output_formats), 'Avaliable formats: %(choices)s.',
'' if standalone else 'Defaults to: html.')) '' if standalone else 'Defaults to: html.'))
group.add_argument( group.add_argument(
'--intermediate-dir', metavar='DIR_PATH', required=standalone, '--intermediate-dir', metavar='DIR_PATH', required=standalone,
...@@ -89,7 +85,7 @@ def ArgumentParser(standalone=False, legacy_formats=None): ...@@ -89,7 +85,7 @@ def ArgumentParser(standalone=False, legacy_formats=None):
return parser return parser
def ProcessOptions(options, standalone=False): def ProcessOptions(options):
"""Adjust result processing options as needed before running benchmarks. """Adjust result processing options as needed before running benchmarks.
Note: The intended scope of this function is limited to only adjust options Note: The intended scope of this function is limited to only adjust options
...@@ -102,8 +98,6 @@ def ProcessOptions(options, standalone=False): ...@@ -102,8 +98,6 @@ def ProcessOptions(options, standalone=False):
Args: Args:
options: An options object with values parsed from the command line. options: An options object with values parsed from the command line.
standalone: Whether this is a standalone Results Processor run (as
opposed to the run with Telemetry).
""" """
if options.verbosity >= 2: if options.verbosity >= 2:
logging.getLogger().setLevel(logging.DEBUG) logging.getLogger().setLevel(logging.DEBUG)
...@@ -140,19 +134,10 @@ def ProcessOptions(options, standalone=False): ...@@ -140,19 +134,10 @@ def ProcessOptions(options, standalone=False):
else: else:
options.upload_bucket = None options.upload_bucket = None
if options.output_formats: if not options.output_formats:
chosen_formats = sorted(set(options.output_formats)) options.output_formats = ['html']
else: elif 'none' in options.output_formats:
chosen_formats = ['html'] options.output_formats.remove('none')
options.output_formats = []
for output_format in chosen_formats:
if output_format == 'none':
continue
elif standalone or output_format in HANDLED_NATIVELY:
options.output_formats.append(output_format)
else:
options.legacy_output_formats.append(output_format)
def _CreateTopLevelParser(standalone): def _CreateTopLevelParser(standalone):
......
...@@ -17,7 +17,6 @@ import unittest ...@@ -17,7 +17,6 @@ import unittest
import mock import mock
from core.results_processor import command_line from core.results_processor import command_line
from core.results_processor import formatters
# To easily mock module level symbols within the command_line module. # To easily mock module level symbols within the command_line module.
...@@ -27,7 +26,6 @@ def module(symbol): ...@@ -27,7 +26,6 @@ def module(symbol):
class ProcessOptionsTestCase(unittest.TestCase): class ProcessOptionsTestCase(unittest.TestCase):
def setUp(self): def setUp(self):
self.legacy_formats = []
self.standalone = False self.standalone = False
# Mock os module within results_processor so path manipulations do not # Mock os module within results_processor so path manipulations do not
...@@ -53,8 +51,7 @@ class ProcessOptionsTestCase(unittest.TestCase): ...@@ -53,8 +51,7 @@ class ProcessOptionsTestCase(unittest.TestCase):
mock.patch.stopall() mock.patch.stopall()
def ParseArgs(self, args): def ParseArgs(self, args):
parser = command_line.ArgumentParser( parser = command_line.ArgumentParser(standalone=self.standalone)
standalone=self.standalone, legacy_formats=self.legacy_formats)
options = parser.parse_args(args) options = parser.parse_args(args)
command_line.ProcessOptions(options) command_line.ProcessOptions(options)
return options return options
...@@ -132,23 +129,6 @@ class TestProcessOptions(ProcessOptionsTestCase): ...@@ -132,23 +129,6 @@ class TestProcessOptions(ProcessOptionsTestCase):
with self.assertRaises(SystemExit): with self.assertRaises(SystemExit):
self.ParseArgs(['--output-format', 'unknown']) self.ParseArgs(['--output-format', 'unknown'])
@mock.patch(module('HANDLED_NATIVELY'), ['new-format'])
def testOutputFormatsSplit(self):
self.legacy_formats = ['old-format']
options = self.ParseArgs(
['--output-format', 'new-format', '--output-format', 'old-format'])
self.assertEqual(options.output_formats, ['new-format'])
self.assertEqual(options.legacy_output_formats, ['old-format'])
@mock.patch(module('HANDLED_NATIVELY'), ['new-format'])
def testNoDuplicateOutputFormats(self):
self.legacy_formats = ['old-format']
options = self.ParseArgs(
['--output-format', 'new-format', '--output-format', 'old-format',
'--output-format', 'new-format', '--output-format', 'old-format'])
self.assertEqual(options.output_formats, ['new-format'])
self.assertEqual(options.legacy_output_formats, ['old-format'])
class StandaloneTestProcessOptions(ProcessOptionsTestCase): class StandaloneTestProcessOptions(ProcessOptionsTestCase):
def setUp(self): def setUp(self):
...@@ -170,11 +150,3 @@ class StandaloneTestProcessOptions(ProcessOptionsTestCase): ...@@ -170,11 +150,3 @@ class StandaloneTestProcessOptions(ProcessOptionsTestCase):
self.assertEqual(options.output_formats, ['json-test-results']) self.assertEqual(options.output_formats, ['json-test-results'])
self.assertEqual(options.intermediate_dir, '/path/to/curdir/some_dir') self.assertEqual(options.intermediate_dir, '/path/to/curdir/some_dir')
self.assertEqual(options.output_dir, '/path/to/output_dir') self.assertEqual(options.output_dir, '/path/to/output_dir')
class TestNativelyHandledFormats(unittest.TestCase):
def testNativelyHandledFormatsHaveFormatters(self):
for output_format in command_line.HANDLED_NATIVELY:
if output_format == 'none':
continue
self.assertIn(output_format, formatters.FORMATTERS)
...@@ -323,5 +323,5 @@ def main(args=None): ...@@ -323,5 +323,5 @@ def main(args=None):
"""Entry point for the standalone version of the results_processor script.""" """Entry point for the standalone version of the results_processor script."""
parser = command_line.ArgumentParser(standalone=True) parser = command_line.ArgumentParser(standalone=True)
options = parser.parse_args(args) options = parser.parse_args(args)
command_line.ProcessOptions(options, standalone=True) command_line.ProcessOptions(options)
return ProcessResults(options) return ProcessResults(options)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment