Created
November 7, 2013 21:20
-
-
Save philippstroehle/7362037 to your computer and use it in GitHub Desktop.
command line parsing in python, useful for parallelizing stuff on multicore machines
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import argparse | |
| def main(c=1, C=1): | |
| for iteration in [iteration for iteration in range(config.iterations) if iteration % C == c - 1]: | |
| logger.info("This is iteration %s" % iteration) | |
| seed(iteration) | |
| np.random.seed(iteration) | |
| pass | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument("-c", "--core", type=int, help="id of the core to use", default=1) | |
| parser.add_argument("-C", "--cores", type=int, help="total number of cores in use", default=1) | |
| args = parser.parse_args() | |
| main(c=args.core, C=args.cores) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment