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

Side by Side Diff: scripts/tools/estimate_capacity.py

Issue 956923002: estimate_capacity.py: filter by patch project or blamelist (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 5 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 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 """ 6 """
7 Estimates capacity needs for all builders of a given master. 7 Estimates capacity needs for all builders of a given master.
8 """ 8 """
9 9
10 import argparse 10 import argparse
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 return { 75 return {
76 'hourly_bots': min_bots(hourly_buckets, 3600), 76 'hourly_bots': min_bots(hourly_buckets, 3600),
77 'daily_bots': min_bots(daily_buckets, 3600 * 24), 77 'daily_bots': min_bots(daily_buckets, 3600 * 24),
78 } 78 }
79 79
80 80
81 def main(argv): 81 def main(argv):
82 parser = argparse.ArgumentParser() 82 parser = argparse.ArgumentParser()
83 parser.add_argument('master') 83 parser.add_argument('master')
84 parser.add_argument('--days', type=int, default=14) 84 parser.add_argument('--days', type=int, default=14)
85 parser.add_argument('--ignore-cls-by', action='append') 85 parser.add_argument('--filter-by-blamelist')
86 parser.add_argument('--filter-by-patch-project')
86 87
87 args = parser.parse_args(argv) 88 args = parser.parse_args(argv)
88 89
89 with tempfile.NamedTemporaryFile() as f: 90 with tempfile.NamedTemporaryFile() as f:
90 subprocess.check_call([ 91 subprocess.check_call([
91 os.path.join(BASE_DIR, 'scripts', 'tools', 'runit.py'), 92 os.path.join(BASE_DIR, 'scripts', 'tools', 'runit.py'),
92 os.path.join(BASE_DIR, 'scripts', 'tools', 'dump_master_cfg.py'), 93 os.path.join(BASE_DIR, 'scripts', 'tools', 'dump_master_cfg.py'),
93 'masters/%s' % args.master, 94 'masters/%s' % args.master,
94 f.name]) 95 f.name])
95 master_config = json.load(f) 96 master_config = json.load(f)
(...skipping 23 matching lines...) Expand all
119 } 120 }
120 # TODO(phajdan.jr): use multiprocessing pool to speed this up. 121 # TODO(phajdan.jr): use multiprocessing pool to speed this up.
121 for builddir, builders in pool['builders'].iteritems(): 122 for builddir, builders in pool['builders'].iteritems():
122 print ' builddir "%s":' % builddir 123 print ' builddir "%s":' % builddir
123 for builder in builders: 124 for builder in builders:
124 raw_builds = get_builds( 125 raw_builds = get_builds(
125 args.master.replace('master.', ''), builder, days) 126 args.master.replace('master.', ''), builder, days)
126 127
127 builds = [] 128 builds = []
128 for build in raw_builds: 129 for build in raw_builds:
130 properties = {p[0]: p[1] for p in build.get('properties', [])}
131 if (args.filter_by_patch_project and
132 properties.get('patch_project') != args.filter_by_patch_project):
133 continue
134
129 blamelist = build.get('blame', []) 135 blamelist = build.get('blame', [])
130 ignore_cl = False 136 if (args.filter_by_blamelist and
131 for entry in blamelist: 137 args.filter_by_blamelist not in blamelist):
132 if entry in args.ignore_cls_by: 138 continue
133 ignore_cl = True
134 break
135 if not ignore_cl:
136 builds.append(build)
137 139
138 capacity = estimate_capacity(builds) 140 capacity = estimate_capacity(builds)
139 for key in ('hourly_bots', 'daily_bots'): 141 for key in ('hourly_bots', 'daily_bots'):
140 pool_capacity[key] += capacity[key] 142 pool_capacity[key] += capacity[key]
141 print ' %-45s %5.1f %5.1f' % ( 143 print ' %-45s %5.1f %5.1f' % (
142 builder, 144 builder,
143 capacity['daily_bots'], 145 capacity['daily_bots'],
144 capacity['hourly_bots']) 146 capacity['hourly_bots'])
145 print ' %-45s %5.1f %5.1f %5.1f' % ( 147 print ' %-45s %5.1f %5.1f %5.1f' % (
146 'total', 148 'total',
147 pool_capacity['daily_bots'], 149 pool_capacity['daily_bots'],
148 pool_capacity['hourly_bots'], 150 pool_capacity['hourly_bots'],
149 len(pool['slave_set'])) 151 len(pool['slave_set']))
150 152
151 return 0 153 return 0
152 154
153 155
154 if __name__ == '__main__': 156 if __name__ == '__main__':
155 sys.exit(main(sys.argv[1:])) 157 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698