Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(281)

Side by Side Diff: tools/perf/fetch_benchmark_deps.py

Issue 2921353002: Refactor how we fetch Telemetry deps conditionally (Closed)
Patch Set: Only fetch data of official perf benchmarks Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/perf/conditionally_execute ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2015 The Chromium Authors. All rights reserved. 2 # Copyright 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """This module fetches and prints the dependencies given a benchmark.""" 6 """This module fetches and prints the dependencies given a benchmark."""
7 7
8 import argparse 8 import argparse
9 import os 9 import os
10 import sys 10 import sys
11 11
12 from core import benchmark_finders 12 from core import benchmark_finders
13 from core import path_util 13 from core import path_util
14 14
15 path_util.AddPyUtilsToPath() 15 path_util.AddPyUtilsToPath()
16 from py_utils import cloud_storage 16 from py_utils import cloud_storage
17 17
18 path_util.AddTelemetryToPath() 18 path_util.AddTelemetryToPath()
19 from telemetry import benchmark_runner 19 from telemetry import benchmark_runner
20 # TODO(nedn): we should not rely on Telemetry private API.
21 from telemetry.internal.browser import browser_options
20 22
21 from chrome_telemetry_build import chromium_config 23 from chrome_telemetry_build import chromium_config
22 24
23 25
24 def _FetchDependenciesIfNeeded(story_set): 26 def _FetchDependenciesIfNeeded(story_set):
25 """ Download files needed by a user story set. """ 27 """ Download files needed by a user story set. """
28 if not story_set.wpr_archive_info:
29 return
30
26 # Download files in serving_dirs. 31 # Download files in serving_dirs.
27 serving_dirs = story_set.serving_dirs 32 serving_dirs = story_set.serving_dirs
28 for directory in serving_dirs: 33 for directory in serving_dirs:
29 cloud_storage.GetFilesInDirectoryIfChanged(directory, story_set.bucket) 34 cloud_storage.GetFilesInDirectoryIfChanged(directory, story_set.bucket)
30 35
31 # Download WPR files. 36 # Download WPR files.
32 if any(not story.is_local for story in story_set): 37 if any(not story.is_local for story in story_set):
33 story_set.wpr_archive_info.DownloadArchivesIfNeeded() 38 story_set.wpr_archive_info.DownloadArchivesIfNeeded()
34 39
35 40
(...skipping 17 matching lines...) Expand all
53 os.path.join(dirpath, filename)) 58 os.path.join(dirpath, filename))
54 if extension == '.sha1': 59 if extension == '.sha1':
55 deps.add(path_name) 60 deps.add(path_name)
56 61
57 # Return relative paths. 62 # Return relative paths.
58 prefix_len = len(os.path.realpath(path_util.GetChromiumSrcDir())) + 1 63 prefix_len = len(os.path.realpath(path_util.GetChromiumSrcDir())) + 1
59 return [dep[prefix_len:] for dep in deps if dep] 64 return [dep[prefix_len:] for dep in deps if dep]
60 65
61 66
62 def FetchDepsForBenchmark(benchmark, output): 67 def FetchDepsForBenchmark(benchmark, output):
68 parser = browser_options.BrowserFinderOptions().CreateParser()
69 benchmark.AddCommandLineArgs(parser)
70 options, _ = parser.parse_args([])
71
63 # Download files according to specified benchmark. 72 # Download files according to specified benchmark.
64 story_set = benchmark().CreateStorySet(None) 73 story_set = benchmark().CreateStorySet(options)
65 74
66 _FetchDependenciesIfNeeded(story_set) 75 _FetchDependenciesIfNeeded(story_set)
67 76
68 # Print files downloaded. 77 # Print files downloaded.
69 deps = _EnumerateDependencies(story_set) 78 deps = _EnumerateDependencies(story_set)
70 for dep in deps: 79 for dep in deps:
71 print >> output, dep 80 print >> output, dep
72 81
73 82
74 def main(args, output): 83 def main(args, output):
(...skipping 14 matching lines...) Expand all
89 benchmark = benchmark_runner.GetBenchmarkByName( 98 benchmark = benchmark_runner.GetBenchmarkByName(
90 options.benchmark_name, config) 99 options.benchmark_name, config)
91 if not benchmark: 100 if not benchmark:
92 raise ValueError('No such benchmark: %s' % options.benchmark_name) 101 raise ValueError('No such benchmark: %s' % options.benchmark_name)
93 FetchDepsForBenchmark(benchmark, output) 102 FetchDepsForBenchmark(benchmark, output)
94 else: 103 else:
95 if not options.force: 104 if not options.force:
96 raw_input( 105 raw_input(
97 'No benchmark name is specified. Fetching all benchmark deps. ' 106 'No benchmark name is specified. Fetching all benchmark deps. '
98 'Press enter to continue...') 107 'Press enter to continue...')
99 for b in benchmark_finders.GetAllBenchmarks(): 108 for b in benchmark_finders.GetAllPerfBenchmarks():
100 print >> output, ('Fetch dependencies for benchmark %s:' 109 print >> output, ('Fetch dependencies for benchmark %s:'
101 % benchmark.Name()) 110 % b.Name())
jbudorick 2017/06/06 17:08:15 This fix should still land somewhere, whether in t
102 FetchDepsForBenchmark(b, output) 111 FetchDepsForBenchmark(b, output)
103 112
104 if __name__ == '__main__': 113 if __name__ == '__main__':
105 main(sys.argv[1:], sys.stdout) 114 main(sys.argv[1:], sys.stdout)
OLDNEW
« no previous file with comments | « tools/perf/conditionally_execute ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698