Microservice Generation Developer Guide

This is the developers guide to microservice generation.

1.1 What is microservice generation?

Acumos is intended to enable the use of a wide range of tools and technologies in the development of machine learning models including support for both open sourced and proprietary toolkits. Models can be easily onboarded and wrapped into containerized microservices which are interoperable with many other components.

The goal of microservice generation component is to provide an interface to create a wrapper microservice for the models onboarded in Acumos and containerize it along with all the run time dependencies of the model. .

1.2 Target Users

This guide is targeted towards the open source user community that:

  1. Intends to understand the backend functionality of the microservice generation.
  2. Intends to contribute code to enhance the functionality of the microservice generation.

1.3 Assumptions

It is assumed that the ML Models contributed by the open source community:

  1. Provide the basic request response style of communication.
  2. Can be converted in Microservices
  3. Are capable of communicating via Http REST mechanism.
  4. Are developed in Java, Python 3.0, R and sourced from toolkits such as Scikit, TensorFlow, H2O, and RCloud.

5. Model is successfully onboarded in Acumos and Model artifacts are available in Acumos Nexus repository. Artifacts include - Model binary, Protobuf definition for model input/output and service, Metadata.json along with Tosca generator files.

1.4 Microservice generation Design Architecture


Microservice generation exposes API that accepts solution ID for onboarded model, downloads model artifacts and builds docker image for the model. Docker image is pushed to Nexus repository along with log for the dockerization of the model microservice.


1.5 Microservice generation Low Level Design

Modeler/Data scientist creates model using toolkit. Modeler uses Acumos-client-library to push the model to Acumos platform. The client library uploads model and metadata file to Acumos onboarding server.Onboarding server solution, puts model and metadata artifact to repository. Model solution ID is accepted by Microservice generation API. Microservice generation downloads model artifacts - Model binary, protobuf file and metadata.json from Nexus. It parses metdata, creates a docker image and deploys all dependent libraries in docker container. It also deploys model binary in the container. Once docker image is created successfully it is uploaded to Nexus. It logs steps for dockerization and uploads the log as well to Nexus repository. This log is available for user to download and verify docker container or identify issues if dockerization is unsuccessful.


1.6 Onboarding Use Case

Below, the data scientist’s model is wrapped to produce a standardized native model. Depending on the input model, only a subset of standard model interfaces may be supported.

Acumos can then generate a microservice however it wishes. The underlying generic server can only interface with the inner model via the wrapper. This decoupling allows us to iterate upon and improve the wrapper independently of Acumos.


1.7 Microservice generartion Model Artifact

Model artifacts must provide sufficient metadata that enables Acumos to instantiate runtimes, generate microservices, and validate microservice compositions. The proposed solution is to split the model artifact into public and private components.

  • Public
  • Understood by Acumos. Includes metadata on:
  • Model methods and signatures
  • Runtime information
  • Private
  • Opaque to Acumos but understood by the wrapper library.
  • Includes: Serialized model
  • Auxiliary artifacts required by wrapper library
  • Auxiliary artifacts required by model

By splitting the artifact into public and private pieces, the wrapper library has the freedom to independently iterate and improve.


1.8 Microservice generartion Setup


  1. Clone the code from Gerrit Repo:

Repo URL: https://gerrit.acumos.org

Under the dashboard page we have list of Projects,select Microservice generartion Project and clone this project by using below clone command:

git clone ssh://<GERRIT_USER_NAME>@gerrit.acumos.org:29418/microservice-generation

  1. After cloning import this project in your recommended IDE like STS.
  2. Take the maven update so that you can download all the required dependencies for the Microservice generartion Project.
  3. After doing maven update you can run or debug the code by using Spring Boot App but before that we need to set the Environment Variables in our IDE tool for local testing and if you want to read the environment variables once you deployed your code on the dev or IST server than you need to set all the environment variables in system-integration Project.

1.9 Microservice generartion Technology & Framework

  • Java 1.8
  • Spring Boot
  • Spring REST
  • Docker Java Library

1.10 Microservice generartion – Code Walkthrough & details

In Microservice generartion project we have template folder under resources where we are putting all the Docker file with some other dependencies for different Models like h20,java_argus,java_genric,,python,r ,etc.

For example:

For Microservice generartion H20 model we have the h20 Docker file and requirement.txt file attached below inside h20 folder.

Microservice generartion code understands this Docker file related to particular model line by line it reads the commands and performs the action accordingly. It will download all the required dependences accordingly.

Note: Make sure the Docker is installed in the local Machine before try to Onboard the model in by using our local machine Environment.

1.11 Microservice generartion – Docker Image Creation and details

The Microservice generartion server exposes REST API for creating a docker image for a model onboarded in Acumos.

API accepts solution ID for the model in Acumos. The metadata JSON, Model binary and protobuf definition file are downloaded from the repository. The model metadata is used to get the runtime version information, for example python 3.5. This information is used to fetch the runtime template. The runtime template contains template for following files.





Below is the structure:


The above template files are populated based on metadata JSON uploaded by user. Microservice generartion server uses docker-java library for model docker image creation. Once the docker image is created, the image is tagged and pushed to nexus docker registry.The server uses common data micro-services API to create solution and store model and metadata to artifact repository.

1.13 Microservice generartion Backend API


This API is used for actual Microservice and docker image generartion for models after successful authentication of token (APIToken or JWTtoken) shared by user.