Zero-dependency parallel script runner.
Project description
π〽️❗: pi-line
A zero-dependency parallel script runner for Python.
Define units of work (Pi), execute them in parallel with a Runner, or feed them continuously through a Line.
Install
pip install pi-line
Quick start
Run scripts in parallel
from piline import Pi, Runner
pis = [
Pi(name="train", script="train.py", args=["--epochs", "10"]),
Pi(name="eval", script="eval.py"),
]
runner = Runner(max_workers=4)
results = runner.run(pis)
for r in results:
print(f"{r.pi_name}: {'PASS' if r.succeeded else 'FAIL'}")
Continuous feed with a Line
from piline import Pi, Runner, Line
runner = Runner(max_workers=4)
with Line(runner, max_results=5000) as line:
line.put(Pi(name="job1", script="job.py"))
line.put(Pi(name="job2", script="job.py"))
# look up a result by id
result = line.get(pi_id)
# flush results to external storage
batch = line.drain_results()
# line.stop() called automatically
Argument templates
Use {artefact_dir} and {task_dir} placeholders in args — they get resolved to the real paths before execution:
Pi(
name="train",
script="train.py",
args=["--output", "{artefact_dir}/model.pt"],
)
Concepts
- Pi — A unit of work. Wraps a script with args, env vars, and an optional timeout. Gets a unique ID on creation.
.pyfiles run with Python; anything else runs directly. - Result — Outcome of running a Pi. Exit code, timing, paths to stdout/stderr logs and artefacts.
- Runner — Executes a batch of Pi's in parallel using
ProcessPoolExecutor. - Line — Thread-safe queue that feeds Pi's to a Runner in batches. Results stored in a capped dict keyed by
pi_id. Supports context manager, per-Pi and per-batch callbacks, anddrain_results()for periodic flushing.
Output layout
.piline/runs/<pi_name>/<pi_id>/
stdout.log
stderr.log
artefact/
Environment variables
Scripts receive these env vars automatically:
PILINE_PI_ID— The Pi's unique IDPILINE_PI_NAME— The Pi's namePILINE_TASK_DIR— Path to the task directoryPILINE_ARTEFACT_DIR— Path to the artefact subdirectory
Callbacks
Line(
runner,
on_pi_complete=lambda r: print(f"Done: {r.pi_name} ({'PASS' if r.succeeded else 'FAIL'})"),
on_batch_complete=lambda results: print(f"Batch of {len(results)} finished"),
)
API reference
See docs/index.md.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pi_line-1.1.0.tar.gz.
File metadata
- Download URL: pi_line-1.1.0.tar.gz
- Upload date:
- Size: 17.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7fb8eef03a12df7e4d891bdd03206880d72fa2b1ca8fbbcb59234878f99c6193
|
|
| MD5 |
7a15778eaf7de1cb925deaeca13d8ad9
|
|
| BLAKE2b-256 |
4171213e55d1aa1443dce1d62c9afb8b0c3d872f6fa3fa1cfb0331263cf1daf4
|
Provenance
The following attestation bundles were made for pi_line-1.1.0.tar.gz:
Publisher:
ci.yml on importt-ant/pi-line
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pi_line-1.1.0.tar.gz -
Subject digest:
7fb8eef03a12df7e4d891bdd03206880d72fa2b1ca8fbbcb59234878f99c6193 - Sigstore transparency entry: 1338813006
- Sigstore integration time:
-
Permalink:
importt-ant/pi-line@64941defc9f1ab4a973bb8b5d84eace269a8875b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/importt-ant
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@64941defc9f1ab4a973bb8b5d84eace269a8875b -
Trigger Event:
push
-
Statement type:
File details
Details for the file pi_line-1.1.0-py3-none-any.whl.
File metadata
- Download URL: pi_line-1.1.0-py3-none-any.whl
- Upload date:
- Size: 14.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef59716e24275cf9e31483cc78609b4dc1559e35bfeb8eda2fecb9b39540c505
|
|
| MD5 |
0e2f6587dc43d6881e47aeb64df83d03
|
|
| BLAKE2b-256 |
416df51bfd2b96ba356546f1c7f4367db39b0d591e6db7ce76509164b3ef5920
|
Provenance
The following attestation bundles were made for pi_line-1.1.0-py3-none-any.whl:
Publisher:
ci.yml on importt-ant/pi-line
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pi_line-1.1.0-py3-none-any.whl -
Subject digest:
ef59716e24275cf9e31483cc78609b4dc1559e35bfeb8eda2fecb9b39540c505 - Sigstore transparency entry: 1338813007
- Sigstore integration time:
-
Permalink:
importt-ant/pi-line@64941defc9f1ab4a973bb8b5d84eace269a8875b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/importt-ant
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@64941defc9f1ab4a973bb8b5d84eace269a8875b -
Trigger Event:
push
-
Statement type: