Deployment

When are happy with your model pipeline's accuracy, then you can deploy it into production with a single command.

Deploy from CLI

Typically, you will wrap your model in a compact predict function and place it inside a predict.py file (you can call this file anything). Before we deploy update the roro.yml file with details of the API such as name, function to be deployed as a service, size of the inference hardware (optional), cors setting (optional, but useful if you plan to call the API from JavaScript)

# roro.yml

project: image-recognition-demo
runtime: python3-keras

services:
  - name: default
    function: predict.predict
    size: S1
    cors_allow_origins: "*"

Now, deploy

# Ensure we are in the project root
$ roro deploy
Deploying project image-recognition-demo. This may take a few moments ...
Building docker image ... done
Updating scheduled jobs ... done
Started 1 service.

    default: https://image-recognition-demo.rorocloud.io/

Deployed version 1 of image-recognition-demo project

That's it! The platform selects the hardware, builds an image, installs the runtime, installs all the dependencies and packages. The entire code is synchronized and executed on the remote server. Your API is now ready for use. You can share the API with you developers. You can instrospect using roro logs <JOB_ID> command.

Consume Endpoint

The endpoint is RESTful so it can be consumed by any standard requests library. However we have a powerful roro client library which you can use.

>> import roro
>> URL_IMAGE = "https://rorodata-tmp.s3.amazonaws.com/ring-tailed-lemur.jpg"
>> api = roro.Client("https://image-recognition-demo.rorocloud.io/")
>> api.predict(image={"url": URL_IMAGE})

[{'label': 'Madagascar cat, ring-tailed lemur, Lemur catta',
  'probability': 0.9753402471542358},
 {'label': 'indri, indris, Indri indri, Indri brevicaudatus',
  'probability': 0.021191151812672615},
 {'label': 'badger', 'probability': 0.0033273231238126755},
 {'label': 'weasel', 'probability': 4.032577999169007e-05},
 {'label': 'meerkat, mierkat', 'probability': 3.0121240342850797e-05}]
>>

Kill Endpoint

Stop the endpoint from the dashboard by clicking on the Stop button in the Active Service table of the Project Dashboard. It is also easy to stop the endpoint from CLI using roro stop command.

$ roro stop 5b39921e

Feedback

Help us improve the documentation. Flag errors, issues or request how-tos, guides and tutorials on our #documentation channel on our Slack.