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:

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.0

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.0
File Size Uploaded Provenance Actions
mlplant_cli-0.2.0.tar.gz 36.3 kB Without provenance Details for mlplant_cli-0.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 79.5 kB

Release files / mlplant_cli-0.2.0.tar.gz

Download URL mlplant_cli-0.2.0.tar.gz
Size 36.3 kB
Tags Source
SHA-256 checksum
How to use checksums
4dcbc64a6efad7c7606a48e94ce0b8df92014fe3258cc0e0a2c91278ec74f7ed
BLAKE2b-256 checksum
How to use checksums
c48f3e64437f7aee0a0532781ef3fc961648680ba742a68b7c32ba81e9f66de2
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.0-py3-none-any.whl

Download URL mlplant_cli-0.2.0-py3-none-any.whl
Size 43.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fbc152638262ac5fb1704e155ad73e05ef1bf3fcc3e0a81d22f3386f3d033167
BLAKE2b-256 checksum
How to use checksums
e359a2d8884d67332942d0568c4455b5aa8f061a07946d6ec3e7b2ae31f82b78
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.0

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