Transforming a Jupyter Notebook into an API service

Titan Tutorial #1: Hello World!

In this first tutorial, we will explain how to deploy the simplest imaginable to illustrate how easy is to transform models into services using Titan, our flagship product at Akoios. Let’s get started!

First step to get started is to open the editor of your choice (Anaconda Distribution, Google Colab or any other).

Now, we are ready to write a very simple Python code in one of the notebook cells ():

A very simple cell printing Hello world

The code in the cell just prints “Hello world!” when executed. Imagine now that you want to make this available as a service using a REST API interface.

Here is where Titan comes into play. a notebook with Titan is as easy as following these steps:

  • Select the HTTP method for the service (GET, PUT, POST, DELETE)
  • Define an arbitrary name for the endpoint

To define this it is just needed to write at the top of the cell we want to be executed every time the endpoints is called. To make it understandable for Titan, this information must be written after the character in Python.

“Instrumentalized” notebook

In this cell, we are telling Titan the following:

Pretty simple, right?

Now that our “model” is ready, we can use Titan to transform it into a service. It’s as simple as running the command:

$ titan deploy
Running $ titan deploy

What we just did? When running this is what happens:

  • Titan shows you all the notebook files () located in the current folder
  • You are requested to select one ( in our case)
  • Then, you are requested to select the desired runtime environment, we used the for this simple example.

That’s all. Here’s where Titan starts doing its magic:

  • Build the project
  • Deploy the model
  • Start the service

By the end of the execution of the command, you will have a ready-to-use REST API endpoint located at a location like this:

Magic!

In order for an API to make sense, it must be easily accessed and well documented. In that sense, Titan includes a Swagger UI interface at that URL with relevant information about the API and the model. Swagger UI also allows to interact with the API’s resources:

Automagically-generated API description

You can even make a call to the endpoint clicking on the “Try it out” button!

After trying and, as expected, this is what you will get from the API call:

Server response. No surprises!

Let’s now try to consume the service from an external application like Postman. For an easy call like this one, it is just required to provide the following information:

Consuming the endpoint from Postman. Easy-peasy!

In case it helps, you can get the code in this repository.

Wrap-up

In this first edition of our series of tutorials we have seen how to seamlessly deploy a very simple piece of code using our product Titan. After that, we have seen how to consume the service straight from the Swagger UI interface and using Postman.

Next Tutorial

You can keep learning about how to use Titan in our next tutorial where we deploy our first ML model!

Foreword

Titan can help you to radically reduce and simplify the effort required to put AI/ML models into production, enabling Data Science teams to be agile, more productive and closer to the business impact of their developments.

If you want to know more about how to start using Titan or getting a free demo, please visit our website or drop us a line at info@akoios.com.

If you prefer, you can schedule a meeting with us here.

Akoios: Frictionless solutions for modern data science.

Akoios