Skip to content

Commit

Permalink
Merge branch 'dev/ptrottier/rest_api_docs' into 'main'
Browse files Browse the repository at this point in the history
Added REST API documentation

See merge request lightspeedrtx/lightspeed-kit!725
  • Loading branch information
SmokedPete committed Aug 6, 2024
2 parents 965d600 + 19fd572 commit b22df40
Show file tree
Hide file tree
Showing 26 changed files with 602 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,6 @@ PIC-V.log

# Ignore internal settings
repo_internal.toml

# Ignore generated documentation
docs/toolkitinterface/remix-toolkitinterface-restapi-docs.html
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Create 2024.4.0-RC.5 build
- REMIX-2988: Added manual CI test to measure app startup times
- REMIX-3401: Added Centralized Generic factory
- REST API Documentation

### Changed
- REMIX-3401: Changed all usages of factories to use the Centralized Generic factory
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/toolkitinterface/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ remix-toolkitinterface-ingesttab.md
remix-toolkitinterface-aitools.md
remix-toolkitinterface-lighting.md
remix-toolkitinterface-shortcuts.md
remix-toolkitinterface-restapi.md
```

62 changes: 62 additions & 0 deletions docs/toolkitinterface/remix-toolkitinterface-restapi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# REST API

The RTX Remix REST API allows users to send and receive information to and from the Toolkit respectively, as well as
trigger actions in the Toolkit (such as starting the ingestion of a given file, etc.) via HTTP requests.

## Finding the Documentation

The documentation for the Remix Toolkit REST API can be accessed in two different ways: **Live**, and **Static**.

To view the list of endpoints exposed by the RTX Remix Toolkit REST API, follow these instructions:

### Live Documentation:

The live documentation is generated when the Remix Toolkit starts up and gives the ability to test the various endpoints
seamlessly directly from the documentation itself.

1) Start the Remix Toolkit
2) Visit the following website in your web browser: [`http://127.0.0.1:8011/docs#/`](http://127.0.0.1:8011/docs#/) or [`http://localhost:8011/docs#/`](http://localhost:8011/docs#/)

**_NOTE: The 2 websites are equivalent and can be used interchangeably_**

### Static Documentation:

The static documentation doesn't require the Remix Toolkit to be installed and running.

1) Visit the [`API documentation page`](./remix-toolkitinterface-restapi-docs.html)

## Understanding the Documentation

When opening the documentation website, you will be greeted with a list of available endpoints. Every row is a unique
endpoint (HTTP Verb + URL) with a unique purpose.

Clicking on said row will reveal more information about the endpoint, including the expected path parameters,
query parameters, request body, etc.

![REST API Documentation](../data/images/remix-toolkitinterface-restapi-overview.png)

### Endpoint Versioning

The Remix Toolkit REST API uses a versioning header to version every endpoint available individually. A dropdown with
the list of available endpoint version headers can be found in the endpoint details with the `Request body` text or
within the `Successful Response` sub-section of the `Responses` section. The header should have the following format:

```
application/lightspeed.remix.service+json; version=1.0
```

## Testing the Endpoints

Endpoints can be easily tested directly in the documentation. To do so, follow these instructions:

1) Expand the endpoint your would like to test
2) Click the `Try it now` button
3) Fill in any required parameters/body
4) Click the `Execute` button
5) In the `Responses` section, look for the `Server response` subsection.
6) You should see a response `Code` and `Details` for the request you sent in the previous step.

![REST API Response](../data/images/remix-toolkitinterface-restapi-request.png)

***
<sub> Need to leave feedback about the RTX Remix Documentation? [Click here](https://github.com/NVIDIAGameWorks/rtx-remix/issues/new?assignees=nvdamien&labels=documentation%2Cfeedback%2Ctriage&projects=&template=documentation_feedback.yml&title=%5BDocumentation+feedback%5D%3A+) <sub>
45 changes: 43 additions & 2 deletions repo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ post_build.commands = [
["${root}/repo${shell_ext}", "stubgen", "-c", "${config}"],
# Generate a shortcut to run the Mass Ingestion CLI in LSS
["${root}/_build/${platform}/${config}/kit/kit${exe_ext}", "${root}/_build/${platform}/${config}/apps/lightspeed.app.trex.validation_cli_generator.kit", "--no-window", "--/app/extensions/excluded/0='omni.kit.splash' --/app/extensions/excluded/1='omni.kit.window.splash' --/app/settings/persistent=0 --/app/settings/loadUserConfig=0 --/structuredLog/enable=0 --/app/hangDetector/enabled=0 --/crashreporter/skipOldDumpUpload=1 --/app/content/emptyStageOnStart=1", "--/app/file/ignoreUnsavedOnExit=1", "--/app/fastShutdown=1", "--/app/quitAfter=10", "--exec", "${root}/tools/custom/generate_mass_cli.py"],
["${root}/_build/${platform}/${config}/kit/kit${exe_ext}", "${root}/_build/${platform}/${config}/apps/omni.flux.app.service.documentation_cli_generator.kit", "--no-window", "--/app/extensions/excluded/0='omni.kit.splash' --/app/extensions/excluded/1='omni.kit.window.splash' --/app/settings/persistent=0 --/app/settings/loadUserConfig=0 --/structuredLog/enable=0 --/app/hangDetector/enabled=0 --/crashreporter/skipOldDumpUpload=1 --/app/content/emptyStageOnStart=1", "--/app/file/ignoreUnsavedOnExit=1", "--/app/fastShutdown=1", "--/app/quitAfter=10", "--exec", "${root}/tools/custom/generate_service_docs_cli.py"],
]

[repo_build.fetch.pip]
Expand Down Expand Up @@ -366,9 +367,11 @@ apps = [
"${root}/source/apps/lightspeed.app.trex.validation_cli_generator.kit",
"${root}/source/apps/lightspeed.app.trex_dev.kit",
"${root}/source/apps/lightspeed.hdremix.test.kit",
"${root}/source/apps/omni.flux.app.service.documentation_cli_generator.kit",
"${root}/source/extensions/lightspeed.trex.packaging.core/apps/lightspeed.app.trex.project_packaging_cli.kit",
"${root}/source/extensions/lightspeed.trex.project_wizard.core/apps/lightspeed.app.trex.project_wizard_cli.kit",
"${root}/source/extensions/omni.flux.asset_importer.core/apps/omni.flux.app.asset_importer_cli.kit",
"${root}/source/extensions/omni.flux.service.documentation/apps/omni.flux.app.service.documentation_cli.kit",
"${root}/source/extensions/omni.flux.validator.manager.core/apps/omni.flux.app.validator_cli.kit",
"${root}/source/extensions/omni.flux.validator.manager.window/apps/omni.flux.app.validator.kit",
"${root}/source/extensions/omni.flux.validator.mass.core/apps/omni.flux.app.validator.mass_cli.kit",
Expand All @@ -386,16 +389,54 @@ name = "NVIDIA RTX Remix"
project = "${conf:repo.name}"

sphinx_conf_py_extra = """
import shutil
import pathlib
import platform
import shutil
import subprocess
def build_service_docs(app):
output_dir = pathlib.Path(app.builder.outdir)
exec_path = output_dir.parent.parent.parent / "${platform}" / source_substitutions.get("repo_docs_config")
if not (exec_path).exists():
raise RuntimeError("No Kit build was found.")
exec_path = exec_path / ("omni.flux.app.service.documentation.cli" + (".bat" if platform.system().lower() == "windows" else ".sh"))
if not exec_path.exists():
raise RuntimeError("Service Documentation executable not found.")
source_file = pathlib.Path.cwd() / "docs" / "toolkitinterface" / "remix-toolkitinterface-restapi-docs.html"
command = [
str(exec_path),
"-o", str(source_file),
"-e", "lightspeed.trex.service.core",
'-x--/renderer/mdl/searchPaths/templates="${kit}/../omni_core_materials/Base;${kit}/mdl/core/Base;${kit}/mdl/core/Volume;${kit}/mdl/core/mdl"',
]
print("Generating service documentation")
print(" ".join(command))
result = subprocess.run(command, check=True)
if result.returncode != 0:
raise RuntimeError("An error occured while generating the Service documentation.")
output_file = output_dir / "docs" / "toolkitinterface" / "remix-toolkitinterface-restapi-docs.html"
print("Copying generated documentation from", source_file, "to", output_file)
output_file.parent.mkdir(parents=True)
shutil.copy2(source_file, output_file)
def copy_videos(app, exc):
video_dir = pathlib.Path(app.builder.outdir).joinpath("docs", "videos")
src = pathlib.Path.cwd().joinpath("docs", "videos")
print(f"copying videos from {video_dir} to {src}")
shutil.copytree(src, video_dir)
sphinx_event_handlers = [("build-finished", copy_videos)]
sphinx_event_handlers = [
("builder-inited", build_service_docs),
("build-finished", copy_videos),
]
autodoc_mock_imports = [
"fastapi", # Import Doc from typing_extensions fails
Expand Down
1 change: 1 addition & 0 deletions source/apps/exts.deps.generated.kit
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@
"omni.flux.resources" = {}
"omni.flux.selection_history_tree.model.usd" = {}
"omni.flux.selection_history_tree.widget" = {}
"omni.flux.service.documentation" = {}
"omni.flux.service.factory" = {}
"omni.flux.service.shared" = {}
"omni.flux.tabbed.widget" = {}
Expand Down
62 changes: 62 additions & 0 deletions source/apps/omni.flux.app.service.documentation_cli_generator.kit
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
[package]
version = "1.0.0"
category = "Application"
title = "Flux Service Documentation Generation App"
description = "App used to generate the shortcut of the Service Documentation Generation CLI"
authors = ["Pierre-Olivier Trottier <ptrottier@nvidia.com>"]
repository = "https://gitlab-master.nvidia.com/lightspeedrtx/lightspeed-kit"
keywords = ["omni", "flux", "app", "service", "documentation", "CLI", "Generator"]
changelog = """
# Changelog
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [1.0.0]
### Added
- Created
"""
readme = """
# Omniverse Flux Service Documentation Generation

A tool to generate static documentation from Kit microservices
"""

[dependencies]
"omni.flux.service.documentation" = {}

[settings.app.window]
title = "Flux Service Documentation Generation App"

[settings]
# Basic Kit App
################################
app.versionFile = "${app}/../../../VERSION"
app.fastShutdown = true

# Register extension folder from this repo in kit
[settings.app.exts]
folders.'++' = ["${app}/../../../exts", "${app}/../../../extscache", "${app}/../exts", "${app}/../extscache", "${kit}/../exts", "${kit}/../extscache"]

[[test]]
args = [
"--/app/window/width=480",
"--/app/window/height=480",
]

dependencies = [
"omni.flux.tests.dependencies",
]

########################################################################################################################
# BEGIN GENERATED PART (Remove from 'BEGIN' to 'END' to regenerate)
########################################################################################################################

# Kit SDK Version: 106.0.0+release.118399.fcefe91f.gl

# Version lock for all dependencies:
[settings.app.exts]
enabled = [
]

########################################################################################################################
# END GENERATED PART
########################################################################################################################
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[package]
title = "Flux Service Documentation Generation App"

# That makes it browsable in UI with "experience" filter
keywords = ["app"]

[dependencies]
"omni.flux.service.documentation" = {}

[settings.app.window]
title = "Flux Service Documentation Generation App"

[settings]
# Basic Kit App
################################
app.versionFile = "${app}/../../../VERSION"
app.fastShutdown = true

# Register extension folder from this repo in kit
[settings.app.exts]
folders.'++' = ["${app}/../../../exts", "${app}/../../../extscache", "${app}/../exts", "${app}/../extscache", "${kit}/../exts", "${kit}/../extscache"]

[[test]]
args = [
"--/app/window/width=480",
"--/app/window/height=480",
]

########################################################################################################################
# BEGIN GENERATED PART (Remove from 'BEGIN' to 'END' to regenerate)
########################################################################################################################

# Kit SDK Version: 106.0.0+release.118399.fcefe91f.gl

# Version lock for all dependencies:
[settings.app.exts]
enabled = [
]

########################################################################################################################
# END GENERATED PART
########################################################################################################################
10 changes: 10 additions & 0 deletions source/extensions/omni.flux.service.documentation/bin/cli.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@echo off

call "%~dp0..\..\..\dev\tools\packman\python" %~dp0cli.py %*
if %errorlevel% neq 0 ( goto Error )

:Success
exit /b 0

:Error
exit /b %errorlevel%
80 changes: 80 additions & 0 deletions source/extensions/omni.flux.service.documentation/bin/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
"""
* SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
"""

import argparse
import pathlib
import platform
import subprocess


def main():
example = r"""
Example:
cli.bat -o "{kit}\..\..\..\docs\flux\latest\service-documentation.html" -e omni.flux.service.factory
""" # noqa

parser = argparse.ArgumentParser(
description="Run the service documentation generation in command line.",
epilog=example,
formatter_class=argparse.RawTextHelpFormatter,
)
parser.add_argument("-o", "--output", type=str, help="The output HTML file path", required=True)
parser.add_argument(
"-e",
"--enable",
help="Name(s) of the Kit extension(s) plugin we want to use",
nargs="+",
type=str,
required=True,
)
parser.add_argument(
"-x", "--extra-args", help="Any extra arguments to pass to Kit", action="append", type=str, required=False
)
args = parser.parse_args()

if pathlib.Path(args.output).suffix.lower() != ".html":
raise ValueError("The output file must be an HTML file. (.html)")

root_dir = pathlib.Path(__file__).parent.parent.parent.parent

cmd = [
str(root_dir.joinpath("kit", "kit.exe" if platform.system() == "Windows" else "kit")),
str(pathlib.Path(__file__).parent.parent.joinpath("apps", "omni.flux.app.service.documentation_cli.kit")),
]
for ext in args.enable:
cmd.extend(["--enable", ext])

for arg in args.extra_args or []:
cmd.extend([arg])

cmd.append("--no-window")
exec_cmd = f"{pathlib.Path(__file__).parent.parent.joinpath('omni', 'flux', 'service', 'documentation', 'cli.py')}" # noqa E501
exec_cmd += f' -o "{args.output}"'
cmd.extend(["--exec", exec_cmd])

print(" ".join(cmd))
with subprocess.Popen(cmd, stdout=subprocess.PIPE, bufsize=1, universal_newlines=True) as p:
for line in p.stdout:
print(line, end="") # process line here

if p.returncode != 0:
raise subprocess.CalledProcessError(p.returncode, p.args)


if __name__ == "__main__":
main()
8 changes: 8 additions & 0 deletions source/extensions/omni.flux.service.documentation/bin/cli.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

set -e

SCRIPT_DIR=$(dirname ${BASH_SOURCE})
cd "$SCRIPT_DIR"

exec "$SCRIPT_DIR/../../../dev/tools/packman/python.sh" cli.py $@
Loading

0 comments on commit b22df40

Please sign in to comment.