def test_bug3(): """remake run --one not working #29""" orig_cwd = os.getcwd() os.chdir(examples_dir) sysrun('make clean') remake_cmd('remake run --one ex1'.split()) sysrun('make reset') os.chdir(orig_cwd)
def test_bug1(): orig_cwd = os.getcwd() os.chdir(examples_dir) sysrun('make clean') remake_cmd('remake run -E multiproc -f ex1'.split()) remake_cmd('remake run -E multiproc -f ex1'.split()) sysrun('make reset') os.chdir(orig_cwd)
def test_bug4(): """remake run --one not working #29""" orig_cwd = os.getcwd() os.chdir(examples_dir) sysrun('make clean') ex1 = load_remake('ex1.py') ex1.finalize() ex1.run_one() sysrun('make reset') os.chdir(orig_cwd)
def setUpClass(cls) -> None: cls.orig_cwd = os.getcwd() os.chdir(examples_dir) sysrun('make clean') cls.remake = load_remake('ex3.py') cls.remake.finalize() cls.monitor = RemakeMonitor(cls.remake) # Using the real curses package causes problems for PyCharm and github CI. # Mock out all the important parts. cls.stdscr = mock.MagicMock() cls.stdscr.getmaxyx.return_value = (100, 50) # Generate dummy keypresses to feed into RemakeMonitorCurses. commands = [ 'r', 'f', 't', ':task 0', ':task 1', ':task 2', ':show tasks', 'w' 'j', 'k', 'g', 'G', 'F', 'R', ':q' # Note, end by quiting application. ] clist = [] for command in commands: clist_command = [-1] * 100 + [ord(c) for c in command] if len(command) > 1: clist_command += [13] clist.extend(clist_command) cls.stdscr.getch.side_effect = clist # Create patches for all curses functions called. curses_patch_fns = [ 'init_pair', 'curs_set', 'color_pair', 'napms', 'is_term_resized', 'resizeterm', ] cls.patchers = [] for fn in curses_patch_fns: patcher = mock.patch(f'curses.{fn}') setattr(cls, fn, patcher.start()) cls.patchers.append(patcher) cls.is_term_resized.return_value = False
def _submit_slurm_script(slurm_script_path): try: comp_proc = sysrun(f'sbatch {slurm_script_path}') output = comp_proc.stdout logger.debug(output.strip()) except sp.CalledProcessError as cpe: logger.error(f'Error submitting {slurm_script_path}') logger.error(cpe) logger.error('===ERROR===') logger.error(cpe.stderr) logger.error('===ERROR===') raise return output
def __init__(self, task_ctrl, slurm_config): super().__init__(task_ctrl) default_slurm_kwargs = {'queue': 'short-serial', 'max_runtime': '4:00:00', 'mem': 50000} slurm_kwargs = {**default_slurm_kwargs} slurm_kwargs.update(slurm_config) self.slurm_dir = Path('.remake/slurm/scripts') self.slurm_dir.mkdir(exist_ok=True, parents=True) self.slurm_output = Path('.remake/slurm/output') self.slurm_output.mkdir(exist_ok=True, parents=True) self.remakefile_path = Path(task_ctrl.name + '.py').absolute() self.slurm_kwargs = slurm_kwargs self.task_jobid_map = {} self.remakefile_path_hash = sha1(self.remakefile_path.read_bytes()).hexdigest() self.pending_tasks = [] # Check to see whether this task is already running. try: # get jobid, partition and job name. # job name is 10 character task key. output = sysrun('squeue -u mmuetz -o "%.18i %.20P %.10j"').stdout logger.debug(output.strip()) except sp.CalledProcessError as cpe: logger.error('Error on squeue command') logger.error(cpe) logger.error('===ERROR===') logger.error(cpe.stderr) logger.error('===ERROR===') raise # Parse output. Skip first and blank lines. self.currently_running_task_keys = {} for line in output.split('\n')[1:]: if not line: continue jobid, partition, task_key = line.split() self.currently_running_task_keys[task_key] = {'jobid': jobid, 'partition': partition}
def teardown_module(): global orig_cwd orig_cwd = os.getcwd() # Restore everything to its original state. sysrun('make reset') os.chdir(orig_cwd)
def tearDown(self) -> None: sysrun('make reset') os.chdir(self.orig_cwd)
def setUp(self) -> None: self.orig_cwd = os.getcwd() os.chdir(examples_dir) sysrun('make clean') self.remake = load_remake('ex3.py') self.remake.finalize()
def setUp(self) -> None: self.orig_cwd = os.getcwd() os.chdir(examples_dir) sysrun('make clean')
def tearDownClass(cls) -> None: for patcher in cls.patchers: patcher.stop() sysrun('make reset') os.chdir(cls.orig_cwd)
def tearDownClass(cls) -> None: sysrun('make reset') os.chdir(cls.orig_cwd)
def setUpClass(cls) -> None: cls.orig_cwd = os.getcwd() os.chdir(examples_dir) sysrun('make clean') cls.remake = load_remake('demo.py')