Package: mllaunchpad
ML Launchpad lets you easily make Machine Learning models available as
REST API (or any kind of microservice). It also offers lightweight model life cycle
management functionality.It creates a separation between machine learning
models and their environment. This way, you can run your model with
differentdata sources.
and on different environments, by just swapping
out the configuration, no code changes required. ML Launchpad makes your
model available as a business-facingRESTful APIwithout extra coding.Currently, some basic model life cycle management is supported. Training
automatically persists a model in the model store together with its metrics,
and automatically retrieves it for launching its API or
re-training. Previous models are backed up.The full documentation is available athttps://mllaunchpad.readthedocs.io.To learn more about the rationale and structure of ML Launchpad,
seeDescription.Getting started$pipinstallmllaunchpadDownload theexample filesfrom the ML Launchpad GitHub repo. Some of them might require the installations
of some extra packages (e.g. scikit-learn), depending on what they demonstrate.For more about installation, or if you don’t want to usepipand instead install from source (as a user), please see the sectionInstallation.If you want to work on ML Launchpad itself, seeContributing.What’s in the box?If you downloaded the source, you see several subfolders, wheremllaunchpadis the actual ML Launchpad package and the rest are examples and
development tools. You can safely ignore anything except the examples.Theexamplescontain a few example model implementations.
Look here for inspiration on how to use this package. Every model here
consists of at least three files:<examplename>_model.py: the example’s actual model code<examplename>_cfg.yml: the example’s configuration file<examplename>.raml: example’s RESTful API specification.
Used, among others, to parse and validate parameters.There are also some extra files, like CSV files to use, ordatasource.
extensions.The subfoldertestservercontains an example for running a REST API
in gunicorn behind nginx.Try Out the ExamplesIn the following, it is assumed thatmllaunchpadisinstalledand
theexamplesare located in the current directory.To train a very,verysimple example model whose job it is to add two
numbers, use the command:$mllaunchpad-caddition_cfg.ymlt(We give it a config file after the-cparameter, andtis
short for the commandtrain. There’s also a parameter-hto
print help. For all details of the command line interface, see
theUsage section.)Some log information is printed (you can give it a log-config file to
change this, see examples/logging_cfg.yml). At the end, it should say
“Created and stored trained model”, followed by something about metrics.This created a model_store if it didn’t exist yet (which for now is just
a directory). For our examples, the model store is conveniently located
in the same directory. It contains our persistedadditionmodel and
its metadata.To re-test the previously trained model, use the commandr:$mllaunchpad-caddition_cfg.ymlrTo run a (debugging-only!) REST API for the model, use the commanda:$mllaunchpad-caddition_cfg.ymlaTo quickly try out out our fancy addition model API, open this link in a
browser:http://127.0.0.1:5000/add/v0/sum?x1=3&x2=2(curl"http://127.0.0.1:5000/add/v0/sum?x1=3&x2=2"on the command
line)What next?Have a look at theadditionexample’s python code (and comments),
its yml config, then look at the other examples. First, we suggest thetreeexample for intermediate complexity (although its prediction
code does quite some complex stuff to be compatible with three different
kinds of prediction usage, which is not really that realistic).If you are wondering about the RAML file (which is a RESTful API
specification standard that is used in some corporate environments, and
a good idea in general), also look at theg(generate-raml) command
line parameter, which does a lot of work (almost all of it, in fact) for
getting you started with a first RAML.To learn how to use ML Launchpad, seeUsage.For more details on how ML Launchpad actually works and why we created it,
seeIn Depth.TroubleshootingIn case the console commandmllaunchpad <your_arguments>is not recognized,
try:$python-mmllaunchpad<your_arguments>If you get an error likeNo module named 'your_model', the fileyour_model.pyis not in the python path. You can try to set thePYTHONPATH environment variableto the path(s) to your file(s), or, if you’re usingmllaunchpadfrom your own python code, append the path(s) tosys.path.If you getModuleNotFoundError: No module named 'mllaunchpad'(inmllaunchpad/__main__.py), try to start flask the following way:$exportFLASK_APP=mllaunchpad.wsgi:application$exportLAUNCHPAD_CFG=addition_cfg.yml$flaskrun(On Windows, usesetinstead ofexport)This problem appears to be connected to Flask restarting in different ways on
different installations. If you know what exactly this is about,please let us
know.