Getting started

Using the omni.services.* extensions and Omniverse Kit’s –exec command-line option makes it easy to get started with services. As the service evolves and grows it might be worth turning the service itself into an Extension so that it is easy to ship and distribute. Doing so will also give all the power of extensions to services with the possibilities to set up dependencies on other extensions, install additional python packages and take advantage of the settings framework.

Basic service

Starting with a very simple hello world example:

hello_world.py
1from omni.services.core import main
2
3def hello_world():
4  return "hello world"
5
6main.register_endpoint("get", "/hello-world", hello_world)

That is all that is needed to write a service. To run the newly created service, the ‘kit’ executable is required, which can be obtained in one of two ways:

  1. Local Installation: Install Omniverse Kit via the Omniverse Launcher. After installation, the ‘./kit’ executable will be located in the installation directory.

  2. Docker Container: Alternatively, a Kit Docker container is available on NVIDIA GPU Cloud (NGC). For instructions on using the Kit Docker container, refer to the Container instructions.

To execute your service with Omniverse Kit and an HTTP transport, use the path to your service script along with the following command-line arguments:

kit --exec hello_world.py \
  --enable omni.services.core \
  --enable omni.services.transport.server.http \
  --/exts/omni.kit.registry.nucleus/registries/0/name=kit/services \
  --/exts/omni.kit.registry.nucleus/registries/0/url=https://dw290v42wisod.cloudfront.net/exts/kit/services

The omni.kit.registry.nucleus settings make sure that the Omniverse services extensions can be found and downloaded as by default they do not ship with the kit-sdk.

Omniverse services automatically generate interactive API documentation, which is readily accessible at the following URL by default:

http://localhost:8011/docs

This interactive documentation page enables direct experimentation with the API. Utilize the Try it out feature available for each endpoint to test API functionality. Keep in mind that this documentation is auto-generated and reflects the current configuration of your service.

For a more comprehensive and customized documentation experience, consider adding new endpoints and providing detailed descriptions for each. This will further enrich the documentation, making it more informative and user-friendly.

Advanced services

A more involved example is available at the following GitHub Repository: https://github.com/NVIDIA-Omniverse/deep-dive-into-microservices

Omniverse Kit ships with several more advanced services and more are available in the extension registry and Omniverse Farm is also fully built using the microservices stack within Omniverse and is made up several different services. Its code is available from the Omniverse Launcher after which its code can be explored.