Skip to main content

pytest-paraflow

pytest-paraflow is a pytest plugin for deterministic test sharding across machines.

Features

  • Deterministic sharding by test identity (stable hash-based assignment).
  • Group-based sharding via markers so related tests stay together.
  • Dynamic shard count derived from total test count and desired shard size.

Install

uv add pytest-paraflow

Usage

Enable sharding by passing --paraflow-shard-id and either --paraflow-num-shards or --paraflow-target-shard-size.

Static shard count

pytest --paraflow-shard-id=0 --paraflow-num-shards=4

Dynamic shard count

pytest --paraflow-shard-id=1 --paraflow-target-shard-size=200

For N collected tests, shard count is calculated as ceil(N / target_shard_size).

Group tests by marker

import pytest

@pytest.mark.paraflow_group("db")
def test_a():
    ...

@pytest.mark.paraflow_group("db")
def test_b():
    ...
pytest \
  --paraflow-shard-id=0 \
  --paraflow-num-shards=3 \
  --paraflow-group-marker=paraflow_group

Marker behavior:

  • Tests with the same marker value are assigned to the same shard.
  • @pytest.mark.paraflow_group(...) is only used when --paraflow-group-marker=paraflow_group is provided.
  • Without --paraflow-group-marker, paraflow falls back to per-test (nodeid) sharding.
  • --paraflow-group-marker=smoke with @pytest.mark.smoke groups all smoke tests together (single group key).
  • --paraflow-group-marker=smoke with @pytest.mark.smoke("db") groups by value (for example db, api).
  • --paraflow-group-marker is repeatable. If multiple configured markers exist on one test, the first configured marker wins.

CLI options

  • --paraflow-shard-id: current shard index (zero-based).
  • --paraflow-num-shards: total shard count.
  • --paraflow-target-shard-size: desired tests per shard for dynamic sizing.
  • --paraflow-group-marker: marker name used for grouping (repeatable).

Configuration defaults

CLI option defaults are loaded from Settings (src/pytest_paraflow/config/settings.py). You can configure them via environment variables:

  • PYTEST_PARAFLOW__SHARD_ID
  • PYTEST_PARAFLOW__NUM_SHARDS
  • PYTEST_PARAFLOW__TARGET_SHARD_SIZE
  • PYTEST_PARAFLOW__GROUP_MARKER (JSON array, for example ["paraflow_group", "smoke"])

CLI values always override environment defaults.

GitHub Actions (matrix sharding)

Example workflow template: examples/paraflow-matrix-example.yml. Copy it into .github/workflows/ in your repository to enable CI.

It runs pytest in 4 shards via matrix (shard_id: [0, 1, 2, 3]) and limits concurrent shard jobs with:

  • strategy.max-parallel: 2
  • --paraflow-shard-id=${{ matrix.shard_id }}
  • --paraflow-num-shards=4

Validation rules

  • --paraflow-shard-id is required whenever sharding is enabled.
  • One of --paraflow-num-shards or --paraflow-target-shard-size is required.
  • --paraflow-shard-id must be in [0, total_shards - 1].

Metadata

Release files for pytest-paraflow 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-paraflow 0.1.0
File Size Uploaded Provenance
pytest_paraflow-0.1.0.tar.gz 8.0 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-paraflow 0.1.0
File Interpreter ABI Platform
pytest_paraflow-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 22.3 kB

Release files / pytest_paraflow-0.1.0.tar.gz

Download URL pytest_paraflow-0.1.0.tar.gz
Size 8.0 kB
Tags Source
SHA-256 checksum
How to use checksums
0b20b78641e18fee9c0862b93fe9a0bad8ea6c21df9dd85cbaa0d40f78a88540
BLAKE2b-256 checksum
How to use checksums
9321a0751de1ccaa47037c1d8afe67f202087ab9c19ce5a8f6b1f8da75abc2ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 26, 2026.

Transparency log

Release files / pytest_paraflow-0.1.0-py3-none-any.whl

Download URL pytest_paraflow-0.1.0-py3-none-any.whl
Size 14.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c1c8926f1a3d6a827cedc34abab26001abdbd3c2632d0d64e13b5df12631c3d9
BLAKE2b-256 checksum
How to use checksums
ef8cad22c53d7197a779305627b535257bacd4e8a2d6996e9301c28744d9fd4c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 26, 2026.

Transparency log

Security for pytest-paraflow 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pytest_paraflow-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 26, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page