Skip to content

Tutorial - Gapi Micro Services

A Micro Service is a process that runs a wrapper python script that integrates your custom code/models so they can integrate into Gapi Workflows.

You can run a Micro Service wherever you like and connect it to a Gapi Server via the streaming, hybrid binary+json message protocol.

There are some out-of-the-box β€œCommunity Micro Services" that we integrate, test and pack into Docker images. When you run them, they auto integrate, load NVIDIA layers correctly and offer logging to the host system.

Even better, create your own! Just implement an on_message Python handler to process requests and respond. The rest is handled for you.

Think of a Micro Service as a simple wrapper to some code or model you have. It works the same as any other Node inside a Workflow. When it's your Micro Service Node's turn your on_message function will be called. Your script gets the rolling Transaction data for context and you then publish your data directly back into the flow.

Running the Community Micro Services

Requirements for Community Micro Services

  1. One of the following Jetson devices:

    Jetson AGX Orin (64GB) Jetson AGX Orin (32GB) Jetson Orin NX (16GB) Jetson Orin Nano (8GB) Jetson Orin Nano (4GB)

  2. Running one of the following versions of JetPack:

    JetPack 5 (L4T r35.x) JetPack 6 (L4T r36.x)

  3. Sufficient storage space.

    • Literally 4KB for your own Micro Service
    • Anywhere from ~4GB to ~10GB for each Community Micro Service
#1 Login and go to the Micro Services tab
#2 Follow the instructions in the blue box on that page to download your custom configuration
#3 Then follow the instructions below that for installing the Micro Service you want

Example of instruction page:

Congrats! You Can Go Through the Workflow Tips Now

Creating Your Own Micro Service

The entire Micro Service zip file is just 4KB with 4 files:

  • message_handler.py: for you to respond
  • message.py: for the streaming binary/json protocol
  • gapi-ms: as entry point and handler)
  • requirements.txt: defines just asyncio + websockets

Full documentation here: Gapi Micro Service Docs. Synopsis below...

#1 Create logical Micro Service in UI and copy the key
#2 Download the zip file from the UI
#3 python gapi-ms.py ws://0.0.0.0:8090/gapi-ws [MICROSERVICE_KEY]
#4 Refresh the UI to confirm it's online
#5 Edit the message_handler.py to handle binary+json input and change the output
#6 Add a Micro Service Node to a Workflow and tie it to your Micro Service. Hit Test.