Giter VIP home page Giter VIP logo

budgetml's Introduction

BudgetML: Deploy ML models on a budget

InstallationQuickstartCommunityDocs

PyPI - ZenML Version PyPI - Python Version PyPI Status GitHub

Notice: This library is not being actively maintained, and we're looking for someone to update it and keep it going! Reach out to me directly if you would like to help!

Why

BudgetML is perfect for practitioners who would like to quickly deploy their models to an endpoint, but not waste a lot of time, money, and effort trying to figure out how to do this end-to-end.

We built BudgetML because it's hard to find a simple way to get a model in production fast and cheaply.

  • Cloud functions are limited in memory and cost a lot at scale.

  • Kubernetes clusters are overkill for one single model.

  • Deploying from scratch involves learning too many different concepts like SSL certificate generation, Docker, REST, Uvicorn/Gunicorn, backend servers etc., that are simply not within the scope of a typical data scientist.

BudgetML is our answer to this challenge. It is supposed to be fast, easy, and developer-friendly. It is by no means meant to be used in a full-fledged production-ready setup. It is simply a means to get a server up and running as fast as possible with the lowest costs possible.

BudgetML lets you deploy your model on a Google Cloud Platform preemptible instance (which is ~80% cheaper than a regular instance) with a secured HTTPS API endpoint. The tool sets it up in a way that the instance autostarts when it shuts down (at least once every 24 hours) with only a few minutes of downtime. BudgetML ensures the cheapest possible API endpoint with the lowest possible downtime.

Key Features

Cost comparison

BudgetML uses Google Cloud Preemptible instances under-the-hood to reduce costs by 80%. This can potentially mean hundreds of dollars worth of savings. Here is a screenshot of the e2-highmem GCP series, which is regular family of instances to be using for memory intense tasks like ML model inference functions. See the following price comparison (as of Jan 31, 2021 [source])

GCP costs

Even with the lowest machine_type, there is a $46/month savings, and with the highest configuration this is $370/month savings!

Installation

BudgetML is available for easy installation into your environment via PyPI:

pip install budgetml

Alternatively, if you’re feeling brave, feel free to install the bleeding edge:

NOTE: Do so at your own risk; no guarantees given!

pip install git+https://github.com/ebhy/budgetml.git@main --upgrade

Quickstart

BudgetML aims for as simple a process as possible. First set up a predictor:

# predictor.py
class Predictor:
    def load(self):
        from transformers import pipeline
        self.model = pipeline(task="sentiment-analysis")

    async def predict(self, request):
        # We know we are going to use the `predict_dict` method, so we use
        # the request.payload pattern
        req = request.payload
        return self.model(req["text"])[0]

Then launch it with a simple script:

# deploy.py
import budgetml
from predictor import Predictor

# add your GCP project name here.
budgetml = budgetml.BudgetML(project='GCP_PROJECT')

# launch endpoint
budgetml.launch(
    Predictor,
    domain="example.com",
    subdomain="api",
    static_ip="32.32.32.322",
    machine_type="e2-medium",
    requirements=['tensorflow==2.3.0', 'transformers'],
)

For a deeper dive, check out the detailed guide in the examples directory. For more information about the BudgetML API, refer to the docs.

Screenshots

Interactive docs to test endpoints. Support for Images. Interactive docs

Password-protected endpoints: Password protected endpoints

Simple prediction interface: Simple Prediction Interface of BudgetML

Projects using BudgetML

We are proud that BudgetML is actively being used in the following live products:

ZenML: For production scenarios

BudgetML is for users on a budget. If you're working in a more serious production environment, then consider using ZenML as the perfect open-source MLOps framework for ML production needs. It does more than just deployments, and is more suited for professional workplaces.

Proudly built by two brothers

We are two brothers who love building products, especially ML-related products that make life easier for people. If you use this tool for any of your products, we would love to hear about it and potentially add it to this space. Please get in touch via email.

Oh and please do consider giving us a GitHub star if you like the repository - open-source is hard, and the support keeps us going.

budgetml's People

Contributors

bradleybonitatibus avatar dependabot[bot] avatar htahir1 avatar strickvl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

budgetml's Issues

[BUG] Sensitive information leaked in Log

Describe the bug
FastAPI username and password are directly logged. It could be a potential security issue as described in CWE-532 in code

To Reproduce
launch_local

Expected behavior
Redacted the username and pasword

Screenshots
N/A

Stack Trace
N/A

** Context (please complete the following information):**
N/A

Additional information
N/A

[FEATURE] Quickstart example for sockeye

Is your feature request related to a problem? Please describe.
I'm not sure how to run a sockeye (https://github.com/awslabs/sockeye) model with budgetml

Describe the solution you'd like
A quickstart example to run a sockeye model. For example the model built in https://awslabs.github.io/sockeye/tutorials/wmt.html .

Describe alternatives you've considered
Using https://github.com/jamesewoo/sockeye-serving/tree/master/src/sockeye_serving or writing FastAPI endpoints that import sockeye.

Additional context
https://github.com/jamesewoo/sockeye-serving/tree/master/src/sockeye_serving does not seem to be in active development.

Extra files/scripts in Docker container

Hi @htahir1 , thanks for the super handy library !

I am wondering whether or not it is possible to include some extra python file when creating the Docker container?
I am attempting to infer a custom model and thus I need a bunch of files like: checkpoint, model file, config and so on..
I couldn't find anything mentioning this in the docs.

Thanks for your help 😄

[BUG]

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Stack Trace
If applicable, add the error stack trace to help explain your problem.

** Context (please complete the following information):**

  • OS: [e.g. Ubuntu 18.04]
  • Python Version: [e.g. 3.6.6]
  • BudgetML Version: [e.g. 0.1.0]

Additional information
Add any other context about the problem here.

Location error

Describe the bug
As a newbie in GCP, I'm trying to run BudgetML with the "getting started" code shared. After setting up GCP, and running run_budget_ml.py (which contains the budget_ml.launch() call), I get the following error:

Traceback (most recent call last):
File "run_budget_ml.py", line 24, in
budgetml.launch(
File "/Users/yadapruksachatkun/opt/anaconda3/lib/python3.8/site-packages/budgetml/main.py", line 321, in launch
self.create_scheduler_job(
File "/Users/yadapruksachatkun/opt/anaconda3/lib/python3.8/site-packages/budgetml/main.py", line 266, in create_scheduler_job
create_gcp_scheduler_job(project_id, topic, schedule, region)
File "/Users/yadapruksachatkun/opt/anaconda3/lib/python3.8/site-packages/budgetml/gcp/scheduler.py", line 30, in create_scheduler_job
response = client.create_job(
File "/Users/yadapruksachatkun/opt/anaconda3/lib/python3.8/site-packages/google/cloud/scheduler_v1/services/cloud_scheduler/client.py", line 595, in create_job
response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
File "/Users/yadapruksachatkun/opt/anaconda3/lib/python3.8/site-packages/google/api_core/gapic_v1/method.py", line 145, in call
return wrapped_func(*args, **kwargs)
File "/Users/yadapruksachatkun/opt/anaconda3/lib/python3.8/site-packages/google/api_core/grpc_helpers.py", line 75, in error_remapped_callable
six.raise_from(exceptions.from_grpc_error(exc), exc)
File "", line 3, in raise_from
google.api_core.exceptions.InvalidArgument: 400 Location must equal us-west2 because the App Engine app that is associated with this project is located in us-west2

My app engine region is us-west-2, and I also set my project region to us-west-2. What region should I be setting?
Thank you!

[BUG] Better alignment with REST API: send 500 not 400 if predictor couldn't get loaded

Describe the bug
Hi! first of all, thanks for such a neat tool! 🎉

It's not a bug, I just thought that sending HTTP 400 is not good when the predictor couldn't get loaded (all /predict* routes):

@app.post("/predict/")
async def predict(request: Request,
_: str = Depends(verify)) -> Response:
global PREDICTOR
if PREDICTOR is None:
raise HTTPException(
status_code=400,
detail="The predictor could not be loaded. Please check the logs "
"for more detail.",
)

I think, it's better to use a 5XX server-side error:

  • HTTP 400 means that there was a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).
  • HTTP 500 means that the server encountered an unexpected condition that prevented it from fulfilling the request. This error response is a generic "catch-all" response. Usually, this indicates the server cannot find a better 5xx error code to response.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.