跳转到主要内容

运行并行任务并将结果保存到json.gz文件

项目描述

PyPI version Build Status codecov

运行并行任务并将结果保存到json.gz文件。

安装

稳定

pip install ultrachronic

最新

pip install git+https://github.com/yoavram/ultrachronic.git

支持Python 3.4和3.5。

测试

需求

pip install nose click

运行

nosetests tests

示例

do_something.py中的代码

from ultrachronic import jsonify_result, repeat

import click

@jsonify_result
def do_something(arg1, arg2):
    a = 1
    b = 2
    # must return a dict!
    return dict(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)')
def main(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

作者

  • Yoav Ram (@yoavram)

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源代码分发

ultrachronic-0.1.5.tar.gz (19.9 kB 查看哈希值)

上传时间:

构建分发

ultrachronic-0.1.5-py3.6.egg (5.7 kB 查看哈希值)

上传时间:

ultrachronic-0.1.5-py3.5.egg (5.8 kB 查看哈希值)

上传时间:

ultrachronic-0.1.5-py3.4.egg (5.8 kB 查看哈希值)

上传时间

ultrachronic-0.1.5-py2.py3-none-any.whl (5.2 kB 查看哈希值)

上传时间 Python 2 Python 3

支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面