Skip to main content

Parallelize the execution of tasks with pytask.

Project description

pytask-parallel

PyPI PyPI - Python Version image image PyPI - License image image pre-commit.ci status image


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 a pyproject.toml.

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

[tool.pytask.ini_options]
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.2.0.tar.gz (12.5 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.2.0-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytask_parallel-0.2.0.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.12

File hashes

Hashes for pytask_parallel-0.2.0.tar.gz
Algorithm Hash digest
SHA256 30beda6460774255007f8f6fb14f73b121f1295adc4071e01b9bd6780a3f6628
MD5 861b4f64f01445c0428b427e862c4158
BLAKE2b-256 8880d076f0d99b6561eb9d3df016b0bc494f924d18cea29d3e6626b9d9fd1b25

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytask_parallel-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 88c8f815ad0c5e3b6946acdb9e07579fda099c285f8dd301ea5f19025cecbfe8
MD5 deacb4afb83a3458b67329e191e91286
BLAKE2b-256 6187e8438688d085d516aa619f1ac82199f3cc3bc05b71f2cc651d2b795b3e6c

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