diff options
Diffstat (limited to 'gen/generator.py')
-rw-r--r-- | gen/generator.py | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/gen/generator.py b/gen/generator.py index 56563b1..f35a22b 100644 --- a/gen/generator.py +++ b/gen/generator.py | |||
@@ -51,14 +51,14 @@ class Generator(object): | |||
51 | This class also performs checks of parameter values and prints out help. | 51 | This class also performs checks of parameter values and prints out help. |
52 | All subclasses must implement _create_exp. | 52 | All subclasses must implement _create_exp. |
53 | ''' | 53 | ''' |
54 | def __init__(self, name, templates, options, params): | 54 | def __init__(self, scheduler, templates, options, params): |
55 | self.options = self.__make_options(params) + options | 55 | self.options = self.__make_options(params) + options |
56 | 56 | ||
57 | self.__setup_params(params) | 57 | self.__setup_params(params) |
58 | 58 | ||
59 | self.params = params | 59 | self.params = params |
60 | self.template = "\n".join([TP_RM] + templates) | 60 | self.template = "\n".join([TP_RM] + templates) |
61 | self.name = name | 61 | self.scheduler = scheduler |
62 | 62 | ||
63 | def __make_options(self, params): | 63 | def __make_options(self, params): |
64 | '''Return generic Litmus options.''' | 64 | '''Return generic Litmus options.''' |
@@ -137,7 +137,7 @@ class Generator(object): | |||
137 | 137 | ||
138 | exp_params_file = self.out_dir + "/" + DEFAULTS['params_file'] | 138 | exp_params_file = self.out_dir + "/" + DEFAULTS['params_file'] |
139 | with open(exp_params_file, 'wa') as f: | 139 | with open(exp_params_file, 'wa') as f: |
140 | params['scheduler'] = self.name | 140 | params['scheduler'] = self.scheduler |
141 | pprint.pprint(params, f) | 141 | pprint.pprint(params, f) |
142 | 142 | ||
143 | if tasks: | 143 | if tasks: |
@@ -210,7 +210,7 @@ class Generator(object): | |||
210 | for dp in DesignPointGenerator(self.params): | 210 | for dp in DesignPointGenerator(self.params): |
211 | for trial in xrange(trials): | 211 | for trial in xrange(trials): |
212 | # Create directory name from relevant parameters | 212 | # Create directory name from relevant parameters |
213 | dir_leaf = "sched=%s_%s" % (self.name, col_map.encode(dp)) | 213 | dir_leaf = "sched=%s_%s" % (self.scheduler, col_map.encode(dp)) |
214 | dir_leaf = dir_leaf.strip('_') # If there are none | 214 | dir_leaf = dir_leaf.strip('_') # If there are none |
215 | dir_leaf += ("_trial=%s" % trial) if trials > 1 else "" | 215 | dir_leaf += ("_trial=%s" % trial) if trials > 1 else "" |
216 | 216 | ||
@@ -239,12 +239,12 @@ class Generator(object): | |||
239 | 239 | ||
240 | def print_help(self): | 240 | def print_help(self): |
241 | display_options = [o for o in self.options if not o.hidden] | 241 | display_options = [o for o in self.options if not o.hidden] |
242 | s = str(Template("""Generator $name: | 242 | s = str(Template("""scheduler $scheduler: |
243 | #for $o in $options | 243 | #for $o in $options |
244 | $o.name -- $o.help | 244 | $o.name -- $o.help |
245 | \tDefault: $o.default | 245 | \tDefault: $o.default |
246 | \tAllowed: $o.types | 246 | \tAllowed: $o.types |
247 | #end for""", searchList={'name':self.name, 'options':display_options})) | 247 | #end for""", searchList={'scheduler':self.scheduler, 'options':display_options})) |
248 | 248 | ||
249 | # Has to be an easier way to print this out... | 249 | # Has to be an easier way to print this out... |
250 | for line in s.split("\n"): | 250 | for line in s.split("\n"): |
@@ -258,3 +258,12 @@ class Generator(object): | |||
258 | res = [" "*Generator.HELP_INDENT +res[-1]] | 258 | res = [" "*Generator.HELP_INDENT +res[-1]] |
259 | i = Generator.HELP_INDENT + len(word) | 259 | i = Generator.HELP_INDENT + len(word) |
260 | print(", ".join(res)) | 260 | print(", ".join(res)) |
261 | |||
262 | |||
263 | generators = {} | ||
264 | |||
265 | def register_generator(name, clazz): | ||
266 | generators[name] = clazz | ||
267 | |||
268 | def get_generators(): | ||
269 | return generators | ||