Opinionated pipeline run archives for Python scripts.
Project description
pypelite
Pypelite is an opinionated pipeline layer in the spirit of joblib.
Wrap expensive functions with @pypelite.stage(...) and run your script inside
pypelite.pipeline(...). Stage outputs are saved to disk, so a failed run can
resume from completed steps, and a later run can refresh only the stages you
want to rerun.
import pypelite
@pypelite.stage("prices")
def load_prices(symbols):
return market_api.fetch_prices(symbols)
@pypelite.stage("features")
def build_features(prices_df):
return make_model_features(prices_df)
@pypelite.stage("train")
def train_model(features_df):
return fit_price_model(features_df)
with pypelite.pipeline("runs/price-model"):
prices_df = load_prices(["AAPL", "MSFT", "NVDA"])
features_df = build_features(prices_df)
model = train_model(features_df)
No DSL, no DAG boilerplate, no scheduler deployment. The Python script is the pipeline.
Installation
pip install pypelite
Documentation
Run Controls
with pypelite.pipeline(
path="runs/experiment",
refresh=["features"],
skip=["train"],
clean=["predict"],
until="features",
):
run_price_model()
refreshrecomputes named stages touched by the run.skipreturns a stage'sskip_value.cleanremoves cached files not touched by a successful run.untilstops the pipeline after the named stage completes.
Parallel Runs
Use vectorize with keyed stages when workers should compute missing items in
batches while still storing one artifact per key. A common case is filling
missing dates:
@pypelite.stage("daily_features", key="date", vectorize="dates", workers=4)
def build_daily_features(dates):
return feature_builder.for_dates(dates)
Use parallel_batch when the whole stage should run in worker-backed batches
and produce one final cached artifact. A common case is gathering many stocks:
@pypelite.stage(
"prices",
parallel_batch="symbols",
batch_size=50,
workers=4,
)
def load_prices(symbols):
return market_api.fetch_prices(symbols)
Archive Management
Stages write to the default archive unless they name another one. Keep shared data outside the training job archive:
import pypelite.configs
@pypelite.stage("prices", archive="data", key=("date", "symbol"))
def load_price(date, symbol):
return market_api.price(date, symbol)
@pypelite.stage("model")
def train_model(features_df):
return xgboost.train(params, features_df)
with pypelite.pipeline(
archives={
"default": pypelite.configs.archive("runs/model"),
"data": "archive/data",
},
):
run_price_model()
Use custom formatters when a stage should write a native artifact format. The
model stage above returns an XGBoost booster, so pypelite.configs.archive
stores it as UBJ.
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 pypelite-0.1.8.tar.gz.
File metadata
- Download URL: pypelite-0.1.8.tar.gz
- Upload date:
- Size: 13.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0217f135950ca59ee1bc3e0f5ea9dfeb72b1c6cb102672c738398bbab68dc717
|
|
| MD5 |
dd7aa7946452785b7fe9ab49329df036
|
|
| BLAKE2b-256 |
95aeeb35cae80b04c26a9f8714824ecb36be1311623567f4f39d54c172e99ec8
|
File details
Details for the file pypelite-0.1.8-py3-none-any.whl.
File metadata
- Download URL: pypelite-0.1.8-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b51de260cf4e8d8fc8c497b60fdac80abfc2177b2a8c4a918240cb767afe62e3
|
|
| MD5 |
f9ef0d1e2f987aa1b0a21cb3d543efdb
|
|
| BLAKE2b-256 |
35da1d7fe17d5a8702b3a31cb0ac4f4a3298bf68c49bc8ea8b286df334bda1d3
|