运行并行作业并将结果保存到json.gz文件
ultrachronic的Python项目详细描述
运行并行作业并将结果保存到json.gz文件。
安装
稳定:
pip install ultrachronic
最新:
pip install git+https://github.com/yoavram/ultrachronic.git
支持Python3.4和3.5
测试
要求:
pip install nose click
运行:
nosetests tests
示例
在do_something.py:
中编码fromultrachronicimportjsonify_result,repeatimportclick@jsonify_resultdefdo_something(arg1,arg2):a=1b=2# must return a dict!returndict(a=a,b=b)@click.command()@click.option('--arg1',default=1,type=int,help='Argument 1')@click.option('--arg2',default='a',type=str,help='Argument 2')@click.option('--reps',default=1,type=click.IntRange(1,None),help='Number of repetitions')@click.option('--cpus',default=1,type=int,help='Number of CPUs to use (<1 for all available)')defmain(arg1,arg2,reps,cpus):repeat(do_something,reps,cpus,arg1=arg1,arg2=arg2)if__name__=='__main__':main()
用法:
python do_something.py python do_something.py --reps 10 --cpus 2 python do_something.py --arg1 5 --reps 10 --cpus 1 python do_something.py --arg2 hi --reps 10 --cpus 0