A multiprocess task runner for Prefect 2.8.3+.
Project description
Prefect Multiprocess Task Runner
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f21b10c1ef04c147f9b4c3aa1c32b218b84007609f91f16d9cfc7fcb6924591 |
|
MD5 | 1b5ec29419c1396f29decf0738755d3b |
|
BLAKE2b-256 | d024442efae392bc41284dba864ffce78e23c24124b2d621e7d6698a6f0c1a9c |
File details
Details for the file prefect_multiprocess-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: prefect_multiprocess-0.1.2-py3-none-any.whl
- Upload date:
- Size: 13.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa4f3d390c7651de45547ade2c5829d3c73dc03cbbcbc27e9599ecd310a90292 |
|
MD5 | a7ba48432b4ae630e6e2a100027405d2 |
|
BLAKE2b-256 | ddbf249d2af47750477ae60e1fab24d8129db6760ca5a5acb1d75bbc976aa409 |