Skip to main content

Parallelize the execution of tasks with pytask.

Project description

PyPI PyPI - Python Version https://img.shields.io/conda/vn/conda-forge/pytask-parallel.svg https://img.shields.io/conda/pn/conda-forge/pytask-parallel.svg PyPI - License https://img.shields.io/github/workflow/status/pytask-dev/pytask-parallel/Continuous%20Integration%20Workflow/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 install -c conda-forge pytask-parallel

By default, the plugin uses loky’s robust implementation of the ProcessPoolExecutor.

It is also possible to select the ProcessPoolExecutor or ThreadPoolExecutor from 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, access 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

Warning

It is not possible to combine parallelization with debugging. That is why --pdb or --trace deactivate parallelization.

If you parallelize the execution of your tasks using two or more workers, do not use breakpoint() or import pdb; pdb.set_trace() since both will cause exceptions.

Changes

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

Development

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.1.1.tar.gz (11.9 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.1.1-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file pytask_parallel-0.1.1.tar.gz.

File metadata

  • Download URL: pytask_parallel-0.1.1.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for pytask_parallel-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f68d6383b9c69a91f79227ff893bb176a368402ee8616479d720f8807683b3a9
MD5 6e2c959418d27c9391d00ba6080375b6
BLAKE2b-256 4170713ae1934de6612b082e6a187c7ba729b79b05fdcbbc97e7b43acbdfecf6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pytask_parallel-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for pytask_parallel-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ac191eeb92a7449fd7e7a8add66cd22d1d4a73c1048e665a5a42acfd363abf55
MD5 53997717e8612220ab4fe9f804e1d1d1
BLAKE2b-256 46aebf4f4c353597d1abf7c417f8f763dd9d93928d6fdca5160d66d0736a4f36

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