From df66932fd7c90086b0fc01f46b26a9385d99bc2b Mon Sep 17 00:00:00 2001 From: Tomas Gavenciak Date: Sat, 18 Sep 2010 22:46:44 +0200 Subject: [PATCH] Fix the hooks in eval.py (self -> e), status writing --- t/moe/eval.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/t/moe/eval.py b/t/moe/eval.py index 8c996e2..94ebfa2 100644 --- a/t/moe/eval.py +++ b/t/moe/eval.py @@ -110,13 +110,13 @@ def hook_init_dirs(e): 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.""" @@ -127,16 +127,18 @@ def hook_init_tasktype(e): 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 -- 2.39.5