diff options
author | Luis Lozano <llozano@chromium.org> | 2015-12-15 13:49:30 -0800 |
---|---|---|
committer | Luis Lozano <llozano@chromium.org> | 2015-12-16 17:36:06 +0000 |
commit | f2a3ef46f75d2196a93d3ed27f4d1fcf22b54fbe (patch) | |
tree | 185d243c7eed7c7a0db6f0e640746cadc1479ea9 /bestflags | |
parent | 2a66f70fef907c1cb15229cb58e5129cb620ac98 (diff) | |
download | toolchain-utils-f2a3ef46f75d2196a93d3ed27f4d1fcf22b54fbe.tar.gz |
Run pyformat on all the toolchain-utils files.
This gets rid of a lot of lint issues.
Ran by doing this:
for f in *.py; do echo -n "$f " ; if [ -x $f ]; then pyformat -i
--remove_trailing_comma --yapf --force_quote_type=double $f ; else
pyformat -i --remove_shebang --remove_trailing_comma --yapf
--force_quote_type=double $f ; fi ; done
BUG=chromium:567921
TEST=Ran simple crosperf run.
Change-Id: I59778835fdaa5f706d2e1765924389f9e97433d1
Reviewed-on: https://chrome-internal-review.googlesource.com/242031
Reviewed-by: Luis Lozano <llozano@chromium.org>
Commit-Queue: Luis Lozano <llozano@chromium.org>
Tested-by: Luis Lozano <llozano@chromium.org>
Reviewed-by: Yunlian Jiang <yunlian@google.com>
Diffstat (limited to 'bestflags')
-rw-r--r-- | bestflags/example_algorithms.py | 18 | ||||
-rw-r--r-- | bestflags/flags.py | 1 | ||||
-rw-r--r-- | bestflags/flags_test.py | 1 | ||||
-rw-r--r-- | bestflags/flags_util.py | 2 | ||||
-rw-r--r-- | bestflags/generation.py | 1 | ||||
-rw-r--r-- | bestflags/generation_test.py | 3 | ||||
-rw-r--r-- | bestflags/genetic_algorithm.py | 2 | ||||
-rw-r--r-- | bestflags/hill_climb_best_neighbor.py | 2 | ||||
-rw-r--r-- | bestflags/iterative_elimination.py | 1 | ||||
-rw-r--r-- | bestflags/mock_task.py | 1 | ||||
-rw-r--r-- | bestflags/pipeline_process.py | 16 | ||||
-rw-r--r-- | bestflags/pipeline_process_test.py | 6 | ||||
-rw-r--r-- | bestflags/pipeline_worker.py | 1 | ||||
-rw-r--r-- | bestflags/pipeline_worker_test.py | 9 | ||||
-rw-r--r-- | bestflags/steering.py | 1 | ||||
-rw-r--r-- | bestflags/steering_test.py | 17 | ||||
-rw-r--r-- | bestflags/task.py | 7 | ||||
-rw-r--r-- | bestflags/task_test.py | 2 | ||||
-rw-r--r-- | bestflags/testing_batch.py | 12 |
19 files changed, 41 insertions, 62 deletions
diff --git a/bestflags/example_algorithms.py b/bestflags/example_algorithms.py index 945ff0e2..9775d491 100644 --- a/bestflags/example_algorithms.py +++ b/bestflags/example_algorithms.py @@ -1,7 +1,6 @@ # Copyright (c) 2013 The Chromium OS Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. - """An example main file running the algorithms. Part of the Chrome build flags optimization. @@ -30,8 +29,11 @@ import testing_batch parser = OptionParser() -parser.add_option('-f', '--file', dest='filename', - help='configuration file FILE input', metavar='FILE') +parser.add_option('-f', + '--file', + dest='filename', + help='configuration file FILE input', + metavar='FILE') # The meta data for the genetic algorithm. BUILD_CMD = 'BUILD_CMD' @@ -112,8 +114,8 @@ def _ProcessGA(meta_data): Task.InitLogCommand(build_cmd, test_cmd, output_file) # Initiate the build/test command and the log directory. - GAGeneration.InitMetaData(stop_threshold, num_chromosomes, num_trials, - specs, mutation_rate) + GAGeneration.InitMetaData(stop_threshold, num_chromosomes, num_trials, specs, + mutation_rate) # Generate the initial generations. generation_tasks = testing_batch.GenerateRandomGATasks(specs, num_chromosomes, @@ -169,9 +171,9 @@ def _StartExperiment(num_builders, num_testers, generations): build_test, pipeline_worker.Helper, pipeline_worker.Worker, test_steering) - steer_process = multiprocessing.Process(target=Steering, - args=(set([]), generations, - test_steering, steering_build)) + steer_process = multiprocessing.Process( + target=Steering, + args=(set([]), generations, test_steering, steering_build)) # Start the processes. build_process.start() diff --git a/bestflags/flags.py b/bestflags/flags.py index 7e7ea674..b316421e 100644 --- a/bestflags/flags.py +++ b/bestflags/flags.py @@ -1,7 +1,6 @@ # Copyright (c) 2013 The Chromium OS Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. - """Manage bundles of flags used for the optimizing of ChromeOS. Part of the Chrome build flags optimization. diff --git a/bestflags/flags_test.py b/bestflags/flags_test.py index 8ab0a9a5..dbbea77c 100644 --- a/bestflags/flags_test.py +++ b/bestflags/flags_test.py @@ -1,7 +1,6 @@ # Copyright (c) 2013 The Chromium OS Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. - """Unit tests for the classes in module 'flags'. Part of the Chrome build flags optimization. diff --git a/bestflags/flags_util.py b/bestflags/flags_util.py index ae19a60b..20be57fb 100644 --- a/bestflags/flags_util.py +++ b/bestflags/flags_util.py @@ -1,7 +1,6 @@ # Copyright (c) 2013 The Chromium OS Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. - """Utility functions to explore the neighbor flags. Part of the Chrome build flags optimization. @@ -9,7 +8,6 @@ Part of the Chrome build flags optimization. __author__ = 'yuhenglong@google.com (Yuheng Long)' - import flags from flags import Flag diff --git a/bestflags/generation.py b/bestflags/generation.py index 331c8105..67c379f5 100644 --- a/bestflags/generation.py +++ b/bestflags/generation.py @@ -1,7 +1,6 @@ # Copyright (c) 2013 The Chromium OS Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. - """A generation of a set of tasks. Part of the Chrome build flags optimization. diff --git a/bestflags/generation_test.py b/bestflags/generation_test.py index cdb4b7ab..2e042d49 100644 --- a/bestflags/generation_test.py +++ b/bestflags/generation_test.py @@ -1,7 +1,6 @@ # Copyright (c) 2013 The Chromium OS Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. - """Generation unittest. Part of the Chrome build flags optimization. @@ -15,7 +14,6 @@ import unittest from generation import Generation from mock_task import IdentifierMockTask - # Pick an integer at random. TEST_STAGE = -125 @@ -69,5 +67,6 @@ class GenerationTest(unittest.TestCase): # list is set. assert gen.Done() + if __name__ == '__main__': unittest.main() diff --git a/bestflags/genetic_algorithm.py b/bestflags/genetic_algorithm.py index 15ad1f74..deb83f12 100644 --- a/bestflags/genetic_algorithm.py +++ b/bestflags/genetic_algorithm.py @@ -1,7 +1,6 @@ # Copyright (c) 2013 The Chromium OS Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. - """The hill genetic algorithm. Part of the Chrome build flags optimization. @@ -87,6 +86,7 @@ def RandomMutate(specs, flag_set, mutation_rate): class GATask(Task): + def __init__(self, flag_set): Task.__init__(self, flag_set) diff --git a/bestflags/hill_climb_best_neighbor.py b/bestflags/hill_climb_best_neighbor.py index 4f59bca3..7bb5a7ff 100644 --- a/bestflags/hill_climb_best_neighbor.py +++ b/bestflags/hill_climb_best_neighbor.py @@ -1,7 +1,6 @@ # Copyright (c) 2013 The Chromium OS Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. - """A variation of the hill climbing algorithm. Part of the Chrome build flags optimization. @@ -13,7 +12,6 @@ neighbor. __author__ = 'yuhenglong@google.com (Yuheng Long)' - from flags import FlagSet import flags_util from generation import Generation diff --git a/bestflags/iterative_elimination.py b/bestflags/iterative_elimination.py index 618917e2..2f4c41d1 100644 --- a/bestflags/iterative_elimination.py +++ b/bestflags/iterative_elimination.py @@ -1,7 +1,6 @@ # Copyright (c) 2013 The Chromium OS Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. - """Iterative flags elimination. Part of the Chrome build flags optimization. diff --git a/bestflags/mock_task.py b/bestflags/mock_task.py index 144b7747..6de2b35c 100644 --- a/bestflags/mock_task.py +++ b/bestflags/mock_task.py @@ -1,7 +1,6 @@ # Copyright (c) 2013 The Chromium OS Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. - """This module defines the common mock tasks used by various unit tests. Part of the Chrome build flags optimization. diff --git a/bestflags/pipeline_process.py b/bestflags/pipeline_process.py index e77d92cc..31f5f21f 100644 --- a/bestflags/pipeline_process.py +++ b/bestflags/pipeline_process.py @@ -1,7 +1,6 @@ # Copyright (c) 2013 The Chromium OS Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. - """Pipeline process that encapsulates the actual content. Part of the Chrome build flags optimization. @@ -90,11 +89,10 @@ class PipelineProcess(multiprocessing.Process): work_pool = multiprocessing.Pool(self._num_processes) # the helper process - helper_process = multiprocessing.Process(target=self._helper, - args=(self._stage, self._cache, - self._helper_queue, - self._work_queue, - self._result_queue)) + helper_process = multiprocessing.Process( + target=self._helper, + args=(self._stage, self._cache, self._helper_queue, self._work_queue, + self._result_queue)) helper_process.start() mycache = self._cache.keys() @@ -112,9 +110,9 @@ class PipelineProcess(multiprocessing.Process): self._helper_queue.put(task) else: # Let the workers do the actual work. - work_pool.apply_async(self._worker, args=(self._stage, task, - self._work_queue, - self._result_queue)) + work_pool.apply_async( + self._worker, + args=(self._stage, task, self._work_queue, self._result_queue)) mycache.append(task_key) # Shutdown the workers pool and the helper process. diff --git a/bestflags/pipeline_process_test.py b/bestflags/pipeline_process_test.py index 77d72db5..b9d84067 100644 --- a/bestflags/pipeline_process_test.py +++ b/bestflags/pipeline_process_test.py @@ -1,7 +1,6 @@ # Copyright (c) 2013 The Chromium OS Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. - """Pipeline Process unittest. Part of the Chrome build flags optimization. @@ -62,9 +61,8 @@ class PipelineProcessTest(unittest.TestCase): inp = manager.Queue() output = manager.Queue() - process = pipeline_process.PipelineProcess(2, 'testing', {}, TEST_STAGE, - inp, MockHelper, MockWorker, - output) + process = pipeline_process.PipelineProcess( + 2, 'testing', {}, TEST_STAGE, inp, MockHelper, MockWorker, output) process.start() inp.put(MockTask(TEST_STAGE, 1)) diff --git a/bestflags/pipeline_worker.py b/bestflags/pipeline_worker.py index 7cccaead..e21ec2c8 100644 --- a/bestflags/pipeline_worker.py +++ b/bestflags/pipeline_worker.py @@ -1,7 +1,6 @@ # Copyright (c) 2013 The Chromium OS Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. - """The pipeline_worker functions of the build and test stage of the framework. Part of the Chrome build flags optimization. diff --git a/bestflags/pipeline_worker_test.py b/bestflags/pipeline_worker_test.py index 8c8f315c..e3de5e12 100644 --- a/bestflags/pipeline_worker_test.py +++ b/bestflags/pipeline_worker_test.py @@ -1,7 +1,6 @@ # Copyright (c) 2013 The Chromium OS Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. - """Unittest for the pipeline_worker functions in the build/test stage. Part of the Chrome build flags optimization. @@ -20,7 +19,6 @@ from mock_task import MockTask import pipeline_process import pipeline_worker - # Pick an integer at random. TEST_STAGE = -3 @@ -51,10 +49,9 @@ class PipelineWorkerTest(unittest.TestCase): completed_queue = manager.Queue() # Set up the helper process that holds the helper method. - helper_process = multiprocessing.Process(target=pipeline_worker.Helper, - args=(TEST_STAGE, {}, helper_queue, - completed_queue, - result_queue)) + helper_process = multiprocessing.Process( + target=pipeline_worker.Helper, + args=(TEST_STAGE, {}, helper_queue, completed_queue, result_queue)) helper_process.start() # A dictionary defines the mock result to the helper. diff --git a/bestflags/steering.py b/bestflags/steering.py index a7a559e2..320f7c37 100644 --- a/bestflags/steering.py +++ b/bestflags/steering.py @@ -1,7 +1,6 @@ # Copyright (c) 2013 The Chromium OS Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. - """The framework stage that produces the next generation of tasks to run. Part of the Chrome build flags optimization. diff --git a/bestflags/steering_test.py b/bestflags/steering_test.py index 2000dc45..c96e362f 100644 --- a/bestflags/steering_test.py +++ b/bestflags/steering_test.py @@ -1,7 +1,6 @@ # Copyright (c) 2013 The Chromium OS Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. - """Steering stage unittest. Part of the Chrome build flags optimization. @@ -17,7 +16,6 @@ from mock_task import IdentifierMockTask import pipeline_process import steering - # Pick an integer at random. STEERING_TEST_STAGE = -8 @@ -110,10 +108,9 @@ class SteeringTest(unittest.TestCase): input_queue = manager.Queue() result_queue = manager.Queue() - steering_process = multiprocessing.Process(target=steering.Steering, - args=(set(), - [current_generation], - input_queue, result_queue)) + steering_process = multiprocessing.Process( + target=steering.Steering, + args=(set(), [current_generation], input_queue, result_queue)) steering_process.start() # Test that each generation is processed properly. I.e., the generations are @@ -158,10 +155,9 @@ class SteeringTest(unittest.TestCase): input_queue = manager.Queue() result_queue = manager.Queue() - steering_process = multiprocessing.Process(target=steering.Steering, - args=(steering_tasks, - [current_generation], - input_queue, result_queue)) + steering_process = multiprocessing.Process( + target=steering.Steering, + args=(steering_tasks, [current_generation], input_queue, result_queue)) steering_process.start() @@ -169,5 +165,6 @@ class SteeringTest(unittest.TestCase): assert result_queue.get() == pipeline_process.POISONPILL steering_process.join() + if __name__ == '__main__': unittest.main() diff --git a/bestflags/task.py b/bestflags/task.py index ee85b1a4..f055fc75 100644 --- a/bestflags/task.py +++ b/bestflags/task.py @@ -1,7 +1,6 @@ # Copyright (c) 2013 The Chromium OS Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. - """A reproducing entity. Part of the Chrome build flags optimization. @@ -257,7 +256,8 @@ class Task(object): for _ in range(BUILD_TRIES): try: # Execute the command and get the execution status/results. - p = subprocess.Popen(command.split(), stdout=subprocess.PIPE, + p = subprocess.Popen(command.split(), + stdout=subprocess.PIPE, stderr=subprocess.PIPE) (out, err) = p.communicate() @@ -311,7 +311,8 @@ class Task(object): # Try TEST_TRIES number of times before confirming that the build fails. for _ in range(TEST_TRIES): try: - p = subprocess.Popen(command.split(), stdout=subprocess.PIPE, + p = subprocess.Popen(command.split(), + stdout=subprocess.PIPE, stderr=subprocess.PIPE) (out, err) = p.communicate() diff --git a/bestflags/task_test.py b/bestflags/task_test.py index a40e4ad4..68a7bf78 100644 --- a/bestflags/task_test.py +++ b/bestflags/task_test.py @@ -1,7 +1,6 @@ # Copyright (c) 2013 The Chromium OS Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. - """Task unittest. Part of the Chrome build flags optimization. @@ -170,5 +169,6 @@ class TaskTest(unittest.TestCase): assert work_task.Done(task.TEST_STAGE) assert work_task.Done(task.BUILD_STAGE) + if __name__ == '__main__': unittest.main() diff --git a/bestflags/testing_batch.py b/bestflags/testing_batch.py index 7bfda09b..ffe19448 100644 --- a/bestflags/testing_batch.py +++ b/bestflags/testing_batch.py @@ -1,7 +1,6 @@ # Copyright (c) 2013 The Chromium OS Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. - """Hill climbing unitest. Part of the Chrome build flags optimization. @@ -30,7 +29,6 @@ from task import BUILD_STAGE from task import Task from task import TEST_STAGE - # The number of flags be tested. NUM_FLAGS = 5 @@ -296,9 +294,9 @@ def _TestAlgorithm(cost_func, specs, generations, best_result): manager = multiprocessing.Manager() input_queue = manager.Queue() output_queue = manager.Queue() - pp_steer = multiprocessing.Process(target=Steering, - args=(set(), generations, output_queue, - input_queue)) + pp_steer = multiprocessing.Process( + target=Steering, + args=(set(), generations, output_queue, input_queue)) pp_steer.start() # The best result of the algorithm so far. @@ -401,8 +399,7 @@ class MockAlgorithmsTest(unittest.TestCase): specs, MUTATION_RATE) # Generate the initial generations. - generation_tasks = GenerateRandomGATasks(specs, NUM_CHROMOSOMES, - NUM_TRIALS) + generation_tasks = GenerateRandomGATasks(specs, NUM_CHROMOSOMES, NUM_TRIALS) generations = [GAGeneration(generation_tasks, set([]), 0)] # Test the algorithm. @@ -448,5 +445,6 @@ class MockAlgorithmsTest(unittest.TestCase): # be generated. _TestAlgorithm(cost_function, specs, generations, cost) + if __name__ == '__main__': unittest.main() |