Skip to main content

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

API Reference

Run Controls

with pypelite.pipeline(
    path="runs/experiment",
    refresh=["features"],
    skip=["train"],
    clean=["predict"],
    until="features",
):
    run_price_model()
  • refresh recomputes named stages touched by the run.
  • skip returns a stage's skip_value.
  • clean removes cached files not touched by a successful run.
  • until stops 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pypelite-0.1.7.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pypelite-0.1.7-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file pypelite-0.1.7.tar.gz.

File metadata

  • Download URL: pypelite-0.1.7.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

Hashes for pypelite-0.1.7.tar.gz
Algorithm Hash digest
SHA256 eb335beb379da2826acb7f0dc844394a870e3570919c9b8966e3b65513c9ddaf
MD5 e95682d328e56b575d7da11cd51d66e6
BLAKE2b-256 534758d666141827b9b893f1a7ebc41eb77f0c17d135f94a76ea67f1143615d6

See more details on using hashes here.

File details

Details for the file pypelite-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: pypelite-0.1.7-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

Hashes for pypelite-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 17a6a179732e41e837fea859fba93220dee9d4be5f244601f08e2d0d63b1e85a
MD5 ab5d8f53db4c75841fc251c0bfb0c4d7
BLAKE2b-256 93c540474817220de562bd984916b0a0ac49ecfd0604f4d846d9f46dea1e0c0c

See more details on using hashes here.

Supported by

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