aboutsummaryrefslogtreecommitdiff
path: root/crosperf/label.py
diff options
context:
space:
mode:
authorHan Shen <shenhan@google.com>2015-08-05 17:19:55 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-08-20 20:29:33 +0000
commitba64928c5dcbacbc70b4358881a89ad96227164d (patch)
tree4d2887d79204febd1c5b016810b2a65bb7551c91 /crosperf/label.py
parent0aa17b4641bcc205c52e6db0c529dd3126003ec5 (diff)
downloadtoolchain-utils-ba64928c5dcbacbc70b4358881a89ad96227164d.tar.gz
Crosperf schedv2 (1) - new option and integrating new scheduler.
This Cl introduces a new option '--schedv2' which uses the new scheduler to allocate jobs (benchmark_runs) to duts. With this option, schedv2 takes control of storing/allocating jobs and reimage machines using the new algorithm. This CL leaves actual reimaging and running jobs non-op (a random time sleep is used for each such op, which would be replace in later CLs.) You may try this CL like this and see how schedv2 works - crosperf --locks_dir=/usr/local/google/home/shenhan/tmp --use_file_locks=True --logging_level=verbose --schedv2 some.exp Change-Id: If5bb7751b466c39e54c93fe8f0b4e363be6d9165 Reviewed-on: https://chrome-internal-review.googlesource.com/225515 Commit-Queue: Han Shen <shenhan@google.com> Tested-by: Han Shen <shenhan@google.com> Reviewed-by: Han Shen <shenhan@google.com>
Diffstat (limited to 'crosperf/label.py')
-rw-r--r--crosperf/label.py31
1 files changed, 30 insertions, 1 deletions
diff --git a/crosperf/label.py b/crosperf/label.py
index 78fc1314..2f84e77b 100644
--- a/crosperf/label.py
+++ b/crosperf/label.py
@@ -7,13 +7,15 @@
"""The label of benchamrks."""
import os
+
+from image_checksummer import ImageChecksummer
from utils.file_utils import FileUtils
from utils import misc
class Label(object):
def __init__(self, name, chromeos_image, chromeos_root, board, remote,
- image_args, cache_dir, cache_only, chrome_src=None):
+ image_args, cache_dir, cache_only, log_level, chrome_src=None):
self.image_type = self._GetImageType(chromeos_image)
@@ -29,6 +31,7 @@ class Label(object):
self.image_args = image_args
self.cache_dir = cache_dir
self.cache_only = cache_only
+ self.log_level = log_level
if not chromeos_root:
if self.image_type == "local":
@@ -57,6 +60,17 @@ class Label(object):
% (name, chrome_src))
self.chrome_src = chromeos_src
+ self._SetupChecksum()
+
+ def _SetupChecksum(self):
+ """Compute label checksum only once."""
+
+ self.checksum = None
+ if self.image_type == "local":
+ self.checksum = ImageChecksummer().Checksum(self, self.log_level)
+ elif self.image_type == "trybot":
+ self.checksum = hashlib.md5(self.chromeos_image).hexdigest()
+
def _GetImageType(self, chromeos_image):
image_type = None
if chromeos_image.find("xbuddy://") < 0:
@@ -67,6 +81,21 @@ class Label(object):
image_type = "official"
return image_type
+ def __hash__(self):
+ """Label objects are used in a map, so provide "hash" and "equal"."""
+
+ return hash(self.name)
+
+ def __eq__(self, other):
+ """Label objects are used in a map, so provide "hash" and "equal"."""
+
+ return isinstance(other, Label) and other.name == self.name
+
+ def __str__(self):
+ """For better debugging."""
+
+ return 'label[name="{}"]'.format(self.name)
+
class MockLabel(object):
def __init__(self, name, chromeos_image, chromeos_root, board, remote,
image_args, cache_dir, cache_only, chrome_src=None):