import imp
import moe.log
+class MoePipeError(Exception):
+ """Failure of the MoePipeline."""
+
class MoePipeline:
"""Moe pipeline."""
triple = (pri,name,fun)
pos = bisect.bisect(self.pipe, triple)
if pos <= self.index:
- raise RuntimeError, "MoePipeline.insert cannot alter the past"
+ raise MoePipeError, "Pipeline insert cannot alter the past"
self.pipe.insert(pos, triple)
def dump(self, file=sys.stdout):
modname = "moe.hooks." + name
moe.log.verbose(">> Loading hook %s\n" % name)
if not sys.modules.has_key(modname):
- fp, path, desc = imp.find_module(name, ["moe/hooks"])
+ ## FIXME: Configuration variable for the hook directory?
+ try:
+ fp, path, desc = imp.find_module(name, ["moe/hooks"])
+ except ImportError:
+ raise MoePipeError, "Cannot find hook module " + modname
try:
imp.load_module(modname, fp, path, desc)
finally:
import moe.meta
import moe.config
import moe.eval
+import moe.pipeline
#m = moe.meta.MoeMeta()
#m['a'] = '1'
print "***"
s.dump()
-print moe.eval.init_pipeline(s, 'stk_')
+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)