- "Dumps at level DDEBUG and only compiles the dump if main level low enough."
- if self.log.level <= 5:
- self.log.ddebug('****** Pipeline %r dump: ******'%pipe,name))
- self.log.ddebug(pipe.dump(prefix='**** '))
- self.log.ddebug('**************************'))
-
-#TODO ...
- def init_task(self):
- task = self['TASK']
- task_dir = self['PDIR']
- if not os.path.isdir(task_dir):
- raise moe.MoeError, "No such task %s" % task
-
- task_cfg = moe.config.MoeConfig(name = os.path.join(task_dir, "config"), type='task')
- self.cfgs.push(task_cfg)
- self.log_config(3, "after loading the task")
-
- self.stat["task"] = task
-
- type = self['TASK_TYPE']
- if type == "batch" or type == "interactive":
- moe.batch.prepare_pipe(self)
- elif type == "opendata":
- raise moe.MoeError, "Opendata tasks not implemented yet"
- else:
- raise moe.MoeError, "Unknown task type " + type
+ "Dumps pipeline `pipe` at level DDEBUG (only compiles the dump if main level low enough)."
+ if self.log.level <= 5:
+ self.log.ddebug('****** Pipeline %r dump: ******'%pipe,name)
+ self.log.ddebug(pipe.dump(prefix='**** '))
+ self.log.ddebug('**************************')
+
+ def hook_init_dirs(self):
+ """(mainline at time 5) Create and check directories, fix directory variables.
+ .. note:: Currently only TDIR."""
+ self.config.fix('TDIR')
+ tdir = self['TDIR']
+ if os.path.isdir(tdir):
+ shutil.rmtree(tdir)
+ moe.util.mkdir_tree(tdir)
+
+ def hook_load_task_config(self):
+ """(mainline at time 15) Load `TASK_CONFIG` and check `PDIR`, fixes `TASK`, `PDIR`, `TASK_CONFIG`."""
+ self.config.fix(['TASK', 'PDIR', 'TASK_CONFIG'])
+ self.log.debug('Loading task config %s', self['TASK_CONFIG'])
+ if not os.path.isdir(self['PDIR']):
+ raise moe.MoeError, "No such task %s in %s" % (self['TASK'], self['PDIR'])
+ self.config.parse_file(self['TASK_CONFIG'], level=50)
+ self.debug_dump_config()
+
+ self.stat["task"] = task # Metadata
+
+ def hook_init_tasktype(self):
+ """(mainline at time 20) Fix `TASK_TYPE`, initialize task type module."""
+
+ self.config.fix('TASK_TYPE')
+ task_type = self['TASK_TYPE']
+ self.log.debug('Loading module for TASK_TYPE: %r', task_type)
+ if not task_type:
+ raise MoeError, "Invalid TASK_TYPE: %r" % e
+ try:
+ self.tasktype_module = utils.load_module('moe.tasktypes.' + task_type)
+ except ImportError:
+ self.log.exception()
+ raise MoeError, 'Unknown TASK_TYPE: %r' % task_type
+ mod.tasktype_module.init(self)
+
+ def hook_write_metadata(self):
+ """(mainline at time 90) Write status metadata into file `STATUS_FILE`."""
+ self.log.debug('Writing status file %s', self['STATUS_FILE'])
+ self.status.write(self['STATUS_FILE'])
+ # TODO: dump to ddebug
+
+