Skip to main content

A CLI tool for deploying ML models as production-ready REST APIs

Project description

DeployWizard

Python Version License: MIT Tests Code style: black

DeployWizard is a powerful CLI tool that automates the deployment of machine learning models as production-ready REST APIs with Docker support. It generates all the necessary code and configuration files to containerize your ML models with FastAPI, making deployment a breeze.

Features

  • Multi-Framework Support: Works with scikit-learn, PyTorch, and TensorFlow models
  • Production-Ready: Generates Dockerfiles and optimized FastAPI applications
  • Environment-Aware: Handles both development and production environments
  • Secure by Default: Uses non-root users in containers and secure defaults
  • Easy to Use: Simple CLI interface for generating deployment code
  • Customizable: Flexible template system for advanced customization
  • Tested: Comprehensive test suite with 100% code coverage

Installation

  1. Create and activate a virtual environment (recommended):

    python -m venv venv
    source venv/bin/activate  # On Windows use: venv\Scripts\activate
    
  2. Install DeployWizard using pip:

    pip install deploywizard
    
  3. Verify installation:

    deploywizard --version
    

Quick Start

1. Register a Model

# Register a scikit-learn model
deploywizard register iris_model.pkl --name iris_classifier --version 1.0.0 --framework sklearn --description "Iris classifier with 95% accuracy"

# Register a PyTorch model
deploywizard register sentiment_model.pt --name sentiment_analyzer --version 2.1.0 --framework pytorch --description "BERT-based sentiment analysis"

# Register a TensorFlow model
deploywizard register image_model.h5 --name image_classifier --version 3.0.0 --framework tensorflow --description "CNN for image classification"

2. List and Inspect Models

# List all registered models
deploywizard list
# Output:
# ┏━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓
# ┃ Name                ┃ Version ┃ Framework ┃ Description                                      ┃ Registered At ┃
# ┡━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩
# │ test-model          │ 1.0.0   │ sklearn   │ Test model                                       │ 2025-06-23    │
# │ test-model-db0357e8 │ 1.0.0   │ sklearn   │ Test model                                       │ 2025-06-23    │
# │ sklearn_test_model  │ 1.0.0   │ sklearn   │ Logistic regression model trained on 100         │ 2025-06-23    │
# │                     │         │           │ samples, ...                                     │               │
# └─────────────────────┴─────────┴───────────┴──────────────────────────────────────────────────┴───────────────┘

# Get detailed info about a specific model
deploywizard info --name sklearn_test_model
# Output:
# 
# Model Information
#   • Name: sklearn_test_model
#   • Version: 1.0.0
#   • Framework: sklearn
#   • Path: /path/to/test_models/sklearn_model.pkl
#   • Registered: 2025-06-23T12:35:12.495113+00:00
#
# Description:
#   Logistic regression model trained on 100 samples, 4 features and 2 classes.

3. Deploy a Model

# Deploy a specific version of a model
deploywizard deploy --name sklearn_test_model --version 1.0.0 --output sklearn_test_model_api
# Output:
# Deploying sklearn_test_model (version: 1.0.0)...
# Generating project for sklearn_test_model v 1.0.0
# Output directory: sklearn_test_model_api
# [SUCCESS] Model file copied to /path/to/sklearn_test_model_api/app/sklearn_model.pkl
# [SUCCESS] Project generated successfully in sklearn_test_model_api
# Successfully deployed sklearn_test_model to sklearn_test_model_api
#
# Next steps:
# 1. cd sklearn_test_model_api
# 2. docker-compose up --build
#
# Your API will be available at http://localhost:8000
# API documentation: http://localhost:8000/docs

# Or deploy the latest version (omitting --version)
deploywizard deploy --name sklearn_test_model --output my_model_api

4. Run the Deployed API

After deploying, navigate to the output directory and start the API:

cd sklearn_test_model_api
docker-compose up --build

Once the containers are up and running, you can access:

5. Test the API

You can test the API using curl or any HTTP client:

# Health check
curl http://localhost:8000/health
# Expected output: {"status":"healthy"}

# Make predictions (example for a scikit-learn model)
curl -X POST http://localhost:8000/predict \
  -H "Content-Type: application/json" \
  -d '{"data": [[5.1, 3.5, 1.4, 0.2]]}'

Testing

DeployWizard includes a comprehensive test suite. To run the tests:

# Install test dependencies
pip install -e ".[test]"

# Run all tests
pytest -v

# Run tests with coverage report
pytest --cov=deploywizard --cov-report=term-missing

# Run a specific test file
pytest tests/test_cli.py -v

Troubleshooting

Common Issues

  1. Model not found

    • Ensure the model file exists at the specified path
    • Verify the framework is correctly specified
  2. Port already in use

    • Stop any containers using port 8000
    • Or specify a different port: docker run -p 8080:8000
  3. Docker build fails

    • Check your internet connection
    • Verify Docker is running
    • Check the Docker logs for specific error messages
  4. UnicodeDecodeError on Windows

    • Ensure your terminal supports UTF-8 encoding
    • Set the following environment variable: set PYTHONUTF8=1

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a new branch for your feature
  3. Commit your changes with descriptive messages
  4. Push to the branch
  5. Create a new Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Built with ❤️ using FastAPI and Docker
  • Inspired by the need for simple ML model deployment solutions
  • Thanks to all contributors who have helped improve this project!

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

deploywizard-0.0.1.23062025.tar.gz (27.5 kB view details)

Uploaded Source

Built Distribution

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

deploywizard-0.0.1.23062025-py3-none-any.whl (20.8 kB view details)

Uploaded Python 3

File details

Details for the file deploywizard-0.0.1.23062025.tar.gz.

File metadata

  • Download URL: deploywizard-0.0.1.23062025.tar.gz
  • Upload date:
  • Size: 27.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for deploywizard-0.0.1.23062025.tar.gz
Algorithm Hash digest
SHA256 955883bb84377f2033605c0004e5c956ae1eb1eac8040e991e8bf62094a261be
MD5 ed6c0269864b4dde941ea5dfce3bad4e
BLAKE2b-256 c18395f4b96a40e40a37d9a2ac8642a8b11b773e2791aec6712d5479e2631979

See more details on using hashes here.

File details

Details for the file deploywizard-0.0.1.23062025-py3-none-any.whl.

File metadata

File hashes

Hashes for deploywizard-0.0.1.23062025-py3-none-any.whl
Algorithm Hash digest
SHA256 5966ed5491ad288bd32de47703be576ef80daa6d76ca25abb82e471297dfcedd
MD5 81b599e75c41935752e061a808f11d47
BLAKE2b-256 9faa8a27bc345c7c33e69b80fa211c951a72557d56ee7c86f390a9ea0b41ae57

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