Skip to content

Commit

Permalink
Merge pull request #7 from ansys-internal/mostieri/rename_extensions
Browse files Browse the repository at this point in the history
rename extensions to something more meaningful
  • Loading branch information
randallfrank authored Aug 19, 2024
2 parents a81fbd3 + 46454bb commit 70f2ced
Show file tree
Hide file tree
Showing 17 changed files with 81 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,29 @@
version = f"{pyensight_version}" if pyensight_version else None

extra_args = []
if "ANSYS_PYPI_INDEX_URL" in os.environ:
extra_args.append(os.environ["ANSYS_PYPI_INDEX_URL"])
if "dev0" in version and "ANSYS_PYPI_INDEX_URL" in os.environ:
# Get PyEnSight from the private PyPi repo - dev environment
extra_args.append(str(os.environ["ANSYS_PYPI_INDEX_URL"]))
extra_args.append("--pre")

if os.environ.get("ANSYS_PYPI_REINSTALL", "") == "1":
package_name = "ansys-pyensight-core"

# Add possibility of installing local wheels
if os.environ.get("ANSYS_PYENSIGHT_LOCAL_WHEEL"):
package_name = os.environ.get("ANSYS_PYENSIGHT_LOCAL_WHEEL")

extra_args.extend(
[
"--upgrade",
"--no-deps",
"--no-cache-dir",
"--force-reinstall",
"--pre",
]
)

logging.warning("ansys.tools.omniverse.server - Forced reinstall ansys-pyensight-core")
omni.kit.pipapi.install("ansys-pyensight-core", extra_args=extra_args, version=version)

# Add ignore cache attribute when reinstalling so that you can switch between dev and released versions if needed
omni.kit.pipapi.install(package_name, extra_args=extra_args, version=version, ignore_cache=True)
try:
# Checking to see if we need to install the module
import ansys.pyensight.core
Expand All @@ -59,10 +65,10 @@
dependencies, but we want to use the local copy. Do this by prefixing
the path and (re)load the modules. The pyensight wheel includes the
following for this file:
ansys\pyensight\core\exts\ansys.tools.omniverse.service\ansys\tools\omniverse\service\extension.py
ansys\pyensight\core\exts\ansys.tools.omniverse.core\ansys\tools\omniverse\core\extension.py
"""
kit_dir = __file__
for _ in range(5):
for _ in range(6):
kit_dir = os.path.dirname(kit_dir)
"""
At this point, the name should be: {something}\ansys\pyensight\core\exts
Expand All @@ -85,11 +91,19 @@

# force a reload if we changed the path or had a partial failure that lead
# to a pipapi install.
_ = reload(ansys.pyensight.core)
try:
_ = reload(ansys.pyensight.core)
except Exception:
pass

import ansys.pyensight.core.utils # noqa: F811, E402

_ = reload(ansys.pyensight.core.utils)

import ansys.pyensight.core.utils.dsg_server as dsg_server # noqa: E402

_ = reload(ansys.pyensight.core.utils.dsg_server)

import ansys.pyensight.core.utils.omniverse_dsg_server as ov_dsg_server # noqa: E402

_ = reload(ansys.pyensight.core.utils.omniverse_dsg_server)
Expand Down Expand Up @@ -143,7 +157,7 @@ def find_kit_filename() -> Optional[str]:
return None


class AnsysToolsOmniverseServiceServerExtension(omni.ext.IExt):
class AnsysToolsOmniverseCoreServerExtension(omni.ext.IExt):
"""
This class is an Omniverse kit. The kit is capable of creating a
connection to an Ansys Distributed Scene Graph service and pushing
Expand Down Expand Up @@ -175,6 +189,8 @@ def __init__(self, *args, **kwargs) -> None:
@property
def pyensight_version(self) -> str:
"""The ansys.pyensight.core version"""
if version:
return version
return ansys.pyensight.core.VERSION

@property
Expand Down Expand Up @@ -241,7 +257,7 @@ def time_scale(self, value: float) -> None:
self._time_scale = value

@classmethod
def get_instance(cls) -> Optional["AnsysToolsOmniverseServiceServerExtension"]:
def get_instance(cls) -> Optional["AnsysToolsOmniverseCoreServerExtension"]:
return cls._service_instance

@classmethod
Expand Down Expand Up @@ -317,8 +333,8 @@ def on_startup(self, ext_id: str) -> None:
The specific version of the kit.
"""
self._version = ext_id
self.info(f"ANSYS tools omniverse service server startup: {self._version}")
AnsysToolsOmniverseServiceServerExtension._service_instance = self
self.info(f"ANSYS tools omniverse core server startup: {self._version}")
AnsysToolsOmniverseCoreServerExtension._service_instance = self
if self._setting("help") is not None:
self.help()
elif self._setting("run") is not None:
Expand All @@ -328,38 +344,38 @@ def on_shutdown(self) -> None:
"""
Called by Omniverse when the kit instance is shutting down.
"""
self.info("ANSYS tools omniverse service server shutdown")
self.info("ANSYS tools omniverse core server shutdown")
self.shutdown()
AnsysToolsOmniverseServiceServerExtension._service_instance = None
AnsysToolsOmniverseCoreServerExtension._service_instance = None

def help(self) -> None:
"""
Send the CLI help output to logging.
"""
self.warning(f"ANSYS Tools Omniverse Service: {self._version}")
self.warning(" --/exts/ansys.tools.omniverse.service/help=1")
self.warning(f"ANSYS Tools Omniverse Core: {self._version}")
self.warning(" --/exts/ansys.tools.omniverse.core/help=1")
self.warning(" Display this help.")
self.warning(" --/exts/ansys.tools.omniverse.service/run=1")
self.warning(" --/exts/ansys.tools.omniverse.core/run=1")
self.warning(" Run the server.")
self.warning(" --/exts/ansys.tools.omniverse.service/omniUrl=URL")
self.warning(" --/exts/ansys.tools.omniverse.core/omniUrl=URL")
self.warning(f" Omniverse pathname. (default: {self.omni_uri})")
self.warning(" --/exts/ansys.tools.omniverse.service/dsgUrl=URL")
self.warning(" --/exts/ansys.tools.omniverse.core/dsgUrl=URL")
self.warning(f" Dynamic Scene Graph connection URL. (default: {self.dsg_uri})")
self.warning(" --/exts/ansys.tools.omniverse.service/securityCode=TOKEN")
self.warning(" --/exts/ansys.tools.omniverse.core/securityCode=TOKEN")
self.warning(f" Dynamic Scene Graph security token. (default: {self.security_token})")
self.warning(" --/exts/ansys.tools.omniverse.service/temporal=0|1")
self.warning(" --/exts/ansys.tools.omniverse.core/temporal=0|1")
self.warning(
f" If non-zero, include all timeseteps in the scene. (default: {self.temporal})"
)
self.warning(" --/exts/ansys.tools.omniverse.service/vrmode=0|1")
self.warning(" --/exts/ansys.tools.omniverse.core/vrmode=0|1")
self.warning(
f" If non-zero, do not include a camera in the scene. (default: {self.vrmode})"
)
self.warning(" --/exts/ansys.tools.omniverse.service/normalizeGeometry=0|1")
self.warning(" --/exts/ansys.tools.omniverse.core/normalizeGeometry=0|1")
self.warning(
f" If non-zero, remap the geometry to the domain [-1,-1,-1]-[1,1,1]. (default: {self.normalize_geometry})"
)
self.warning(" --/exts/ansys.tools.omniverse.service/timeScale=FLOAT")
self.warning(" --/exts/ansys.tools.omniverse.core/timeScale=FLOAT")
self.warning(
f" Multiply all DSG time values by this value. (default: {self.time_scale})"
)
Expand Down Expand Up @@ -412,20 +428,20 @@ def launch_server(self) -> None:
for _ in range(5):
kit_dir = os.path.dirname(kit_dir)
cmd.extend(["--ext-folder", kit_dir])
cmd.extend(["--enable", "ansys.tools.omniverse.service"])
cmd.extend(["--enable", "ansys.tools.omniverse.core"])
if self.security_token:
cmd.append(f'--/exts/ansys.tools.omniverse.service/securityCode="{self.security_token}"')
cmd.append(f'--/exts/ansys.tools.omniverse.core/securityCode="{self.security_token}"')
if self.temporal:
cmd.append("--/exts/ansys.tools.omniverse.service/temporal=1")
cmd.append("--/exts/ansys.tools.omniverse.core/temporal=1")
if self.vrmode:
cmd.append("--/exts/ansys.tools.omniverse.service/vrmode=1")
cmd.append("--/exts/ansys.tools.omniverse.core/vrmode=1")
if self.normalize_geometry:
cmd.append("--/exts/ansys.tools.omniverse.service/normalizeGeometry=1")
cmd.append("--/exts/ansys.tools.omniverse.core/normalizeGeometry=1")
if self.time_scale != 1.0:
cmd.append(f"--/exts/ansys.tools.omniverse.service/timeScale={self.time_scale}")
cmd.append(f"--/exts/ansys.tools.omniverse.service/omniUrl={self.omni_uri}")
cmd.append(f"--/exts/ansys.tools.omniverse.service/dsgUrl={self.dsg_uri}")
cmd.append("--/exts/ansys.tools.omniverse.service/run=1")
cmd.append(f"--/exts/ansys.tools.omniverse.core/timeScale={self.time_scale}")
cmd.append(f"--/exts/ansys.tools.omniverse.core/omniUrl={self.omni_uri}")
cmd.append(f"--/exts/ansys.tools.omniverse.core/dsgUrl={self.dsg_uri}")
cmd.append("--/exts/ansys.tools.omniverse.core/run=1")
env_vars = os.environ.copy()
# we are launching the kit from an Omniverse app. In this case, we
# inform the kit instance of:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ version = "0.1.0"
authors = ["ANSYS"]

# The title and description fields are primarily for displaying extension info in UI
title = "ANSYS Tools Omniverse Service Server"
title = "ANSYS Tools Omniverse Core Server"
description = "A geometry synchronization service that enables export of geometry scenes from ANSYS products to Omniverse."

# Path (relative to the root) or content of readme markdown file for UI.
Expand Down Expand Up @@ -38,9 +38,9 @@ icon = "data/icon.png"
"omni.client" = {}
"omni.usd" = {}

# Main python module this extension provides, it will be publicly available as "import ansys.tools.omniverse.service".
# Main python module this extension provides, it will be publicly available as "import ansys.tools.omniverse.core".
[[python.module]]
name = "ansys.tools.omniverse.service"
name = "ansys.tools.omniverse.core"

[[test]]
# Extra dependencies only to be used during test run
Expand All @@ -50,10 +50,10 @@ dependencies = [

[settings]
# CLI setting defaults (note: "help" and "run" are also supported)
exts."ansys.tools.omniverse.service".dsgUrl = "grpc://127.0.0.1:5234"
exts."ansys.tools.omniverse.service".omniUrl = "omniverse://localhost/Users/test"
exts."ansys.tools.omniverse.service".securityCode = ""
exts."ansys.tools.omniverse.service".temporal = "0"
exts."ansys.tools.omniverse.service".vrmode = "0"
exts."ansys.tools.omniverse.service".normalizeGeometry = "0"
exts."ansys.tools.omniverse.service".timeScale = "1.0"
exts."ansys.tools.omniverse.core".dsgUrl = "grpc://127.0.0.1:5234"
exts."ansys.tools.omniverse.core".omniUrl = "omniverse://localhost/Users/test"
exts."ansys.tools.omniverse.core".securityCode = ""
exts."ansys.tools.omniverse.core".temporal = "0"
exts."ansys.tools.omniverse.core".vrmode = "0"
exts."ansys.tools.omniverse.core".normalizeGeometry = "0"
exts."ansys.tools.omniverse.core".timeScale = "1.0"
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# ANSYS Tools Omniverse Service [ansys.tools.omniverse.service]
# ANSYS Tools Omniverse Core [ansys.tools.omniverse.core]

The Omniverse extension provides a dynamic connection between an ANSYS
geometry source (e.g. ANSYS EnSight) and an Omniverse instance. The
connection runs as a standalone service capable of supporting scripted
execution utilizing just a kit CLI. It can also be launched via
PyEnSight and via a simple GUI provided by the [ansys.tools.omniverse.serviceui]
PyEnSight and via a simple GUI provided by the [ansys.tools.omniverse.dsgui]
kit extension.

For more details on this extension see:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ansys.tools.omniverse.service
ansys.tools.omniverse.core
######################


Expand All @@ -9,7 +9,7 @@ ansys.tools.omniverse.service
CHANGELOG


.. automodule::"ansys.tools.omniverse.service"
.. automodule::"ansys.tools.omniverse.core"
:platform: Windows-x86_64, Linux-x86_64
:members:
:undoc-members:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
from typing import Any, Optional
from urllib.parse import urlparse

import ansys.tools.omniverse.service
import ansys.tools.omniverse.core
import omni.ext
import omni.ui as ui


class AnsysToolsOmniverseServiceUIExtension(omni.ext.IExt):
class AnsysToolsOmniverseDSGUIExtension(omni.ext.IExt):
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self._window: Any = None
Expand All @@ -28,8 +28,8 @@ def __init__(self, *args, **kwargs) -> None:
self._connected = False

@property
def service(self) -> Optional["AnsysToolsOmniverseServiceUIExtension"]:
return ansys.tools.omniverse.service.AnsysToolsOmniverseServiceServerExtension.get_instance()
def service(self) -> Optional["AnsysToolsOmniverseDSGUIExtension"]:
return ansys.tools.omniverse.core.AnsysToolsOmniverseCoreServerExtension.get_instance()

def info(self, text: str) -> None:
self._logger.info(text)
Expand Down Expand Up @@ -89,7 +89,7 @@ def stop_server(self) -> None:

def connect_cb(self) -> None:
if self.service is None:
self.error("Unable to find ansys.tools.omniverse.service instance")
self.error("Unable to find ansys.tools.omniverse.core instance")
return
if self._connected:
self.stop_server()
Expand All @@ -109,9 +109,9 @@ def update_cb(self) -> None:
self._grpc.command(cmd, do_eval=False)

def on_startup(self, ext_id: str) -> None:
self.info(f"ANSYS tools omniverse service GUI startup: {ext_id}")
self.info(f"ANSYS tools omniverse DSG GUI startup: {ext_id}")
if self.service is None:
self.error("Unable to find ansys.tools.omniverse.service instance")
self.error("Unable to find ansys.tools.omniverse.core instance")
self.build_ui()
self._update_callback()

Expand Down Expand Up @@ -144,7 +144,7 @@ def update_ui(self) -> None:
self._omni_uri_w.enabled = not self._connected

def build_ui(self) -> None:
self._window = ui.Window(f"ANSYS Tools Omniverse Service ({self.service.pyensight_version})")
self._window = ui.Window(f"ANSYS Tools Omniverse DSG ({self.service.pyensight_version})")
with self._window.frame:
with ui.VStack(height=0, spacing=5):
self._label_w = ui.Label("No connected DSG server")
Expand Down Expand Up @@ -206,7 +206,7 @@ def build_ui(self) -> None:
self._update_w = ui.Button("Request Update", clicked_fn=self.update_cb)

def on_shutdown(self) -> None:
self.info("ANSYS Tools Omniverse service shutdown")
self.info("ANSYS Tools Omniverse DSG shutdown")
self.stop_server()
self._window = None
self._label_w = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ version = "0.1.0"
authors = ["ANSYS"]

# The title and description fields are primarily for displaying extension info in UI
title = "ANSYS Tools Omniverse Service GUI"
title = "ANSYS Tools Omniverse DSG GUI"
description = "A geometry synchronization service that enables export of geometry scenes from ANSYS products to Omniverse."

# Path (relative to the root) or content of readme markdown file for UI.
Expand Down Expand Up @@ -35,11 +35,11 @@ icon = "data/icon.png"
# Use omni.ui to build simple UI
[dependencies]
"omni.kit.uiapp" = {}
"ansys.tools.omniverse.service" = {}
"ansys.tools.omniverse.core" = {}

# Main python module this extension provides, it will be publicly available as "import ansys.tools.omniverse.serviceui".
# Main python module this extension provides, it will be publicly available as "import ansys.tools.omniverse.dsgui".
[[python.module]]
name = "ansys.tools.omniverse.serviceui"
name = "ansys.tools.omniverse.dsgui"

[[test]]
# Extra dependencies only to be used during test run
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ANSYS Tools Omniverse Service GUI [ansys.tools.omniverse.serviceui]
# ANSYS Tools Omniverse DSG GUI [ansys.tools.omniverse.dsgui]

This Omniverse extension is a UI interface to the [ansys.tools.omniverse.service]
This Omniverse extension is a UI interface to the [ansys.tools.omniverse.core]
kit extension. It allows an Omniverse application user to connect to
a running copy of ANSYS EnSight or other application that supports the
Dynamic Scene Graph gRPC protocol. The GUI allows for the remote scene
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ansys.tools.omniverse.serviceui
ansys.tools.omniverse.dsgui
########################


Expand All @@ -9,7 +9,7 @@ ansys.tools.omniverse.serviceui
CHANGELOG


.. automodule::"ansys.tools.omniverse.serviceui"
.. automodule::"ansys.tools.omniverse.dsgui"
:platform: Windows-x86_64, Linux-x86_64
:members:
:undoc-members:
Expand Down

0 comments on commit 70f2ced

Please sign in to comment.