def main(): """ main entry point for script """ comm = MPI.COMM_WORLD opts = getoptions(True) opts['threads'] = comm.Get_size() logout = "mpiOutput-{}.log".format(comm.Get_rank()) # For MPI jobs, do something sane with logging. setuplogger(logging.ERROR, logout, opts['log']) config = Config() if comm.Get_size() < 2: logging.error("Must run MPI job with at least 2 processes") sys.exit(1) myhost = MPI.Get_processor_name() logging.info("Nodename: %s", myhost) processjobs(config, opts, comm.Get_rank(), comm) logging.info("Rank: %s FINISHED", comm.Get_rank())
def test_invalid_settings4(self): testargs = ['procname', '--start', '2015-02-03'] with patch.object(sys, 'argv', testargs): with self.assertRaises(SystemExit): opt = getoptions(False)
def test_invalid_settings3(self): testargs = ['procname', '--start', '34'] with patch.object(sys, 'argv', testargs): with self.assertRaises(ValueError): opt = getoptions(False)
def test_invalid_settings2(self): testargs = ['procname', '--localjobid', '34'] with patch.object(sys, 'argv', testargs): with self.assertRaises(SystemExit): opt = getoptions(False)
def test_invalid_settings0(self): testargs = ['procname', '--process-all'] with patch.object(sys, 'argv', testargs): with self.assertRaises(SystemExit): opt = getoptions(False)
def main(): """ main entry point for script """ opts = getoptions(False) setuplogger(opts['log']) config = Config() threads = opts['threads'] process_pool = mp.Pool(threads) if threads > 1 else None processjobs(config, opts, process_pool) if process_pool is not None: # wait for all processes to finish process_pool.close() process_pool.join()
def main(): """ main entry point for script """ opts = getoptions(False) setuplogger(opts['log']) config = Config() threads = opts['threads'] if threads <= 1: processjobs(config, opts, None) return else: proclist = [] for procid in xrange(threads): p = Process(target=processjobs, args=(config, opts, procid)) p.start() proclist.append(p) for proc in proclist: p.join()
def helper(self, args, expected): testargs = ['processname'] + args with patch.object(sys, 'argv', testargs): opts = getoptions(False) self.assertDictEqual(expected, opts)