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.6.tar.gz (12.5 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.6-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pypelite-0.1.6.tar.gz
  • Upload date:
  • Size: 12.5 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.6.tar.gz
Algorithm Hash digest
SHA256 d2941982a134fd4217d1c5bf893a508c515fb8edb3c3c21e80d24322128c99a3
MD5 fd1a3fec34f7fdd80d0c7985fac1d531
BLAKE2b-256 7f7dde4f2b67fc350da64c93fe94ca15006e0c7233f018be33932b2d1604f749

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pypelite-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 9.9 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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 bfbf4b4ced01a102e23d11d439818900486fa61e226f7f0e8550076ec890c0be
MD5 6aa65baabcf8d30e04fa72e9d4c91b4a
BLAKE2b-256 f771bf81b21589f4f02a9f8765aa66e0bbc820df6b4628dcc29e4826b3396855

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