def doit(line): """ Run *doit* with `task_creators` from all interactive variables (IPython's global namespace). Examples: >>> %doit --help ## Show help for options and arguments. >>> def task_foo(): return {'actions': ['echo hi IPython'], 'verbosity': 2} >>> %doit list ## List any tasks discovered. foo >>> %doit ## Run any tasks. . foo hi IPython """ # Override db-files location inside ipython-profile dir, # which is certainly writable. prof_dir = ip.profile_dir.location opt_vals = {'dep_file': os.path.join(prof_dir, 'db', '.doit.db')} commander = DoitMain(ModuleTaskLoader(ip.user_module), extra_config={'GLOBAL': opt_vals}) commander.BIN_NAME = 'doit' commander.run(line.split())
def doit(line): """ Run *doit* with `task_creators` from all interactive variables (IPython's global namespace). Examples: >>> %doit --help ## Show help for options and arguments. >>> def task_foo(): return {'actions': ['echo hi IPython'], 'verbosity': 2} >>> %doit list ## List any tasks discovered. foo >>> %doit ## Run any tasks. . foo hi IPython """ ip = get_ipython() # Override db-files location inside ipython-profile dir, # which is certainly writable. prof_dir = ip.profile_dir.location opt_vals = {'dep_file': os.path.join(prof_dir, 'db', '.doit.db')} commander = DoitMain(ModuleTaskLoader(ip.user_module), extra_config={'GLOBAL': opt_vals}) commander.run(line.split())
def run(self, doit_args=None, verbose=True): '''Run the pipeline. Movees to the directory, loads the tasks into doit, and executes that tasks that are not up-to-date. Args: doit_args (list): Args that would be passed to the doit shell command. By default, just run. verbose (bool): If True, print UI stuff. Returns: int: Exit status of the doit command. ''' if verbose: print(ui.header('Run Tasks', level=4)) if doit_args is None: doit_args = ['run'] if self.n_threads > 1: doit_args.extend(['-n', str(self.n_threads)]) runner = DoitMain(self) with Move(self.directory): if self.profile is True: profile_fn = path.join(self.directory, 'profile.csv') with StartProfiler(filename=profile_fn): return runner.run(doit_args) else: return runner.run(doit_args)
def start(self): """Begin executing tasks.""" if self.log_filename: print('Output will be logged to `%s`.' % self.log_filename) start_time = time.strftime(self.timestamp_fmt) print('Started %s' % start_time) if self.log_filename: orig_stdout = sys.stdout orig_stderr = sys.stderr sys.stdout = self.log_file sys.stderr = self.log_file print('Started %s' % start_time) doit_main = DoitMain(self) doit_main.run(['run']) stop_time = time.strftime(self.timestamp_fmt) if self.log_filename: print('Stopped %s' % stop_time) print() sys.stdout = orig_stdout sys.stderr = orig_stderr self.log_file.close() print('Stopped %s' % stop_time)
def main(argv=None): myname = path.basename(sys.argv[0]) # @UnusedVariable mydir = path.dirname(__file__) # @UnusedVariable if argv is None: argv = sys.argv[1:] opt_vals = {} # 'dep_file': path.abspath(path.join(mydir, '.doit.db'))} commander = DoitMain(ModuleTaskLoader(pndlcmd), extra_config={'GLOBAL': opt_vals}) commander.run(argv)
def run(self, doit_args=None, move=False, profile_fn=None): if doit_args is None: doit_args = ['run'] runner = DoitMain(self) print('\n--- Begin Task Execution ---') if profile_fn is not False and doit_args[0] == 'run': with StartProfiler(filename=profile_fn): return runner.run(doit_args) else: return runner.run(doit_args)
def _doit_prepare(self, builder, task): miner.dodo.builder = builder # create build directory for storing doit database if not os.path.exists(builder.build_dir): os.makedirs(builder.build_dir) opt_vals = {'dep_file': os.path.join(builder.build_dir, '.doit.db')} commander = DoitMain(ModuleTaskLoader(miner.dodo), extra_config={'GLOBAL': opt_vals}) commander.BIN_NAME = 'doit' logging.info('Preparing LEDE build system...') commander.run(['--verbosity', '2', task])
def main(): configure_test() load_exps() doit_main = DoitMain(CustomTaskLoader()) return doit_main.run(['run'])
def test_help_plugin_name(self, capsys): plugin = {'XXX': 'tests.sample_plugin:MyCmd'} main = DoitMain(extra_config={'COMMAND':plugin}) main.BIN_NAME = 'doit' returned = main.run(["help"]) assert returned == 0 out, err = capsys.readouterr() assert "doit XXX " in out assert "test extending doit commands" in out, out
def test_help_plugin_name(self, capsys): plugin = {'XXX': 'tests.sample_plugin:MyCmd'} main = DoitMain(extra_config={'COMMAND': plugin}) main.BIN_NAME = 'doit' returned = main.run(["help"]) assert returned == 0 out, err = capsys.readouterr() assert "doit XXX " in out assert "test extending doit commands" in out, out
def run(self, cmds): tasks = {} for v in self.loaders: for name, l in v.list_tasks(): f = l tasks[name] = f ml = ModuleTaskLoader(tasks) main = DoitMain(ml) main.config['default_tasks'] = cmds return main.run([])
def cmd_main(args, extra_config=None, bin_name='doit'): if extra_config: extra_config = {'GLOBAL': extra_config} main = DoitMain(extra_config=extra_config) main.BIN_NAME = bin_name return main.run(args)
def task_report(): """ renders the template in reports\report_template.docx with all figures and numbers.yaml mapped""" figure_files = glob.glob(r'reports\figures\*.png') outfile = r'reports\report_analysis-double-pendulum.docx' infile = r'reports\report_template.docx' context_file = r'reports\numbers.yaml' src_file = 'dodo_utils.py' return { 'actions': [(template_renderer(figure_files, context_file), (infile, outfile))], 'targets': [outfile], 'file_dep': [infile] + figure_files + [context_file, src_file], 'clean': True } from doit_xtended.linkedtasks import _generated_linked_tasks if __name__ == '__main__': logging.basicConfig(level=logging.INFO) from doit.cmd_base import ModuleTaskLoader from doit.doit_cmd import DoitMain d = DoitMain(ModuleTaskLoader(globals())) d.run(['-s', 'models:prediction'])
def task_report(): """ renders the template in reports\report_template.docx with all figures and numbers.yaml mapped""" figure_files = glob.glob(r'reports\figures\*.png') outfile = r'reports\report_ThreadImageProcessor.docx' infile = r'reports\report_template.docx' context_file = r'reports\numbers.yaml' src_file = 'dodo_utils.py' return { 'actions': [(template_renderer(figure_files, context_file), (infile, outfile))], 'targets': [outfile], 'file_dep': [infile] + figure_files + [context_file, src_file], 'clean': True } from doit_xtended.linkedtasks import _generated_linked_tasks if __name__ == '__main__': logging.basicConfig(level=logging.INFO) from doit.cmd_base import ModuleTaskLoader from doit.doit_cmd import DoitMain d = DoitMain(ModuleTaskLoader(globals())) d.run(['list', '--all'])