settings_factory.py revision f81680c018729fd4499e1e200d04b48c4b90127c
1#!/usr/bin/python 2 3# Copyright 2011 Google Inc. All Rights Reserved. 4"""Setting files for global, benchmark and labels.""" 5 6from field import BooleanField 7from field import FloatField 8from field import IntegerField 9from field import ListField 10from field import TextField 11from settings import Settings 12 13 14class BenchmarkSettings(Settings): 15 def __init__(self, name): 16 super(BenchmarkSettings, self).__init__(name, "benchmark") 17 self.AddField(TextField("autotest_name", 18 description="The name of the autotest to run." 19 "Defaults to the name of the benchmark.")) 20 self.AddField(TextField("autotest_args", 21 description="Arguments to be passed to the " 22 "autotest.")) 23 self.AddField(IntegerField("iterations", default=1, 24 description="Number of iterations to run the " 25 "autotest.")) 26 self.AddField(FloatField("outlier_range", default=0.2, 27 description="The percentage of highest/lowest " 28 "values to omit when computing the average.")) 29 self.AddField(BooleanField("rm_chroot_tmp", default=False, 30 description="Whether remove the run_remote_test" 31 "result in the chroot")) 32 self.AddField(BooleanField("key_results_only", default=True, 33 description="Whether only show the key results" 34 "of pyautoperf")) 35 self.AddField(TextField("perf_args", default="", 36 description="The optional profile command. It " 37 "enables perf commands to record perforamance " 38 "related counters. It must start with perf " 39 "command record or stat followed by arguments.")) 40 41 42class LabelSettings(Settings): 43 def __init__(self, name): 44 super(LabelSettings, self).__init__(name, "label") 45 self.AddField(TextField("chromeos_image", required=True, 46 description="The path to the image to run tests " 47 "on.")) 48 self.AddField(TextField("chromeos_root", 49 description="The path to a chromeos checkout which " 50 "contains a src/scripts directory. Defaults to " 51 "the chromeos checkout which contains the " 52 "chromeos_image.")) 53 self.AddField(TextField("md5sum", default="", 54 description="The md5sum of this image")) 55 self.AddField(TextField("board", required=True, description="The target " 56 "board for running experiments on, e.g. x86-alex.")) 57 self.AddField(ListField("remote", description= 58 "A comma-separated list of ip's of chromeos" 59 "devices to run experiments on.")) 60 self.AddField(TextField("image_args", required=False, 61 default="", 62 description="Extra arguments to pass to " 63 "image_chromeos.py.")) 64 self.AddField(TextField("cache_dir", default="", 65 description="The cache dir for this image.")) 66 67 68class GlobalSettings(Settings): 69 def __init__(self, name): 70 super(GlobalSettings, self).__init__(name, "global") 71 self.AddField(TextField("name", 72 description="The name of the experiment. Just an " 73 "identifier.")) 74 self.AddField(TextField("board", description="The target " 75 "board for running experiments on, e.g. x86-alex.")) 76 self.AddField(ListField("remote", 77 description="A comma-separated list of ip's of " 78 "chromeos devices to run experiments on.")) 79 self.AddField(BooleanField("rerun_if_failed", description="Whether to " 80 "re-run failed autotest runs or not.", 81 default=False)) 82 self.AddField(BooleanField("rm_chroot_tmp", default=False, 83 description="Whether remove the run_remote_test" 84 "result in the chroot")) 85 self.AddField(ListField("email", description="Space-seperated" 86 "list of email addresses to send email to.")) 87 self.AddField(BooleanField("rerun", description="Whether to ignore the " 88 "cache and for autotests to be re-run.", 89 default=False)) 90 self.AddField(BooleanField("same_specs", default=True, 91 description="Ensure cached runs are run on the " 92 "same kind of devices which are specified as a " 93 "remote.")) 94 self.AddField(BooleanField("same_machine", default=False, 95 description="Ensure cached runs are run on the " 96 "exact the same remote")) 97 self.AddField(IntegerField("iterations", default=1, 98 description="Number of iterations to run all " 99 "autotests.")) 100 self.AddField(TextField("chromeos_root", 101 description="The path to a chromeos checkout which " 102 "contains a src/scripts directory. Defaults to " 103 "the chromeos checkout which contains the " 104 "chromeos_image.")) 105 self.AddField(BooleanField("key_results_only", default=True, 106 description="Whether only show the key results" 107 "of pyautoperf")) 108 self.AddField(IntegerField("acquire_timeout", default=0, 109 description="Number of seconds to wait for " 110 "machine before exit if all the machines in " 111 "the experiment file are busy. Default is 0")) 112 self.AddField(TextField("perf_args", default="", 113 description="The optional profile command. It " 114 "enables perf commands to record perforamance " 115 "related counters. It must start with perf " 116 "command record or stat followed by arguments.")) 117 self.AddField(TextField("cache_dir", default="", 118 description="The abs path of cache dir. " 119 "Default is /home/$(whoami)/cros_scratch.")) 120 self.AddField(BooleanField("no_email", default=False, 121 description="Whether to disable the email to " 122 "user after crosperf finishes.")) 123 self.AddField(TextField("share_users", default="", 124 description="Who's cache data you want to " 125 "use. It accepts multiple users seperated by \",\"")) 126 127 128class SettingsFactory(object): 129 """Factory class for building different types of Settings objects. 130 131 This factory is currently hardcoded to produce settings for ChromeOS 132 experiment files. The idea is that in the future, other types 133 of settings could be produced. 134 """ 135 136 def GetSettings(self, name, settings_type): 137 if settings_type == "label" or not settings_type: 138 return LabelSettings(name) 139 if settings_type == "global": 140 return GlobalSettings(name) 141 if settings_type == "benchmark": 142 return BenchmarkSettings(name) 143 144 raise Exception("Invalid settings type: '%s'." % settings_type) 145