ansys-pyensight-core 0.8.7__py3-none-any.whl → 0.8.9__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of ansys-pyensight-core might be problematic. Click here for more details.

Files changed (34) hide show
  1. ansys/pyensight/core/dockerlauncher.py +6 -0
  2. ansys/pyensight/core/launcher.py +7 -2
  3. ansys/pyensight/core/locallauncher.py +4 -0
  4. ansys/pyensight/core/session.py +1 -1
  5. ansys/pyensight/core/utils/dsg_server.py +227 -35
  6. ansys/pyensight/core/utils/omniverse.py +84 -24
  7. ansys/pyensight/core/utils/omniverse_cli.py +481 -0
  8. ansys/pyensight/core/utils/omniverse_dsg_server.py +236 -426
  9. ansys/pyensight/core/utils/omniverse_glb_server.py +279 -0
  10. {ansys_pyensight_core-0.8.7.dist-info → ansys_pyensight_core-0.8.9.dist-info}/METADATA +12 -6
  11. ansys_pyensight_core-0.8.9.dist-info/RECORD +34 -0
  12. ansys/pyensight/core/exts/ansys.geometry.service/ansys/geometry/service/__init__.py +0 -1
  13. ansys/pyensight/core/exts/ansys.geometry.service/ansys/geometry/service/extension.py +0 -407
  14. ansys/pyensight/core/exts/ansys.geometry.service/config/extension.toml +0 -59
  15. ansys/pyensight/core/exts/ansys.geometry.service/data/icon.png +0 -0
  16. ansys/pyensight/core/exts/ansys.geometry.service/data/preview.png +0 -0
  17. ansys/pyensight/core/exts/ansys.geometry.service/docs/CHANGELOG.md +0 -11
  18. ansys/pyensight/core/exts/ansys.geometry.service/docs/README.md +0 -13
  19. ansys/pyensight/core/exts/ansys.geometry.service/docs/index.rst +0 -18
  20. ansys/pyensight/core/exts/ansys.geometry.serviceui/ansys/geometry/serviceui/__init__.py +0 -1
  21. ansys/pyensight/core/exts/ansys.geometry.serviceui/ansys/geometry/serviceui/extension.py +0 -193
  22. ansys/pyensight/core/exts/ansys.geometry.serviceui/config/extension.toml +0 -49
  23. ansys/pyensight/core/exts/ansys.geometry.serviceui/data/icon.png +0 -0
  24. ansys/pyensight/core/exts/ansys.geometry.serviceui/data/preview.png +0 -0
  25. ansys/pyensight/core/exts/ansys.geometry.serviceui/docs/CHANGELOG.md +0 -11
  26. ansys/pyensight/core/exts/ansys.geometry.serviceui/docs/README.md +0 -13
  27. ansys/pyensight/core/exts/ansys.geometry.serviceui/docs/index.rst +0 -18
  28. ansys/pyensight/core/utils/resources/Materials/Fieldstone/Fieldstone_BaseColor.png +0 -0
  29. ansys/pyensight/core/utils/resources/Materials/Fieldstone/Fieldstone_N.png +0 -0
  30. ansys/pyensight/core/utils/resources/Materials/Fieldstone/Fieldstone_ORM.png +0 -0
  31. ansys/pyensight/core/utils/resources/Materials/Fieldstone.mdl +0 -54
  32. ansys_pyensight_core-0.8.7.dist-info/RECORD +0 -52
  33. {ansys_pyensight_core-0.8.7.dist-info → ansys_pyensight_core-0.8.9.dist-info}/LICENSE +0 -0
  34. {ansys_pyensight_core-0.8.7.dist-info → ansys_pyensight_core-0.8.9.dist-info}/WHEEL +0 -0
@@ -1,407 +0,0 @@
1
- import logging
2
- import os
3
- import subprocess
4
- import sys
5
- from typing import Optional
6
- from urllib.parse import urlparse
7
-
8
- import carb.settings
9
- import omni.ext
10
- import omni.kit.app
11
- import omni.kit.pipapi
12
- import psutil
13
-
14
- try:
15
- import ansys.pyensight.core
16
- import ansys.pyensight.core.utils.dsg_server as tmp_dsg_server # noqa: F401
17
- import ansys.pyensight.core.utils.omniverse_dsg_server as tmp_ov_dsg_server # noqa: F401
18
- except ModuleNotFoundError:
19
- logging.warning("ansys.geometry.server - Installing ansys-pyensight-core")
20
- omni.kit.pipapi.install("ansys-pyensight-core")
21
-
22
-
23
- def find_kit_filename() -> Optional[str]:
24
- """
25
- Use a combination of the current omniverse application and the information
26
- in the local .nvidia-omniverse/config/omniverse.toml file to come up with
27
- the pathname of a kit executable suitable for hosting another copy of the
28
- ansys.geometry.server kit.
29
-
30
- Returns
31
- -------
32
- The pathname of a kit executable or None
33
-
34
- """
35
- # get the current application
36
- app = omni.kit.app.get_app()
37
- app_name = app.get_app_filename().split(".")[-1]
38
- app_version = app.get_app_version().split("-")[0]
39
-
40
- # parse the toml config file for the location of the installed apps
41
- try:
42
- import tomllib
43
- except ModuleNotFoundError:
44
- import pip._vendor.tomli as tomllib
45
-
46
- homedir = os.path.expanduser("~")
47
- ov_config = os.path.join(homedir, ".nvidia-omniverse", "config", "omniverse.toml")
48
- with open(ov_config, "r") as ov_file:
49
- ov_data = ov_file.read()
50
- config = tomllib.loads(ov_data)
51
- appdir = config.get("paths", {}).get("library_root", None)
52
- appdir = os.path.join(appdir, f"{app_name}-{app_version}")
53
-
54
- # Windows: 'kit.bat' in '.' or 'kit' followed by 'kit.exe' in '.' or 'kit'
55
- # Linux: 'kit.sh' in '.' or 'kit' followed by 'kit' in '.' or 'kit'
56
- exe_names = ["kit.sh", "kit"]
57
- if sys.platform.startswith("win"):
58
- exe_names = ["kit.bat", "kit.exe"]
59
-
60
- # look in 4 places...
61
- for dir_name in [appdir, os.path.join(appdir, "kit")]:
62
- for name in exe_names:
63
- if os.path.exists(os.path.join(dir_name, name)):
64
- return os.path.join(dir_name, name)
65
-
66
- return None
67
-
68
-
69
- class AnsysGeometryServiceServerExtension(omni.ext.IExt):
70
- """
71
- This class is an Omniverse kit. The kit is capable of creating a
72
- connection to an Ansys Distributed Scene Graph service and pushing
73
- the graph into an Omniverse Nucleus.
74
- """
75
-
76
- _service_instance = None
77
-
78
- def __init__(self, *args, **kwargs) -> None:
79
- super().__init__(*args, **kwargs)
80
- ext_name = __name__.rsplit(".", 1)[0]
81
- self._logger = logging.getLogger(ext_name)
82
- self._dsg_uri = self._setting("dsgUrl", "ENSIGHT_GRPC_URI")
83
- self._omni_uri = self._setting("omniUrl", "ENSIGHT_OMNI_URI")
84
- self._security_token = self._setting("securityCode", "ENSIGHT_SECURITY_TOKEN")
85
- self._temporal = self._setting("temporal") != "0"
86
- self._vrmode = self._setting("vrmode") != "0"
87
- try:
88
- scale = float(self._setting("timeScale"))
89
- except ValueError:
90
- scale = 1.0
91
- self._time_scale = scale
92
- self._normalize_geometry = self._setting("normalizeGeometry") != "0"
93
- self._version = "unknown"
94
- self._shutdown = False
95
- self._server_process = None
96
-
97
- @property
98
- def dsg_uri(self) -> str:
99
- """The endpoint of a Dynamic Scene Graph service: grpc://{hostname}:{port}"""
100
- return self._dsg_uri
101
-
102
- @dsg_uri.setter
103
- def dsg_uri(self, uri: str) -> None:
104
- self._dsg_uri = uri
105
-
106
- @property
107
- def omni_uri(self) -> str:
108
- """The endpoint of an Omniverse Nucleus service: omniverse://{hostname}/{path}"""
109
- return self._omni_uri
110
-
111
- @omni_uri.setter
112
- def omni_uri(self, value: str) -> None:
113
- self._omni_uri = value
114
-
115
- @property
116
- def security_token(self) -> str:
117
- """The security token of the DSG service instance."""
118
- return self._security_token
119
-
120
- @security_token.setter
121
- def security_token(self, value: str) -> None:
122
- self._security_token = value
123
-
124
- @property
125
- def temporal(self) -> bool:
126
- """If True, the DSG update should include all timesteps."""
127
- return self._temporal
128
-
129
- @temporal.setter
130
- def temporal(self, value: bool) -> None:
131
- self._temporal = bool(value)
132
-
133
- @property
134
- def vrmode(self) -> bool:
135
- """If True, the DSG update should not include camera transforms."""
136
- return self._vrmode
137
-
138
- @vrmode.setter
139
- def vrmode(self, value: bool) -> None:
140
- self._vrmode = bool(value)
141
-
142
- @property
143
- def normalize_geometry(self) -> bool:
144
- """If True, the DSG geometry should be remapped into normalized space."""
145
- return self._normalize_geometry
146
-
147
- @normalize_geometry.setter
148
- def normalize_geometry(self, val: bool) -> None:
149
- self._normalize_geometry = val
150
-
151
- @property
152
- def time_scale(self) -> float:
153
- """Value to multiply DSG time values by before passing to Omniverse"""
154
- return self._time_scale
155
-
156
- @time_scale.setter
157
- def time_scale(self, value: float) -> None:
158
- self._time_scale = value
159
-
160
- @classmethod
161
- def get_instance(cls) -> Optional["AnsysGeometryServiceServerExtension"]:
162
- return cls._service_instance
163
-
164
- @classmethod
165
- def _setting(cls, name: str, env_varname: str = "") -> str:
166
- """
167
- Get a CLI option value. First check if any specified
168
- environment variable is present and if so, return that value.
169
- Next, check to see if a command line value is set and return
170
- that. Finally, fall back to the value (if any) specified in
171
- the kit toml file.
172
-
173
- Parameters
174
- ----------
175
- name
176
- The name of the command line flag to check the value of.
177
- env_varname
178
- Optional name of the environment variable to check the value of.
179
-
180
- Returns
181
- -------
182
- A string or None.
183
- """
184
- # any environmental variable trumps them all.
185
- if env_varname:
186
- value = os.environ.get(env_varname, None)
187
- if value:
188
- return value
189
- settings = carb.settings.get_settings()
190
- ext_name = __name__.rsplit(".", 1)[0]
191
- s = f"/exts/{ext_name}/{name}"
192
- return settings.get(s)
193
-
194
- def info(self, text: str) -> None:
195
- """
196
- Send message to the logger at the info level.
197
-
198
- Parameters
199
- ----------
200
- text
201
- The message to send.
202
- """
203
- self._logger.info(text)
204
-
205
- def warning(self, text: str) -> None:
206
- """
207
- Send message to the logger at the warning level.
208
-
209
- Parameters
210
- ----------
211
- text
212
- The message to send.
213
- """
214
- self._logger.warning(text)
215
-
216
- def error(self, text: str) -> None:
217
- """
218
- Send message to the logger at the error level.
219
-
220
- Parameters
221
- ----------
222
- text
223
- The message to send.
224
- """
225
- self._logger.error(text)
226
-
227
- def on_startup(self, ext_id: str) -> None:
228
- """
229
- Called by Omniverse when the kit instance is started.
230
-
231
- Parameters
232
- ----------
233
- ext_id
234
- The specific version of the kit.
235
- """
236
- self._version = ext_id
237
- self.info(f"ANSYS geometry service server startup: {self._version}")
238
- AnsysGeometryServiceServerExtension._service_instance = self
239
- if self._setting("help") is not None:
240
- self.help()
241
- elif self._setting("run") is not None:
242
- self.run_server()
243
-
244
- def on_shutdown(self) -> None:
245
- """
246
- Called by Omniverse when the kit instance is shutting down.
247
- """
248
- self.info("ANSYS geometry service server shutdown")
249
- self.shutdown()
250
- AnsysGeometryServiceServerExtension._service_instance = None
251
-
252
- def help(self) -> None:
253
- """
254
- Send the CLI help output to logging.
255
- """
256
- self.warning(f"ANSYS Omniverse Geometry Service: {self._version}")
257
- self.warning(" --/exts/ansys.geometry.service/help=1")
258
- self.warning(" Display this help.")
259
- self.warning(" --/exts/ansys.geometry.service/run=1")
260
- self.warning(" Run the server.")
261
- self.warning(" --/exts/ansys.geometry.service/omniUrl=URL")
262
- self.warning(f" Omniverse pathname. (default: {self.omni_uri})")
263
- self.warning(" --/exts/ansys.geometry.service/dsgUrl=URL")
264
- self.warning(f" Dynamic Scene Graph connection URL. (default: {self.dsg_uri})")
265
- self.warning(" --/exts/ansys.geometry.service/securityCode=TOKEN")
266
- self.warning(f" Dynamic Scene Graph security token. (default: {self.security_token})")
267
- self.warning(" --/exts/ansys.geometry.service/temporal=0|1")
268
- self.warning(
269
- f" If non-zero, include all timeseteps in the scene. (default: {self.temporal})"
270
- )
271
- self.warning(" --/exts/ansys.geometry.service/vrmode=0|1")
272
- self.warning(
273
- f" If non-zero, do not include a camera in the scene. (default: {self.vrmode})"
274
- )
275
- self.warning(" --/exts/ansys.geometry.service/normalizeGeometry=0|1")
276
- self.warning(
277
- f" If non-zero, remap the geometry to the domain [-1,-1,-1]-[1,1,1]. (default: {self.normalize_geometry})"
278
- )
279
- self.warning(" --/exts/ansys.geometry.service/timeScale=FLOAT")
280
- self.warning(
281
- f" Multiply all DSG time values by this value. (default: {self.time_scale})"
282
- )
283
-
284
- def is_server_running(self) -> bool:
285
- """
286
- Returns True if the server is running.
287
-
288
- Returns
289
- -------
290
- bool
291
- True if the server is running.
292
- """
293
- if self._server_process:
294
- if psutil.pid_exists(self._server_process.pid):
295
- return True
296
- return False
297
-
298
- def stop_server(self) -> None:
299
- """
300
- If a DSG server connection has been started, stop it. It could be in
301
- process or a subprocess.
302
- """
303
- try:
304
- self._shutdown = True
305
- if self._server_process:
306
- for child in psutil.Process(self._server_process.pid).children(recursive=True):
307
- child.kill()
308
- self._server_process.kill()
309
- except psutil.NoSuchProcess:
310
- pass
311
- self._server_process = None
312
- self._shutdown = False
313
-
314
- def launch_server(self) -> None:
315
- """
316
- Launch a DSG to Omniverse server as a subprocess.
317
- """
318
- if self._server_process:
319
- self.warning("Only a single subprocess server is supported.")
320
- return
321
- kit_name = find_kit_filename()
322
- if kit_name is None:
323
- self.warning("Unable to determine a kit executable pathname.")
324
- return
325
- self.info(f"Using {kit_name} to launch the server")
326
- cmd = [kit_name]
327
- # kit extension location
328
- kit_dir = __file__
329
- for _ in range(5):
330
- kit_dir = os.path.dirname(kit_dir)
331
- cmd.extend(["--ext-folder", kit_dir])
332
- cmd.extend(["--enable", "ansys.geometry.service"])
333
- if self.security_token:
334
- cmd.append(f'--/exts/ansys.geometry.service/securityCode="{self.security_token}"')
335
- if self.temporal:
336
- cmd.append("--/exts/ansys.geometry.service/temporal=1")
337
- if self.vrmode:
338
- cmd.append("--/exts/ansys.geometry.service/vrmode=1")
339
- if self.normalize_geometry:
340
- cmd.append("--/exts/ansys.geometry.service/normalizeGeometry=1")
341
- if self.time_scale != 1.0:
342
- cmd.append(f"--/exts/ansys.geometry.service/timeScale={self.time_scale}")
343
- cmd.append(f"--/exts/ansys.geometry.service/omniUrl={self.omni_uri}")
344
- cmd.append(f"--/exts/ansys.geometry.service/dsgUrl={self.dsg_uri}")
345
- cmd.append("--/exts/ansys.geometry.service/run=1")
346
- env_vars = os.environ.copy()
347
- working_dir = os.path.join(os.path.dirname(ansys.pyensight.core.__file__), "utils")
348
- self._server_process = subprocess.Popen(cmd, close_fds=True, env=env_vars, cwd=working_dir)
349
-
350
- def run_server(self) -> None:
351
- """
352
- Run a DSG to Omniverse server in process.
353
-
354
- Note: this method does not return until the DSG connection is dropped or
355
- self.stop_server() has been called.
356
- """
357
- try:
358
- import ansys.pyensight.core.utils.dsg_server as dsg_server
359
- import ansys.pyensight.core.utils.omniverse_dsg_server as ov_dsg_server
360
- except ImportError as e:
361
- self.error(f"Unable to load DSG service core: {str(e)}")
362
- return
363
-
364
- # Note: This is temporary. The correct fix will be included in
365
- # the pyensight 0.8.5 wheel. The OmniverseWrapper assumes the CWD
366
- # to be the directory with the "resource" directory.
367
- os.chdir(os.path.dirname(ov_dsg_server.__file__))
368
-
369
- # Build the Omniverse connection
370
- omni_link = ov_dsg_server.OmniverseWrapper(path=self._omni_uri, verbose=1)
371
- self.info("Omniverse connection established.")
372
-
373
- # parse the DSG USI
374
- parsed = urlparse(self.dsg_uri)
375
- port = parsed.port
376
- host = parsed.hostname
377
-
378
- # link it to a DSG session
379
- update_handler = ov_dsg_server.OmniverseUpdateHandler(omni_link)
380
- dsg_link = dsg_server.DSGSession(
381
- port=port,
382
- host=host,
383
- vrmode=self.vrmode,
384
- security_code=self.security_token,
385
- verbose=1,
386
- normalize_geometry=self.normalize_geometry,
387
- time_scale=self.time_scale,
388
- handler=update_handler,
389
- )
390
-
391
- # Start the DSG link
392
- self.info(f"Making DSG connection to: {self.dsg_uri}")
393
- err = dsg_link.start()
394
- if err < 0:
395
- self.error("Omniverse connection failed.")
396
- return
397
-
398
- # Initial pull request
399
- dsg_link.request_an_update(animation=self.temporal)
400
-
401
- # until the link is dropped, continue
402
- while not dsg_link.is_shutdown() and not self._shutdown:
403
- dsg_link.handle_one_update()
404
-
405
- self.info("Shutting down DSG connection")
406
- dsg_link.end()
407
- omni_link.shutdown()
@@ -1,59 +0,0 @@
1
- [package]
2
- # Semantic Versioning is used: https://semver.org/
3
- version = "0.8.7"
4
-
5
- # Lists people or organizations that are considered the "authors" of the package.
6
- authors = ["ANSYS"]
7
-
8
- # The title and description fields are primarily for displaying extension info in UI
9
- title = "ANSYS Omniverse Geometry Service Server"
10
- description = "A geometry synchronization service that enables export of geometry scenes from ANSYS products to Omniverse."
11
-
12
- # Path (relative to the root) or content of readme markdown file for UI.
13
- readme = "docs/README.md"
14
-
15
- # URL of the extension source repository.
16
- repository = "https://github.com/ansys/pyensight"
17
-
18
- # One of categories for UI.
19
- category = "simulation"
20
-
21
- # Keywords for the extension
22
- keywords = ["ANSYS", "EnSight", "PyEnSight", "Fluent", "kit"]
23
-
24
- # Location of change log file in target (final) folder of extension, relative to the root.
25
- # More info on writing changelog: https://keepachangelog.com/en/1.0.0/
26
- changelog = "docs/CHANGELOG.md"
27
-
28
- # Preview image and icon. Folder named "data" automatically goes in git lfs (see .gitattributes file).
29
- # Preview image is shown in "Overview" of Extensions window. Screenshot of an extension might be a good preview image.
30
- preview_image = "data/preview.png"
31
-
32
- # Icon is shown in Extensions window, it is recommended to be square, of size 256x256.
33
- icon = "data/icon.png"
34
-
35
- # Use omni.ui to build simple UI
36
- [dependencies]
37
- # "omni.kit.pipapi" = {}
38
- "omni.client" = {}
39
- "omni.usd" = {}
40
-
41
- # Main python module this extension provides, it will be publicly available as "import ansys.geometry.service".
42
- [[python.module]]
43
- name = "ansys.geometry.service"
44
-
45
- [[test]]
46
- # Extra dependencies only to be used during test run
47
- dependencies = [
48
- "omni.kit.ui_test" # UI testing extension
49
- ]
50
-
51
- [settings]
52
- # CLI setting defaults (note: "help" and "run" are also supported)
53
- exts."ansys.geometry.service".dsgUrl = "grpc://127.0.0.1:5234"
54
- exts."ansys.geometry.service".omniUrl = "omniverse://localhost/Users/test"
55
- exts."ansys.geometry.service".securityCode = ""
56
- exts."ansys.geometry.service".temporal = "0"
57
- exts."ansys.geometry.service".vrmode = "0"
58
- exts."ansys.geometry.service".normalizeGeometry = "0"
59
- exts."ansys.geometry.service".timeScale = "1.0"
@@ -1,11 +0,0 @@
1
- # Changelog
2
-
3
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
4
-
5
-
6
- ## [0.8.7] - 2024-07-12
7
- - Support for time varying data and temporal scaling
8
-
9
- ## [0.8.4] - 2024-06-28
10
- - Initial kit version of ANSYS Geometry Service Server
11
-
@@ -1,13 +0,0 @@
1
- # ANSYS Omniverse Geometry Service [ansys.geometry.service]
2
-
3
- The Omniverse extension provides a dynamic connection between an ANSYS
4
- geometry source (e.g. ANSYS EnSight) and an Omniverse instance. The
5
- connection runs as a standalone service capable of supporting scripted
6
- execution utilizing just a kit CLI. It can also be launched via
7
- PyEnSight and via a simple GUI provided by the [ansys.geometry.serviceui]
8
- kit extension.
9
-
10
- For more details on this extension see:
11
- https://ensight.docs.pyansys.com/version/dev/user_guide/omniverse_info.html
12
-
13
-
@@ -1,18 +0,0 @@
1
- ansys.geometry.service
2
- ######################
3
-
4
-
5
- .. toctree::
6
- :maxdepth: 1
7
-
8
- README
9
- CHANGELOG
10
-
11
-
12
- .. automodule::"ansys.geometry.service"
13
- :platform: Windows-x86_64, Linux-x86_64
14
- :members:
15
- :undoc-members:
16
- :show-inheritance:
17
- :imported-members:
18
- :exclude-members: contextmanager