Skip to main content

A multiprocess task runner for Prefect 2.8.3+.

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. It is 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.2.tar.gz (31.7 kB view details)

Uploaded Source

Built Distribution

prefect_multiprocess-0.1.2-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: prefect-multiprocess-0.1.2.tar.gz
  • Upload date:
  • Size: 31.7 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.2.tar.gz
Algorithm Hash digest
SHA256 9f21b10c1ef04c147f9b4c3aa1c32b218b84007609f91f16d9cfc7fcb6924591
MD5 1b5ec29419c1396f29decf0738755d3b
BLAKE2b-256 d024442efae392bc41284dba864ffce78e23c24124b2d621e7d6698a6f0c1a9c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for prefect_multiprocess-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fa4f3d390c7651de45547ade2c5829d3c73dc03cbbcbc27e9599ecd310a90292
MD5 a7ba48432b4ae630e6e2a100027405d2
BLAKE2b-256 ddbf249d2af47750477ae60e1fab24d8129db6760ca5a5acb1d75bbc976aa409

See more details on using hashes here.

Supported by

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