Skip to content

Guides | Rest API

ML-TANGO edited this page Oct 6, 2022 · 34 revisions

Rest API Guides

In TANGO, there are two types of container.

  • Main container : Project Manager, which coordinates other containers start and stop to proceed workflow.
  • Member container: All containers except for Project Manager, which perform specific task in whole workflow.

Project Manager keeps the project details and coordinates the member containers task with start() to start the specific taks at the memeber container, periodically (defined as heart beat frequency, default: 2 sec) calls status_request() of the member container to get the member container status. Member container notifies its task success or fail to the Project Manager with `status_report().

classDiagram
    direction LR

    Project Manager "1" .. "n" Member Container

    class Project Manager
    Project Manager: +status_report(container_id=<container_id>, user_id=<user_id>, project_id=<project_id>, status=<status>)

    class Member Container
    Member Container: +start(project_id=<project_id>, user_id=<user_id>)
    Member Container: +stop(project_id=<project_id>, user_id=<user_id>)
    Member Container: +status_request(project_id=<project_id>, user_id=<user_id>)

Loading

Containers should implement the following core Rest API for other containers calls;

Container Type Rest API exposed to other containers
Main Container status_report()
Member Container start(), stop(), status_request()
  • In addition to this core APIs, each container can implement its own private of public APIs if needed.
  • Refer to Guide | TANGO Archtecture for usage of the Rest APIs between Project Manager and Member Containers

Rest APIs provided by the Project Manager

As a whole workflow coordinator, the Project Manager should expose following APIs for member containers reports its task status using following status_report() function when it succeed or fail it's own task;

status_report(container_id=<container_id>, user_id=<user_id>, project_id=<project_id>, status=<status>)

container_id indicates the container id who reports the status. possible values for <container_id> are as follows:

  • 'labelling' : Dataset Labeling Tool Container
  • 'visualization' : Model Visualizer Container
  • 'bms' : Base Model Select Container
  • 'backbone_nas' : Backbone NAS Container
  • 'neck_nas' : Neck NAS Container
  • 'code_gen' : Code Generation Container
  • 'cloud_deploy' : Depoyment Container for Cloud target
  • 'ondevice_deploy' : Depoyment Container for OnDevice target

user_id, project_id indicate the project user's ID and project ID respectively, which were delivered parameters via start() from Project Manager to Member container.

status indicates whether the task in the member container is success or failed possible values for <status> are as follows:

  • 'success' : successful completion of the task in the member container
  • 'failed' : failuer of the task in the member container

Rest APIs provided by the member containers

All member containers should expose following core APIs for Project Manager start/stop the member container's task and query on the task status;

start(project_id=<project_id>, user_id=<user_id>)

user_id, project_id indicate the project user's ID and project ID respectively.

The Project Manager calls start() exposed by member container in order to make the member container start its task.

  • The Member Container should respond with the HTTP response with body of txt/plain starting.
stop(project_id=<project_id>, user_id=<user_id>)

user_id, project_id indicate the project user's ID and project ID respectively.

The Project Manager calls start() exposed by member container in order to make the member container stop its task.

  • The Member Container should respond with the HTTP response with body of txt/plain stopping.
status_request(project_id=<project_id>, user_id=<user_id>)

user_id, project_id indicate the project user's ID and project ID respectively.

The Project Manager peerodically (defined by its internal frequency) calls status_request() exposed by member container in order to check the task status in the member container.

  • The Member Container should respond with the HTTP response with body one of the followings;
  • "started" : already started its task.
  • "stopped" : stopped it task for response to sto() call or any internal reason.
  • "running" : currently running its task
  • "completed": finishes its task successfully.
  • "failed": fails to complete its task.

Member container state

stateDiagram-v2
  [*] --> Started : start()
  Started --> Running
  Started --> Failed: Internal Error
  Started --> Stopped: stop()
  Running --> Stopped: stop()
  Running --> Failed: Internal Error
  Running --> Completed
  Failed --> [*]
  Stopped --> [*]
  Completed --> [*]

Loading