Skip to main content

Prefect multiprocess task runner.

Project description

Prefect Multiprocess Task Runner

PyPI     

Welcome!

This Prefect collection contains a multiprocess task runner. It is ideal for running CPU-intensive Prefect tasks in parallel, and should be faster than ConcurrentTaskRunner in that scenario. However, tasks that are more I/O-bound than CPU-bound may finish more quickly in ConcurrentTaskRunner. It's useful in scenarios where you want to spread computation across multiple CPU cores on a single machine without adding heavy dependencies like Dask. This package does not require any extra dependencies beyond what Prefect already installs.

Getting Started

Install the package by running:

pip install prefect-multiprocess

Then, use the task runner in your Prefect flows. The task runner only accepts one parameter: processes, which controls the number of worker processes to start for running tasks. If not provided, it defaults to the number of CPUs on the host machine.

Examples:

Create one process for every CPU/CPU core

from prefect import flow
from prefect_multiprocess.task_runners import MultiprocessTaskRunner


@flow(task_runner=MultiprocessTaskRunner())
def my_flow():
    ...

Customizing the number of processes:

@flow(task_runner=MultiprocessTaskRunner(processes=4))
def my_flow():
    ...

Python setup

Requires an installation of Python 3.8+.

We recommend using a Python virtual environment manager such as pipenv, conda or virtualenv.

These tasks are designed to work with Prefect 2.0. For more information about how to use Prefect, please refer to the Prefect documentation.

Limitations

MultiprocessTaskRunner uses cloudpickle to serialize tasks and return values, so task parameters and returns need to be values that cloudpickle can handle.

Resources

If you encounter any bugs while using prefect-multiprocess, feel free to open an issue in the prefect-multiprocess repository.

Feel free to ⭐️ or watch prefect-multiprocess for updates too!

Development

If you'd like to install a version of prefect-multiprocess for development, clone the repository and perform an editable install with pip:

git clone https://github.com/rpeden/prefect-multiprocess.git

cd prefect-multiprocess/

pip install -e ".[dev]"

# Install linting pre-commit hooks
pre-commit install

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

prefect-multiprocess-0.1.1.tar.gz (31.9 kB view details)

Uploaded Source

Built Distribution

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

prefect_multiprocess-0.1.1-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file prefect-multiprocess-0.1.1.tar.gz.

File metadata

  • Download URL: prefect-multiprocess-0.1.1.tar.gz
  • Upload date:
  • Size: 31.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for prefect-multiprocess-0.1.1.tar.gz
Algorithm Hash digest
SHA256 beac13f9f8f99b71461c1fcd3c1be7d50090285805ad22edc655b38c6dedd14a
MD5 e30720c6c49c776b0f5fedfccc20c031
BLAKE2b-256 a5f5983b8992749e98d9b956d9b5822362c667e32011b3b85fddbb99f331fc1b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for prefect_multiprocess-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d603ab60e1f95a1c9305ef2d41c1860da142b92af9a53663374ec1a98bbbf954
MD5 c7869361e19d76828efc28dd3b3a1768
BLAKE2b-256 b1a009727e24023e65680296f5d02d5f69f1e71d3799cf4337398ca436e8fa34

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