def cmd_run(self, args: argparse.Namespace): self.logger.info("running wave function db") self.unlink_simulations() self.store_parameters() self.link_simulations() self.create_working_dir() def task_run_simulation(parameters: Parameters, name: str) -> Dict[str, Any]: @doit_compat.DoitAction def action_run_simulation(targets: List[str]): del targets self.request(parameters, compute=True) return { "name": "run_simulation:" + name.replace("=", ":"), "actions": [action_run_simulation], } tasks = [] # type: List[Callable[[], Dict[str, Any]]] for simulation, parameter in zip(self.simulations, self.combinations): tasks += [partial(task_run_simulation, parameter, simulation.name)] doit_compat.run_doit( tasks, [ "--process=" + str(args.jobs), "--backend=sqlite3", "--db-file=:memory:" ], )
def cmd_list(self: SimulationBase, args: argparse.Namespace): del args self.create_working_dir() with WorkingDir(self.working_dir): run_doit( self.tasks_run, ["list", "--backend=json", "--db-file=doit.json"], )
def cmd_task_info(self: SimulationBase, args: argparse.Namespace): with WorkingDir(self.working_dir): run_doit( self.tasks_run, [ "info", "--backend=json", "--db-file=doit.json", args.name, ], )
def cmd_clean(self: SimulationBase, args: argparse.Namespace): self.create_working_dir() with WorkingDir(self.working_dir): with LockFile(Path("run.lock")): run_doit( self.tasks_clean, [ "--process=" + str(args.jobs), "--backend=json", "--db-file=doit.json", ], )
def cmd_dry_run(self: SimulationBase, args: argparse.Namespace): del args self.create_working_dir() with WorkingDir(self.working_dir): with LockFile(Path("run.lock")): run_doit( self.tasks_dry_run, [ "--backend=json", "--db-file=doit.json", ], )
def cmd_run(self: SimulationSetBase, args: argparse.Namespace): self.logger.info("running simulation set") self.create_working_dir() tasks = [] # type: List[Callable[[], Dict[str, Any]]] for simulation in self.simulations: tasks += run_simulation(simulation) run_doit( tasks, [ "--process=" + str(args.jobs), "--backend=sqlite3", "--db-file=:memory:", ], )
def cmd_graph(self: SimulationBase, args: argparse.Namespace): del args regex = re.compile(r"^\s+\".+\"\s*->\s*\".+\";$") self.create_working_dir() with WorkingDir(self.working_dir): run_doit( self.tasks_run, ["graph", "--backend=json", "--db-file=doit.json"], ) with open("tasks.dot") as fptr: code = fptr.readlines() for i, _ in enumerate(code): if not regex.match(code[i]): continue code[i] = code[i].replace(":", "\\n") with open("tasks.dot", "w") as fptr: fptr.writelines(code)