]> mj.ucw.cz Git - moe.git/blob - t/moe/tasktypes/dummy.py
Adapted test-pipeline runner in dummy tasktype to use "with parse"
[moe.git] / t / moe / tasktypes / dummy.py
1 """
2
3 Dummy task type.
4
5 Adds several info-printing hooks to both pipelines.
6 Runs the test pipeline for each TEST
7 """
8
9 import moe.config
10
11 def init(e):
12       
13     def hook_m_50(e):
14         e.log.info('Here should be compiling')
15
16     e.main_pipe.insert(50, 'dummy tasktype hook_m_50', hook_m_50)
17     
18     def hook_m_60(e):
19         e.log.info('Here we run test pipeline')
20         tests = e['TESTS'].split()
21         for t in tests:
22             e.log.info('Running test %s' % t)
23             e.log.user.info('TEST %s ...' % t)
24             with e.config.parse("TEST='"+t+"'", level=70, source='<dummy tasktype>'): 
25               e.test_pipe.run(e=e)
26             ## The old (but proper, as the above is vulnerable to injections by including "'" !) way was:
27             #op = moe.config.Operation('SET', None, moe.config.ConfigExpression([t]), level=70, source='<dummy tasktype>')
28             #testvar = e.config.lookup('TEST')
29             ## Add and remove operation setting 'TEST="..."'
30             #testvar.add_operation(op)
31             #e.test_pipe.run(e=e)
32             #testvar.remove_operation(op)
33     
34     e.main_pipe.insert(60, 'dummy tasktype hook_m_60', hook_m_60) 
35     
36     def hook_t_30(e):
37         e.log.info("Maybe we should do something? Nah...")
38     
39     e.test_pipe.insert(30, 'dummy tasktype hook_t_30', hook_t_30)