Skip to main content

Parallelize the execution of pytask.

Project description

PyPI PyPI - Python Version https://anaconda.org/pytask/pytask-parallel/badges/version.svg https://anaconda.org/pytask/pytask-parallel/badges/platforms.svg PyPI - License https://github.com/pytask-dev/pytask-parallel/workflows/Continuous%20Integration%20Workflow/badge.svg?branch=main https://codecov.io/gh/pytask-dev/pytask-parallel/branch/main/graph/badge.svg pre-commit.ci status https://img.shields.io/badge/code%20style-black-000000.svg

pytask-parallel

Parallelize the execution of tasks with pytask-parallel which is a plugin for pytask.

Installation

pytask-parallel is available on PyPI and Anaconda.org. Install it with

$ pip install pytask-parallel

# or

$ conda config --add channels conda-forge --add channels pytask
$ conda install pytask-parallel

By default, the plugin uses a robust implementation of the ProcessPoolExecutor from loky.

It is also possible to select the ProcessPoolExecutor or ThreadPoolExecutor in the concurrent.futures module as backends to execute tasks asynchronously.

Usage

To parallelize your tasks across many workers, pass an integer greater than 1 or 'auto' to the command-line interface.

$ pytask -n 2
$ pytask --n-workers 2

# Starts os.cpu_count() - 1 workers.
$ pytask -n auto

Using processes to parallelize the execution of tasks is useful for CPU bound tasks such as numerical computations. (Here is an explanation on what CPU or IO bound means.)

For IO bound tasks, tasks where the limiting factor are network responses, accesses to files, you can parallelize via threads.

$ pytask --parallel-backend threads

You can also set the options in one of the configuration files (pytask.ini, tox.ini, or setup.cfg).

# This is the default configuration. Note that, parallelization is turned off.

[pytask]
n_workers = 1
parallel_backend = loky  # or processes or threads

Changes

Consult the release notes to find out about what is new.

Development

  • pytask-parallel does not call the pytask_execute_task_protocol hook specification/entry-point because pytask_execute_task_setup and pytask_execute_task need to be separated from pytask_execute_task_teardown. Thus, plugins which change this hook specification may not interact well with the parallelization.

  • There are two PRs for CPython which try to re-enable setting custom reducers which should have been working, but does not. Here are the references.

  • If the TopologicalSorter becomes available for all supported Python versions, deprecate the copied module. Meanwhile, keep it in sync.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytask-parallel-0.0.7.tar.gz (30.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytask_parallel-0.0.7-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

Details for the file pytask-parallel-0.0.7.tar.gz.

File metadata

  • Download URL: pytask-parallel-0.0.7.tar.gz
  • Upload date:
  • Size: 30.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.2

File hashes

Hashes for pytask-parallel-0.0.7.tar.gz
Algorithm Hash digest
SHA256 3410fd1d79e812719c8ea215f94fb4678e46f3a1ae96bade00ce54110f1e08b7
MD5 469ae7ad04b362ac88b137e8cbaa6fa1
BLAKE2b-256 626e6232249de945a34da3980dec21826dfe553455b73a01844beceb004fc11c

See more details on using hashes here.

File details

Details for the file pytask_parallel-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: pytask_parallel-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 14.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.2

File hashes

Hashes for pytask_parallel-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 3f9318ea1a1c2f2be91560c560002f1614059ec61eb56b627b1901cd68ebe220
MD5 860d91fad55e1fa500fdaeba75fae34c
BLAKE2b-256 b225ea723bc723d0a4d3402274b9cc128873a2b862242b3486e84ad28e5422de

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page