Skip to main content
mlplant-bg
mlplant is an MLOps framework that converts exploratory Jupyter notebooks into production-ready FastAPI projects using in-cell annotations.

Installation

pip install mlplant-cli

How to use

1. Annotate your notebook

Place an annotation at the top of each cell to mark it as a pipeline step. Four syntax styles are supported — pick whichever fits your workflow:

Function call (recommended)

Valid before any code, reads like a registration call, no errors or warnings:

import mlplant

mlplant.config()
LEARNING_RATE = 0.01
N_ESTIMATORS = 100
mlplant.features()
X["new_feature"] = X["a"] / X["b"]

Decorator

Clean decorator syntax, but only valid immediately before a def or class:

@mlplant.train
def _():
    model.fit(X_train, y_train)
@mlplant.predict
def predict(data: dict):
    return model.predict([list(data.values())])[0]

Expression

Minimal form — attribute access with no call. Valid anywhere, but Pylance may show an "expression value is unused" hint in some configurations:

mlplant.load_data
df = pd.read_csv("data/train.csv")

Comment

Never causes any error or warning, useful when you want zero runtime footprint:

# @mlplant.preprocessing
df = df.dropna()
df["age"] = df["age"].clip(0, 120)

All styles also accept PascalCase aliases (Config, LoadData, Train, etc.):

mlplant.LoadData()        # same as mlplant.load_data()
# @Config                 # same as # @mlplant.config
@mlplant.Train            # same as @mlplant.train (before a function)

Cells with the same annotation are automatically merged into a single output file. Visual noise (matplotlib, seaborn, print, display) is stripped automatically.

2. Build the project

# as a direct command (after installation)
mlplant build my_notebook.ipynb --output ./api --port 8080 --title "My API" --docker

# or via python -m (works anywhere)
python -m mlplant build my_notebook.ipynb --output ./api --docker

By default, build now also runs train_pipeline.py in the generated project, so the API starts with ready-to-serve artifacts in artifacts/.

Data files can stay at the project root (for example data/train.csv). During auto-training, mlplant keeps reading data from the notebook/project root, but all generated pipeline outputs are written under the selected output folder.

With --mlflow, if a remote tracking server is unavailable, mlplant automatically falls back to local SQLite tracking (no server required), stored in output/artifacts/mlflow.db.

To generate files only (without training), use:

mlplant build my_notebook.ipynb --output ./api --no-train

3. Inspect detected steps

mlplant inspect my_notebook.ipynb

# or
python -m mlplant inspect my_notebook.ipynb

Supported annotations

Annotation PascalCase alias Generated file Purpose
mlplant.config() mlplant.Config() src/config.py Hyperparameters and constants
mlplant.load_data() mlplant.LoadData() src/data_loader.py Data ingestion
mlplant.preprocessing() mlplant.Preprocessing() src/preprocessing.py Cleaning and null handling
mlplant.features() mlplant.Features() src/features.py Feature engineering
mlplant.train() mlplant.Train() src/trainer.py Model training
mlplant.evaluate() mlplant.Evaluate() src/evaluate.py Metrics and evaluation
mlplant.artifacts() mlplant.Artifacts() src/artifacts.py Model serialization
mlplant.predict() mlplant.Predict() src/predict.py Inference (exposed at /predict)

Build flags

mlplant build <notebook> [OPTIONS]

  --output / -o   Output directory             (default: ./output)
  --port          Server port                  (default: 8000)
  --title         Swagger UI title             (default: "mlplant API")
  --workers       Uvicorn workers              (default: 1)
  --docker        Generate optimized Dockerfile
  --mlflow        Inject MLflow tracking into training
  --ui            Generate React frontend scaffold for inference
  --train         Run generated train pipeline after build (default)
  --no-train      Skip training during build

Output layout after build

Generated code is placed in the output folder (./output by default):

  • output/main.py
  • output/src/*
  • output/train_pipeline.py
  • output/requirements.txt
  • output/predict_request_example.json (payload blueprint for /predict)
  • output/Dockerfile (when --docker is enabled)
  • output/ui/* (when --ui is enabled)

Pipeline runtime artifacts are also kept in the output folder:

  • output/artifacts/models/*.joblib
  • output/artifacts/metadata.json
  • output/artifacts/label_encoder.joblib (when available)
  • output/artifacts/mlflow.db (local MLflow SQLite tracking)
  • output/artifacts/catboost_info/ (CatBoost auxiliary outputs)

When --ui is enabled:

cd output/ui
npm install
npm run dev

The frontend dynamically reads your API OpenAPI schema (/openapi.json) and builds the predict form from the generated InputData contract.

Metadata

Release files for mlplant-cli 0.2.1

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

Source distribution (sdist)

Source distribution for mlplant-cli 0.2.1
File Size Uploaded Provenance Actions
mlplant_cli-0.2.1.tar.gz 36.5 kB Without provenance Details for mlplant_cli-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mlplant-cli 0.2.1
File Interpreter ABI Platform Actions
mlplant_cli-0.2.1-py3-none-any.whl Python 3 none any Details for mlplant_cli-0.2.1-py3-none-any.whl

Total release size: 80.1 kB

Release files / mlplant_cli-0.2.1.tar.gz

Download URL mlplant_cli-0.2.1.tar.gz
Size 36.5 kB
Tags Source
SHA-256 checksum
How to use checksums
27084b9c4724caef870d85be020ad8ed1bc78330745ce858ceb3c5073f0e5405
BLAKE2b-256 checksum
How to use checksums
afd5c80de54c429e7e25a42c9dd6c73f51f74cb15474d97153e248add1e72c7e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Release files / mlplant_cli-0.2.1-py3-none-any.whl

Download URL mlplant_cli-0.2.1-py3-none-any.whl
Size 43.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8e7aa0b8583e44d3cddc100ab276ef1e7b05897d8c429b85dffcc89d84b2d141
BLAKE2b-256 checksum
How to use checksums
f6d3b6523a0c88ae9198a86a98c25af71a0d8f57b0a6efb06c569c454a4b71f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Security for mlplant-cli 0.2.1

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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