--- /dev/null
+# HOME set automatically
+# CONTESTANT set automatically
+# TASK set automatically
+TASK_DIR="${HOME}/problems/${TASK}"
+SOL_DIR="${HOME}/solutions/${CONTESTANT}/${TASK}"
+TEST_DIR="${HOME}/testing/${CONTESTANT}/${TASK}"
+
+TASK_TYPE=batch
else:
self.load(file)
+ def set(self, k, v):
+ self.vars[k] = [("s", v)]
+
def parse_line(self, x):
x = x.rstrip("\n").lstrip(" \t")
if x=="" or x.startswith("#"):
self.in_progress[k] = 1;
v = self.do_get(k, len(self.stk)-1)
del self.in_progress[k]
- self.cache[k] = v
+ ## FIXME: This is disabled, because the immutability invariant is broken!
+ # self.cache[k] = v
return v
def do_get(self, k, pos):
#!/usr/bin/env python
import moe.config
+import moe.log
+import moe.meta
+import moe.pipeline
+import moe.batch
+import moe.util
+import os.path
+import shutil
+
+class MoeEvalErr(Exception):
+ pass
+
+class Eval:
+
+ def __init__(self):
+ self.cfgs = moe.config.MoeConfigStack()
+ self.builtins = moe.config.MoeConfig()
+ self.cfgs.push(self.builtins)
+ self.main_pipe = moe.pipeline.MoePipeline("main")
+ self.meta = moe.meta.MoeMeta()
+ pass
+
+ def init(self):
+ self.init_global()
+ ## FIXME: Configuration overrides
+ self.init_test()
+ ## FIXME: Initialize logging early on
+ self.init_task()
+
+ def init_global(self):
+ main_cfg = moe.config.MoeConfig(name = os.path.join(self.cfgs['HOME'], "config"))
+ self.cfgs.push(main_cfg)
+
+ def init_test(self):
+ test = self.cfgs['TEST_DIR']
+ if os.path.isdir(test):
+ shutil.rmtree(test)
+ try:
+ moe.util.mkdir_tree(test)
+ except OSError, e:
+ raise MoeEvalErr, "Cannot create %s: %s" % (test, e.strerror)
+
+ def init_task(self):
+ task = self.cfgs['TASK']
+ task_dir = self.cfgs['TASK_DIR']
+ if not os.path.isdir(task_dir):
+ raise MoeEvalErr, "No such task %s" % task
+ task_cfg = moe.config.MoeConfig(name = os.path.join(task_dir, "config"))
+ self.cfgs.push(task_cfg)
+
+ type = self.cfgs['TASK_TYPE']
+ if type == "batch" or type == "interactive":
+ self.main_pipe.insert(100, "compile", moe.batch.compile)
+ self.main_pipe.insert(200, "batch-tests", moe.batch.tests)
+ elif type == "opendata":
+ raise MoeEvalErr, "Opendata tasks not implemented yet"
+ else:
+ raise MoeEvalErr, "Unknown task type " + type
+
+ def run(self):
+ self.main_pipe.configure(self.cfgs["HOOKS"])
+ self.main_pipe.dump()
+ self.main_pipe.run(self)
import moe.config
import moe.eval
import moe.pipeline
+import moe.batch
-#m = moe.meta.MoeMeta()
-#m['a'] = '1'
-#m.write()
+e = moe.eval.Eval()
+e.builtins.set("HOME", ".")
+e.builtins.set("TASK", "sum")
+e.builtins.set("CONTESTANT", "somebody")
+e.init()
-c = moe.config.MoeConfig(name='/dev/stdin')
-c.dump()
+print "Task configuration:"
+e.cfgs.dump()
+print
-#d = moe.config.MoeConfig(name='/dev/stdin')
-#d.dump()
+moe.batch.locate(e)
-s = moe.config.MoeConfigStack()
-s.push(c)
-#s.push(d)
-
-s.dump_defs()
-
-#s.apply_overrides("x_")
-#s.dump_defs()
-
-print "***"
-s.dump()
-
-p = moe.pipeline.MoePipeline('test')
-p.insert(10, 'brum', lambda x: p.insert(30, 'xyzzy', lambda y:y))
-p.insert(20, 'brummm', lambda x: x)
-p.configure("y")
-p.dump()
-p.run(5)
+e.run()