ModelGate 🚀
Containerized machine learning inference API with zero boilerplate.
A trained model sitting in a Jupyter Notebook proves nothing about production readiness. ModelGate bridges the gap between data science experiments and software engineering by providing a robust, dynamic, and safe microservice for tabular ML models (Scikit-Learn, Joblib, Pickle).
✨ Key Features
- Dynamic Artifact Loading: Instantly serve
.joblibor.pklmodels by simply providing a local path or a direct HTTP URL. The API downloads and loads it on startup. - Strict, Dynamic Input Validation: Pass a
schema.jsonvia environment variables. ModelGate usesjsonschemato ensure malformed data never reaches your model. - Out-of-the-box Ready: Defaults to downloading and serving a public Scikit-Learn Iris classification model so you can test integrations immediately.
- Error Shielding: Overridden Exception Handlers strictly prevent Python stack traces from leaking to the client,
returning standardized, safe JSON
422and500errors. - Docker-Native & SDK-Ready: Fully containerized for microservice use, or importable as a native Python SDK into existing codebases.
📖 Documentation
Dive deeper into the specific subsystems:
- 🌐 API Reference: Endpoints, request payloads, and example curl commands.
- ⚙️ Usage & Configuration: Environment variables, Schema validation, Model URL loading, and SDK implementation.
- 🏗️ Architecture & Design: System flow, Mermaid diagrams, and error shielding concepts.
- 🧪 Testing Standards: Pytest strategies, coverage, and CI checks.
- 🧹 Code Quality: Pre-commit, Ruff linting, and formatting.
⚡ Quickstart: Zero to Inference
1. Run the Default Model (Local API)
By default, ModelGate automatically downloads a Scikit-Learn Logistic Regression model (Iris dataset) and enforces its JSON schema.
# Install dependencies
pip install -e .[dev]
# Start the server
uvicorn modelgate.main:app --reload
Test the endpoint:
curl -X POST "http://localhost:8000/api/v1/predict" \
-H "Content-Type: application/json" \
-d '{
"features": {
"sepal_length": 5.1,
"sepal_width": 3.5,
"petal_length": 1.4,
"petal_width": 0.2
}
}'
Response: {"prediction": "setosa", "model_version": "v1.0.0"}
2. Use as a Python SDK
ModelGate isn't just a standalone API—it can be used programmatically in your Python code as a lightweight SDK.
from modelgate import ModelGate
gate = ModelGate()
gate.load_model(
model_path="https://huggingface.co/DmytroSerbeniuk/my-iris-model/resolve/main/model.joblib",
model_type="joblib",
schema="default_schema.json"
)
# Validates input against schema and executes model inference securely
result = gate.predict({
"sepal_length": 5.1,
"sepal_width": 3.5,
"petal_length": 1.4,
"petal_width": 0.2
})
print(result) # Output: "setosa"
3. Run with your own Real Model (Docker)
Have your own .joblib model? Let's deploy it.
- Create an
.envfile pointing to your assets:
MODEL_ARTIFACT_TYPE=joblib
MODEL_ARTIFACT_PATH=https://github.com/your-username/your-repo/raw/main/model.joblib
INPUT_SCHEMA_PATH=my_custom_schema.json
- Build and Run:
docker build -t modelgate .
docker run -p 8000:8000 --env-file .env modelgate
Your Scikit-Learn model is now securely exposed via a REST API!
🤝 Contributing
We welcome contributions! Please check out our Contributing Guidelines for details on our strict Conventional Commits requirement, automated release process, and local setup.
📝 License
Distributed under the MIT License. See LICENSE for more information.
Metadata
Release files for modelgate-py 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| modelgate_py-0.3.0.tar.gz | 12.8 kB | Without provenance | Details for modelgate_py-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| modelgate_py-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for modelgate_py-0.3.0-py3-none-any.whl |
Total release size: 24.2 kB
Release files / modelgate_py-0.3.0.tar.gz
| Download URL | modelgate_py-0.3.0.tar.gz |
|---|---|
| Size | 12.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
19b8401bdd270bf4d6fe377f65eefa0487dd72bee3f3612966ebffc6dfbf4d88
|
|
BLAKE2b-256 checksum How to use checksums |
16ba701234b809d78bdf5a420404839d3ba0b86d1c7ba77abe9712174c676cea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.0
|
Release files / modelgate_py-0.3.0-py3-none-any.whl
| Download URL | modelgate_py-0.3.0-py3-none-any.whl |
|---|---|
| Size | 11.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
44ca1794b5af2a167e8d0694b043edfd5c72e7fa6e2ae0c92d51a5a28078e051
|
|
BLAKE2b-256 checksum How to use checksums |
554a44c9f1c927a1cf7f1fffbef1c0cbd0c3b64dc5962040262b524e842f567a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.0
|
Security for modelgate-py 0.3.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.