ansys-pyensight-core 0.8.8__py3-none-any.whl → 0.8.10__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 (41) hide show
  1. ansys/pyensight/core/__init__.py +1 -1
  2. ansys/pyensight/core/common.py +216 -0
  3. ansys/pyensight/core/dockerlauncher.py +85 -94
  4. ansys/pyensight/core/enshell_grpc.py +32 -0
  5. ansys/pyensight/core/launch_ensight.py +120 -19
  6. ansys/pyensight/core/launcher.py +10 -61
  7. ansys/pyensight/core/libuserd.py +1832 -0
  8. ansys/pyensight/core/locallauncher.py +47 -2
  9. ansys/pyensight/core/renderable.py +30 -0
  10. ansys/pyensight/core/session.py +6 -1
  11. ansys/pyensight/core/utils/dsg_server.py +227 -35
  12. ansys/pyensight/core/utils/omniverse.py +84 -24
  13. ansys/pyensight/core/utils/omniverse_cli.py +481 -0
  14. ansys/pyensight/core/utils/omniverse_dsg_server.py +236 -426
  15. ansys/pyensight/core/utils/omniverse_glb_server.py +279 -0
  16. ansys/pyensight/core/utils/readers.py +15 -11
  17. {ansys_pyensight_core-0.8.8.dist-info → ansys_pyensight_core-0.8.10.dist-info}/METADATA +10 -6
  18. ansys_pyensight_core-0.8.10.dist-info/RECORD +36 -0
  19. ansys/pyensight/core/exts/ansys.geometry.service/ansys/geometry/service/__init__.py +0 -1
  20. ansys/pyensight/core/exts/ansys.geometry.service/ansys/geometry/service/extension.py +0 -407
  21. ansys/pyensight/core/exts/ansys.geometry.service/config/extension.toml +0 -59
  22. ansys/pyensight/core/exts/ansys.geometry.service/data/icon.png +0 -0
  23. ansys/pyensight/core/exts/ansys.geometry.service/data/preview.png +0 -0
  24. ansys/pyensight/core/exts/ansys.geometry.service/docs/CHANGELOG.md +0 -11
  25. ansys/pyensight/core/exts/ansys.geometry.service/docs/README.md +0 -13
  26. ansys/pyensight/core/exts/ansys.geometry.service/docs/index.rst +0 -18
  27. ansys/pyensight/core/exts/ansys.geometry.serviceui/ansys/geometry/serviceui/__init__.py +0 -1
  28. ansys/pyensight/core/exts/ansys.geometry.serviceui/ansys/geometry/serviceui/extension.py +0 -193
  29. ansys/pyensight/core/exts/ansys.geometry.serviceui/config/extension.toml +0 -49
  30. ansys/pyensight/core/exts/ansys.geometry.serviceui/data/icon.png +0 -0
  31. ansys/pyensight/core/exts/ansys.geometry.serviceui/data/preview.png +0 -0
  32. ansys/pyensight/core/exts/ansys.geometry.serviceui/docs/CHANGELOG.md +0 -11
  33. ansys/pyensight/core/exts/ansys.geometry.serviceui/docs/README.md +0 -13
  34. ansys/pyensight/core/exts/ansys.geometry.serviceui/docs/index.rst +0 -18
  35. ansys/pyensight/core/utils/resources/Materials/Fieldstone/Fieldstone_BaseColor.png +0 -0
  36. ansys/pyensight/core/utils/resources/Materials/Fieldstone/Fieldstone_N.png +0 -0
  37. ansys/pyensight/core/utils/resources/Materials/Fieldstone/Fieldstone_ORM.png +0 -0
  38. ansys/pyensight/core/utils/resources/Materials/Fieldstone.mdl +0 -54
  39. ansys_pyensight_core-0.8.8.dist-info/RECORD +0 -52
  40. {ansys_pyensight_core-0.8.8.dist-info → ansys_pyensight_core-0.8.10.dist-info}/LICENSE +0 -0
  41. {ansys_pyensight_core-0.8.8.dist-info → ansys_pyensight_core-0.8.10.dist-info}/WHEEL +0 -0
@@ -36,33 +36,19 @@ except Exception: # pragma: no cover
36
36
  logging.debug(f"docker_is_available: {docker_is_available}\n")
37
37
 
38
38
 
39
- if pim_is_available:
39
+ if pim_is_available: # pragma: no cover
40
40
 
41
- def _launch_ensight_with_pim(
41
+ def _prepare_pim( # pragma: no cover
42
42
  product_version: Optional[str] = None,
43
- **kwargs,
44
- ) -> "Session":
45
- """Internal function.
46
- Start via PyPIM the EnSight Docker container with EnShell as the ENTRYPOINT.
47
- Create and bind a Session instance to the created gRPC session. Return that session.
43
+ ):
44
+ """Create a PIM instance and gRPC channel for the input version of EnSight.
48
45
 
49
46
  Parameters
50
47
  ----------
51
48
  product_version : str, optional
52
- Version of the product. For example, "232". The default is "None", in which case
53
- use_egl : bool, optional
54
- If True, EGL hardware accelerated graphics will be used. The platform
55
- must be able to support it.
56
- use_sos : int, optional
57
- If None, don't use SOS. Otherwise, it's the number of EnSight Servers to use (int).
58
-
59
- Returns
60
- -------
61
-
62
- pyensight Session object instance
49
+ Version of the product. For example, "232". The default is "None"
63
50
 
64
51
  """
65
-
66
52
  pim = pypim.connect()
67
53
  instance = pim.create_instance(
68
54
  product_name="ensight",
@@ -77,10 +63,46 @@ if pim_is_available:
77
63
  ("grpc.testing.fixed_reconnect_backoff_ms", 1100),
78
64
  ]
79
65
  )
66
+ return instance, channel
67
+
68
+ def _launch_ensight_with_pim( # pragma: no cover
69
+ product_version: Optional[str] = None,
70
+ **kwargs,
71
+ ) -> "Session":
72
+ """Internal function.
73
+ Start via PyPIM the EnSight Docker container with EnShell as the ENTRYPOINT.
74
+ Create and bind a Session instance to the created gRPC session. Return that session.
80
75
 
76
+ Parameters
77
+ ----------
78
+ product_version : str, optional
79
+ Version of the product. For example, "232". The default is "None"
80
+ use_egl : bool, optional
81
+ If True, EGL hardware accelerated graphics will be used. The platform
82
+ must be able to support it.
83
+ use_sos : int, optional
84
+ If None, don't use SOS. Otherwise, it's the number of EnSight Servers to use (int).
85
+
86
+ Returns
87
+ -------
88
+ Session
89
+ pyensight Session object instance
90
+
91
+ """
92
+ instance, channel = _prepare_pim(product_version=product_version)
81
93
  launcher = DockerLauncher(channel=channel, pim_instance=instance, **kwargs)
82
94
  return launcher.connect()
83
95
 
96
+ def _launch_libuserd_with_pim(
97
+ product_version: Optional[str] = None, **kwargs
98
+ ): # pragma: no cover
99
+ from ansys.pyensight.core.libuserd import LibUserd
100
+
101
+ instance, channel = _prepare_pim(product_version=product_version)
102
+ libuserd = LibUserd(channel=channel, pim_instance=instance, **kwargs)
103
+ libuserd.initialize()
104
+ return libuserd
105
+
84
106
 
85
107
  def launch_ensight(
86
108
  product_version: Optional[str] = None,
@@ -171,3 +193,82 @@ def launch_ensight(
171
193
  **kwargs, # pragma: no cover
172
194
  ) # pragma: no cover
173
195
  return launcher.start() # pragma: no cover
196
+
197
+
198
+ def launch_libuserd( # pragma: no cover
199
+ product_version: Optional[str] = None,
200
+ use_pim: bool = True,
201
+ use_docker: bool = True,
202
+ data_directory: Optional[str] = None,
203
+ docker_image_name: Optional[str] = None,
204
+ use_dev: bool = False,
205
+ ansys_installation: Optional[str] = None,
206
+ timeout: float = 120.0,
207
+ pull_image_if_not_available: bool = False,
208
+ ):
209
+ """Start an EnSight session via EnShell using the Docker EnSight Image.
210
+ Return that session.
211
+
212
+ Parameters
213
+ ----------
214
+ product_version : str, optional
215
+ Select an installed version of ANSYS. The string must be in a format like
216
+ "232" (for 2023 R2). The default is "None", in which case the newest installed
217
+ version is used.
218
+ use_pim : bool, optional
219
+ If True, then PyPIM is used to launch the EnSight image.
220
+ use_docker : bool, optional
221
+ If True, use DockerLaucher. If use_pim is True, this option is ignored.
222
+ data_directory: str, optional
223
+ Host directory to make into the Docker container at /data
224
+ Only used if use_docker is True.
225
+ docker_image_name: str, optional
226
+ Optional Docker Image name to use
227
+ use_dev: bool, optional
228
+ Option to use the latest ensight_dev Docker Image; overridden by docker_image_name if specified.
229
+ ansys_installation: str, optional
230
+ Location of the ANSYS installation, including the version.
231
+ directory Default: None (causes common locations to be scanned).
232
+ If use_pim is True, this option is ignored. If use_docker is True, this option is ignored.
233
+ application: str, optional
234
+ The application to be launched. By default, "ensight", but
235
+ "envision" is also available.
236
+ timeout: float, optional
237
+ In some cases where the EnSight session can take a significant amount of
238
+ time to start up, this is the number of seconds to wait before failing
239
+ the connection. The default is 120.0.
240
+ pull_image_if_not_available: bool
241
+ If True, the image will be pulled using Docker. If use_pim is True this option
242
+ is ignored.
243
+ Returns
244
+ -------
245
+ type
246
+ LibUserd object instance
247
+
248
+ Raises
249
+ ------
250
+ RuntimeError
251
+ variety of error conditions
252
+
253
+ """
254
+ from ansys.pyensight.core.libuserd import LibUserd
255
+
256
+ logging.debug(f"pim_is_available: {pim_is_available} use_pim: {use_pim}\n") # pragma: no cover
257
+ if pim_is_available and use_pim: # pragma: no cover
258
+ if pypim.is_configured():
259
+ return _launch_libuserd_with_pim(product_version=product_version, timeout=timeout)
260
+ logging.debug(f"docker_is_available: {docker_is_available} use_docker: {use_docker}\n")
261
+ if docker_is_available and use_docker:
262
+ libuserd = LibUserd(
263
+ data_directory=data_directory,
264
+ docker_image_name=docker_image_name,
265
+ use_dev=use_dev,
266
+ use_docker=use_docker,
267
+ timeout=timeout,
268
+ pull_image_if_not_available=pull_image_if_not_available,
269
+ )
270
+ libuserd.initialize()
271
+ return libuserd
272
+ libuserd = LibUserd(ansys_installation=ansys_installation, timeout=timeout)
273
+ libuserd.initialize()
274
+ return libuserd
@@ -13,9 +13,7 @@ Examples:
13
13
  """
14
14
  import os.path
15
15
  import platform
16
- import random
17
16
  import re
18
- import socket
19
17
  from typing import TYPE_CHECKING, Dict, List, Optional
20
18
  import warnings
21
19
 
@@ -59,7 +57,12 @@ class Launcher:
59
57
  enable_rest_api : bool, optional
60
58
  Whether to enable the EnSight REST API. The default is ``False``.
61
59
  This parameter is supported in EnSight 2024 R1 and later.
62
-
60
+ additional_command_line_options: list, optional
61
+ Additional command line options to be used to launch EnSight.
62
+ Please note, when using DockerLauncher, arguments that contain spaces
63
+ are not supported.
64
+ launch_web_ui : bool, optional
65
+ Whether to launch the webUI from EnSight
63
66
  """
64
67
 
65
68
  def __init__(
@@ -68,6 +71,8 @@ class Launcher:
68
71
  use_egl: bool = False,
69
72
  use_sos: Optional[int] = None,
70
73
  enable_rest_api: bool = False,
74
+ additional_command_line_options: Optional[List] = None,
75
+ launch_webui: bool = False,
71
76
  ) -> None:
72
77
  self._timeout = timeout
73
78
  self._use_egl_param_val: bool = use_egl
@@ -87,6 +92,8 @@ class Launcher:
87
92
  self._egl_env_val = False
88
93
  # a dict of any optional launcher specific query parameters for URLs
89
94
  self._query_parameters: Dict[str, str] = {}
95
+ self._additional_command_line_options = additional_command_line_options
96
+ self._launch_webui = launch_webui
90
97
 
91
98
  @property
92
99
  def session_directory(self) -> str:
@@ -200,64 +207,6 @@ class Launcher:
200
207
  ports.append(int(command_line[idx]))
201
208
  return list(set(ports))
202
209
 
203
- @staticmethod
204
- def _find_unused_ports(count: int, avoid: Optional[List[int]] = None) -> Optional[List[int]]:
205
- """Find "count" unused ports on the host system
206
-
207
- A port is considered unused if it does not respond to a "connect" attempt. Walk
208
- the ports from 'start' to 'end' looking for unused ports and avoiding any ports
209
- in the 'avoid' list. Stop once the desired number of ports have been
210
- found. If an insufficient number of ports were found, return None.
211
-
212
- Parameters
213
- ----------
214
- count: int :
215
- Number of unused ports to find
216
- avoid: Optional[List[int]] :
217
- An optional list of ports not to check
218
-
219
- Returns
220
- -------
221
- The detected ports or None on failure
222
-
223
- """
224
- if avoid is None:
225
- avoid = []
226
- ports = list()
227
-
228
- # pick a starting port number
229
- start = random.randint(1024, 64000)
230
- # We will scan for 65530 ports unless end is specified
231
- port_mod = 65530
232
- end = start + port_mod - 1
233
- # walk the "virtual" port range
234
- for base_port in range(start, end + 1):
235
- # Map to physical port range
236
- # There have been some issues with 65534+ so we stop at 65530
237
- port = base_port % port_mod
238
- # port 0 is special
239
- if port == 0: # pragma: no cover
240
- continue # pragma: no cover
241
- # avoid admin ports
242
- if port < 1024: # pragma: no cover
243
- continue # pragma: no cover
244
- # are we supposed to skip this one?
245
- if port in avoid: # pragma: no cover
246
- continue # pragma: no cover
247
- # is anyone listening?
248
- sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
249
- result = sock.connect_ex(("127.0.0.1", port))
250
- if result != 0:
251
- ports.append(port)
252
- else:
253
- sock.close()
254
- if len(ports) >= count:
255
- return ports
256
- # in case we failed...
257
- if len(ports) < count: # pragma: no cover
258
- return None # pragma: no cover
259
- return ports # pragma: no cover
260
-
261
210
  def _use_egl(self) -> bool:
262
211
  """Return True if the system supports the EGL and if EGL was desired.
263
212