def _executeGenerateWorkflow(args: argparse.Namespace) -> None: logger: logging.Logger = logging.getLogger("gromax") logger.info("Generating run options.") # Assign hardware config cpu_ids: List[int] = parseIDString(args.cpu_ids) logger.info("CPU IDs: {}".format(cpu_ids)) num_cpus: int = len(cpu_ids) if num_cpus % 2 == 1: logger.warning( "Detected an odd number of CPU IDs ({}), this is atypical.".format( num_cpus)) gpu_ids: List[int] = parseIDString(args.gpu_ids) logger.info("GPU IDs: {}".format(gpu_ids)) num_gpus: int = len(gpu_ids) modval: int = num_cpus % num_gpus if modval != 0: logger.warning( "Number of CPUs({}) is not divisible by the number of GPUs({}), will only use {} CPUs." .format(num_cpus, num_gpus, num_cpus - modval)) cpu_ids = cpu_ids[:-modval] hw_config: HardwareConfig = HardwareConfig(cpu_ids=cpu_ids, gpu_ids=gpu_ids) generate_options: GenerateOptions = _populateGenerateOptions(args) if args.single_sim_only: config_splits: List[List[HardwareConfig]] = [[hw_config]] else: config_splits: List[List[HardwareConfig]] = generateConfigSplitOptions( hw_config, max_sims_per_gpu=generate_options.max_sims_per_gpu) logger.debug("Generated {} hardware config breakdowns".format( len(config_splits))) run_opts: List[List[Dict]] = [] for config_split in config_splits: run_opts.extend( createRunOptionsForConfigGroup(config_split, args.gmx_version, generate_options)) # Serialize options. out_file: str = args.run_file # TODO Make this configurable and robust gmx: str = args.gmx_executable + " mdrun" tpr: str = args.tpr num_trials: int = args.trials_per_group WriteRunScript(out_file, ParamsToString(run_opts, tpr, gmx, num_trials))
def testOtherInvalid(self): with self.assertRaises(ValueError): parseIDString("a")
def testInvalidDash(self): with self.assertRaises(ValueError): parseIDString("3-")
def testInvalidColon(self): with self.assertRaises(ValueError): parseIDString("3::")
def testInvalidCommas(self): with self.assertRaises(ValueError): parseIDString("0,,,3")
def testValidSingleInt(self): self.assertEqual(parseIDString("5"), [5])
def testSizeThreeValidColonStrideOther(self): self.assertEqual(parseIDString("1:3:12"), [1, 4, 7, 10])
def testSizeThreeValidColonStrideOne(self): self.assertEqual(parseIDString("1:1:5"), [1, 2, 3, 4, 5])
def testSizeTwoValidColon(self): self.assertEqual(parseIDString("1:3"), [1, 2, 3])
def testValidDash(self): self.assertEqual(parseIDString("0-5"), [0, 1, 2, 3, 4, 5])
def testValidCommas(self): self.assertEqual(parseIDString("0,2,3,4"), [0, 2, 3, 4])