-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds method for simulation CLI arguments to the
AppLauncher
class (#…
…160) # Description Adds `add_app_launcher_args` function to the `AppLauncher` class, which can be used to add AppLauncher-specific arguments to an existing ArgumentParser instance. Because everything we pass is then passed to SimulationApp as a config, the MR also adds the `check_config()` function. This compares the key values of a dict and raises a ValueError in the following cases: * if they have a key reserved for a SimulationApp config parameter but incorrect value types * if the value type is correct, it informs the user if a dict item they passed will be interpreted as a SimulationApp config parameter. Non-SimulationApp relevant keys are cleaned from the dict before it is passed to SimulationApp. Also separated out the giant `AppLauncher.__init__` function into a few sub-functions to make things more readable. ## Type of change - New feature (non-breaking change which adds functionality) ## Checklist - [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with `./orbit.sh --format` - [x] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] I have updated the changelog and the corresponding version in the extension's `config/extension.toml` file --------- Signed-off-by: AutonomousHansen <[email protected]> Co-authored-by: Mayank Mittal <[email protected]>
- Loading branch information
1 parent
3473efb
commit 39f9549
Showing
32 changed files
with
700 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
521 changes: 455 additions & 66 deletions
521
source/extensions/omni.isaac.orbit/omni/isaac/orbit/app.py
Large diffs are not rendered by default.
Oops, something went wrong.
49 changes: 49 additions & 0 deletions
49
source/extensions/omni.isaac.orbit/test/app/test_argparser_launch.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES, ETH Zurich, and University of Toronto | ||
# All rights reserved. | ||
# | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
|
||
from __future__ import annotations | ||
|
||
import argparse | ||
import unittest | ||
from unittest import mock | ||
|
||
from omni.isaac.orbit.app import AppLauncher | ||
|
||
|
||
class TestAppLauncher(unittest.TestCase): | ||
"""Test launching of the simulation app using AppLauncher.""" | ||
|
||
@mock.patch("argparse.ArgumentParser.parse_args", return_value=argparse.Namespace(livestream=1)) | ||
def test_livestream_launch_with_argparser(self, mock_args): | ||
"""Test launching with argparser arguments.""" | ||
# create argparser | ||
parser = argparse.ArgumentParser() | ||
# add app launcher arguments | ||
AppLauncher.add_app_launcher_args(parser) | ||
# check that argparser has the mandatory arguments | ||
for name in AppLauncher._APPLAUNCHER_CONFIG_TYPES: | ||
self.assertTrue(parser._option_string_actions[f"--{name}"]) | ||
# parse args | ||
mock_args = parser.parse_args() | ||
# everything defaults to None | ||
app = AppLauncher(mock_args).app | ||
|
||
# import settings | ||
import carb | ||
|
||
# acquire settings interface | ||
carb_settings_iface = carb.settings.get_settings() | ||
# check settings | ||
# -- no-gui mode | ||
self.assertEqual(carb_settings_iface.get("/app/window/enabled"), False) | ||
# -- livestream | ||
self.assertEqual(carb_settings_iface.get("/app/livestream/enabled"), True) | ||
|
||
# close the app on exit | ||
app.close() | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
40 changes: 40 additions & 0 deletions
40
source/extensions/omni.isaac.orbit/test/app/test_env_var_launch.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES, ETH Zurich, and University of Toronto | ||
# All rights reserved. | ||
# | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
|
||
from __future__ import annotations | ||
|
||
import os | ||
import unittest | ||
|
||
from omni.isaac.orbit.app import AppLauncher | ||
|
||
|
||
class TestAppLauncher(unittest.TestCase): | ||
"""Test launching of the simulation app using AppLauncher.""" | ||
|
||
def test_livestream_launch_with_env_var(self): | ||
"""Test launching with no-keyword args but environment variables.""" | ||
# manually set the settings as well to make sure they are set correctly | ||
os.environ["LIVESTREAM"] = "1" | ||
# everything defaults to None | ||
app = AppLauncher().app | ||
|
||
# import settings | ||
import carb | ||
|
||
# acquire settings interface | ||
carb_settings_iface = carb.settings.get_settings() | ||
# check settings | ||
# -- no-gui mode | ||
self.assertEqual(carb_settings_iface.get("/app/window/enabled"), False) | ||
# -- livestream | ||
self.assertEqual(carb_settings_iface.get("/app/livestream/enabled"), True) | ||
|
||
# close the app on exit | ||
app.close() | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
37 changes: 37 additions & 0 deletions
37
source/extensions/omni.isaac.orbit/test/app/test_kwarg_launch.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES, ETH Zurich, and University of Toronto | ||
# All rights reserved. | ||
# | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
|
||
from __future__ import annotations | ||
|
||
import unittest | ||
|
||
from omni.isaac.orbit.app import AppLauncher | ||
|
||
|
||
class TestAppLauncher(unittest.TestCase): | ||
"""Test launching of the simulation app using AppLauncher.""" | ||
|
||
def test_livestream_launch_with_kwarg(self): | ||
"""Test launching with headless and livestreaming arguments.""" | ||
# everything defaults to None | ||
app = AppLauncher(headless=True, livestream=1).app | ||
|
||
# import settings | ||
import carb | ||
|
||
# acquire settings interface | ||
carb_settings_iface = carb.settings.get_settings() | ||
# check settings | ||
# -- no-gui mode | ||
self.assertEqual(carb_settings_iface.get("/app/window/enabled"), False) | ||
# -- livestream | ||
self.assertEqual(carb_settings_iface.get("/app/livestream/enabled"), True) | ||
|
||
# close the app on exit | ||
app.close() | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.