]> mj.ucw.cz Git - moe.git/commitdiff
Fix the hooks in eval.py (self -> e), status writing
authorTomas Gavenciak <gavento@ucw.cz>
Sat, 18 Sep 2010 20:46:44 +0000 (22:46 +0200)
committerTomas Gavenciak <gavento@ucw.cz>
Sat, 18 Sep 2010 20:46:44 +0000 (22:46 +0200)
t/moe/eval.py

index 8c996e29a2111bb0974fa09dd2505958f7ad9cfa..94ebfa227b61d96ebfb2644e2673e1739f0878b0 100644 (file)
@@ -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