def hook_load_task_config(e):
"""(mainline at time 15) Load `TASK_CONFIG` and check `PDIR`, fixes `TASK`, `PDIR`, `TASK_CONFIG`."""
e.config.fix(['TASK', 'PDIR', 'TASK_CONFIG'])
- e.log.debug('Loading task config %s', self['TASK_CONFIG'])
+ e.log.debug('Loading task config %s', e['TASK_CONFIG'])
if not os.path.isdir(e['PDIR']):
- raise moe.MoeError, "No such task %s in %s" % (e['TASK'], self['PDIR'])
- e.config.parse_file(self['TASK_CONFIG'], level=50)
+ raise moe.MoeError, "No such task %s in %s" % (e['TASK'], e['PDIR'])
+ e.config.parse_file(e['TASK_CONFIG'], level=50)
e.debug_dump_config()
- e.status["task"] = task # Metadata
+ e.status["task"] = e['TASK'] # Metadata
def hook_init_tasktype(e):
"""(mainline at time 20) Fix `TASK_TYPE`, initialize task type module."""
if not task_type:
raise MoeError, "Invalid TASK_TYPE: %r" % e
try:
- e.tasktype_module = utils.load_module('moe.tasktypes.' + task_type)
+ e.tasktype_module = moe.util.load_module('moe.tasktypes.' + task_type)
except ImportError:
e.log.exception()
raise MoeError, 'Unknown TASK_TYPE: %r' % task_type
- mod.tasktype_module.init(e)
+ e.tasktype_module.init(e)
def hook_write_metadata(e):
"""(mainline at time 90) Write status metadata into file `STATUS_FILE`."""
- e.log.debug('Writing status file %s', self['STATUS_FILE'])
- e.status.write(self['STATUS_FILE'])
+ e.debug_dump_status()
+ e.log.debug('Writing status file %s', e['STATUS_FILE'])
+ with open(e['STATUS_FILE'], 'w') as f:
+ e.status.write(f)
# TODO: dump to ddebug