def from_dict(cls, d): qa = QueueAdapter.from_dict(d['queue_adapter']) if d['queue_adapter'] is not None else None return cls(job_rundir=d['job_rundir'], qout_file=d['qout_file'], qerr_file=d['qerr_file'], queue_adapter=qa, max_mem_per_proc_mb=d['max_mem_per_proc_mb'], mem_per_proc_increase_mb=d['mem_per_proc_increase_mb'], max_master_mem_overhead_mb=d['max_master_mem_overhead_mb'], master_mem_overhead_increase_mb=d['master_mem_overhead_increase_mb'])
def test_walltime_handler(self): # Simple test from a queue_adapter f = open(os.path.join(test_dir, "fw_handlers", "walltime", "PBS_qadapter.json")) dd = json.load(f) f.close() qad = QueueAdapter.from_dict(dd) walltime_handler = WalltimeHandler(job_rundir=os.path.join(test_dir, "fw_handlers", "walltime"), qout_file='queue.qout', qerr_file='queue.qerr', queue_adapter=qad, max_timelimit=1200, timelimit_increase=600) self.assertTrue(walltime_handler.check()) # Test with a given Firework walltime_handler = WalltimeHandler(job_rundir='.', qout_file='queue.qout', qerr_file='queue.qerr', queue_adapter=None, max_timelimit=1200, timelimit_increase=600) # Get the Firework from json file f = open(os.path.join(test_dir, 'fw_handlers', 'walltime', 'sleep_fw.json')) dd = json.load(f) f.close() fw_to_check = Firework.from_dict(dd) # Hack the launch_dir so that it points to the directory where the queue.qout is fw_to_check.launches[-1].launch_dir = os.path.join(test_dir, fw_to_check.launches[-1].launch_dir) walltime_handler.src_setup(fw_spec={}, fw_to_check=fw_to_check) self.assertTrue(walltime_handler.check()) actions = walltime_handler.correct() self.assertEqual(actions, {'errors': ['WalltimeHandler'], 'actions': [{'action': {'_set': {'timelimit': 660.0}}, 'object': {'source': 'fw_spec', 'key': 'qtk_queueadapter'}, 'action_type': 'modify_object'}]})
def from_dict(cls, d): qa = QueueAdapter.from_dict( d['queue_adapter']) if d['queue_adapter'] is not None else None return cls(job_rundir=d['job_rundir'], qout_file=d['qout_file'], qerr_file=d['qerr_file'], queue_adapter=qa, max_timelimit=d['max_timelimit'], timelimit_increase=d['timelimit_increase'])
def from_dict(cls, d): qa = QueueAdapter.from_dict(d['queue_adapter']) if d['queue_adapter'] is not None else None return cls(job_rundir=d['job_rundir'], qout_file=d['qout_file'], qerr_file=d['qerr_file'], queue_adapter=qa, max_timelimit=d['max_timelimit'], timelimit_increase=d['timelimit_increase'])