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

Side by Side Diff: scripts/common/slave_alloc.py

Issue 2250443002: Update floating builder logic, add to "chromiumos" (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: Pylint fixes. Created 4 years, 4 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 | « masters/master.chromiumos/slaves.cfg ('k') | scripts/master/cros/builder_config.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Library to generate, maintain, and read static slave pool maps.""" 5 """Library to generate, maintain, and read static slave pool maps."""
6 6
7 import collections 7 import collections
8 import itertools 8 import itertools
9 import json 9 import json
10 import os 10 import os
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 """Saves the current slave pool set to the store path.""" 149 """Saves the current slave pool set to the store path."""
150 state_dict = {} 150 state_dict = {}
151 if self._state and self._state.class_map: 151 if self._state and self._state.class_map:
152 class_map = state_dict['class_map'] = {} 152 class_map = state_dict['class_map'] = {}
153 for sc, slave_list in self._state.class_map.iteritems(): 153 for sc, slave_list in self._state.class_map.iteritems():
154 class_dict = class_map.setdefault(sc.name, {}) 154 class_dict = class_map.setdefault(sc.name, {})
155 subtype_dict = class_dict.setdefault(sc.subtype, []) 155 subtype_dict = class_dict.setdefault(sc.subtype, [])
156 subtype_dict.extend(slave_list) 156 subtype_dict.extend(slave_list)
157 157
158 if self._list_unallocated: 158 if self._list_unallocated:
159 state_dict['unallocated'] = list(self._state.unallocated or ()) 159 state_dict['unallocated'] = sorted(list(self._state.unallocated or ()))
160 160
161 with open(self.state_path, 'w') as fd: 161 with open(self.state_path, 'w') as fd:
162 json.dump(state_dict, fd, sort_keys=True, indent=2) 162 json.dump(state_dict, fd, sort_keys=True, indent=2)
163 163
164 def AddPool(self, name, *slaves): 164 def AddPool(self, name, *slaves):
165 """Returns (str): The slave pool that was allocated (for chaining). 165 """Returns (str): The slave pool that was allocated (for chaining).
166 166
167 Args: 167 Args:
168 name (str): The slave pool name. 168 name (str): The slave pool name.
169 slaves: Slave name strings that belong to this pool. 169 slaves: Slave name strings that belong to this pool.
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 339
340 # Convert SlaveMapEntry fields to immutable form. 340 # Convert SlaveMapEntry fields to immutable form.
341 result = SlaveMap( 341 result = SlaveMap(
342 entries={}, 342 entries={},
343 unallocated=frozenset(n_state.unallocated)) 343 unallocated=frozenset(n_state.unallocated))
344 for k, v in slave_map_entries.iteritems(): 344 for k, v in slave_map_entries.iteritems():
345 result.entries[k] = SlaveMapEntry( 345 result.entries[k] = SlaveMapEntry(
346 classes=frozenset(v.classes), 346 classes=frozenset(v.classes),
347 keys=tuple(sorted(v.keys))) 347 keys=tuple(sorted(v.keys)))
348 return result 348 return result
349
350
351 def BuildClassMap(sm):
352 class_map = {}
353 for s, e in sm.entries.iteritems():
354 for cls in e.classes:
355 subtype_map = class_map.setdefault(cls.name, {})
356 subtype_map.setdefault(cls.subtype, set()).add(s)
357 return class_map
OLDNEW
« no previous file with comments | « masters/master.chromiumos/slaves.cfg ('k') | scripts/master/cros/builder_config.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698