ansys-pyensight-core 0.8.9__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.
- ansys/pyensight/core/__init__.py +1 -1
- ansys/pyensight/core/common.py +216 -0
- ansys/pyensight/core/dockerlauncher.py +79 -94
- ansys/pyensight/core/enshell_grpc.py +32 -0
- ansys/pyensight/core/launch_ensight.py +120 -19
- ansys/pyensight/core/launcher.py +4 -60
- ansys/pyensight/core/libuserd.py +1832 -0
- ansys/pyensight/core/locallauncher.py +43 -2
- ansys/pyensight/core/renderable.py +30 -0
- ansys/pyensight/core/session.py +5 -0
- ansys/pyensight/core/utils/readers.py +15 -11
- {ansys_pyensight_core-0.8.9.dist-info → ansys_pyensight_core-0.8.10.dist-info}/METADATA +4 -6
- {ansys_pyensight_core-0.8.9.dist-info → ansys_pyensight_core-0.8.10.dist-info}/RECORD +15 -13
- {ansys_pyensight_core-0.8.9.dist-info → ansys_pyensight_core-0.8.10.dist-info}/LICENSE +0 -0
- {ansys_pyensight_core-0.8.9.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
|
|
41
|
+
def _prepare_pim( # pragma: no cover
|
|
42
42
|
product_version: Optional[str] = None,
|
|
43
|
-
|
|
44
|
-
|
|
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"
|
|
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
|
ansys/pyensight/core/launcher.py
CHANGED
|
@@ -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
|
|
|
@@ -63,6 +61,8 @@ class Launcher:
|
|
|
63
61
|
Additional command line options to be used to launch EnSight.
|
|
64
62
|
Please note, when using DockerLauncher, arguments that contain spaces
|
|
65
63
|
are not supported.
|
|
64
|
+
launch_web_ui : bool, optional
|
|
65
|
+
Whether to launch the webUI from EnSight
|
|
66
66
|
"""
|
|
67
67
|
|
|
68
68
|
def __init__(
|
|
@@ -72,6 +72,7 @@ class Launcher:
|
|
|
72
72
|
use_sos: Optional[int] = None,
|
|
73
73
|
enable_rest_api: bool = False,
|
|
74
74
|
additional_command_line_options: Optional[List] = None,
|
|
75
|
+
launch_webui: bool = False,
|
|
75
76
|
) -> None:
|
|
76
77
|
self._timeout = timeout
|
|
77
78
|
self._use_egl_param_val: bool = use_egl
|
|
@@ -92,6 +93,7 @@ class Launcher:
|
|
|
92
93
|
# a dict of any optional launcher specific query parameters for URLs
|
|
93
94
|
self._query_parameters: Dict[str, str] = {}
|
|
94
95
|
self._additional_command_line_options = additional_command_line_options
|
|
96
|
+
self._launch_webui = launch_webui
|
|
95
97
|
|
|
96
98
|
@property
|
|
97
99
|
def session_directory(self) -> str:
|
|
@@ -205,64 +207,6 @@ class Launcher:
|
|
|
205
207
|
ports.append(int(command_line[idx]))
|
|
206
208
|
return list(set(ports))
|
|
207
209
|
|
|
208
|
-
@staticmethod
|
|
209
|
-
def _find_unused_ports(count: int, avoid: Optional[List[int]] = None) -> Optional[List[int]]:
|
|
210
|
-
"""Find "count" unused ports on the host system
|
|
211
|
-
|
|
212
|
-
A port is considered unused if it does not respond to a "connect" attempt. Walk
|
|
213
|
-
the ports from 'start' to 'end' looking for unused ports and avoiding any ports
|
|
214
|
-
in the 'avoid' list. Stop once the desired number of ports have been
|
|
215
|
-
found. If an insufficient number of ports were found, return None.
|
|
216
|
-
|
|
217
|
-
Parameters
|
|
218
|
-
----------
|
|
219
|
-
count: int :
|
|
220
|
-
Number of unused ports to find
|
|
221
|
-
avoid: Optional[List[int]] :
|
|
222
|
-
An optional list of ports not to check
|
|
223
|
-
|
|
224
|
-
Returns
|
|
225
|
-
-------
|
|
226
|
-
The detected ports or None on failure
|
|
227
|
-
|
|
228
|
-
"""
|
|
229
|
-
if avoid is None:
|
|
230
|
-
avoid = []
|
|
231
|
-
ports = list()
|
|
232
|
-
|
|
233
|
-
# pick a starting port number
|
|
234
|
-
start = random.randint(1024, 64000)
|
|
235
|
-
# We will scan for 65530 ports unless end is specified
|
|
236
|
-
port_mod = 65530
|
|
237
|
-
end = start + port_mod - 1
|
|
238
|
-
# walk the "virtual" port range
|
|
239
|
-
for base_port in range(start, end + 1):
|
|
240
|
-
# Map to physical port range
|
|
241
|
-
# There have been some issues with 65534+ so we stop at 65530
|
|
242
|
-
port = base_port % port_mod
|
|
243
|
-
# port 0 is special
|
|
244
|
-
if port == 0: # pragma: no cover
|
|
245
|
-
continue # pragma: no cover
|
|
246
|
-
# avoid admin ports
|
|
247
|
-
if port < 1024: # pragma: no cover
|
|
248
|
-
continue # pragma: no cover
|
|
249
|
-
# are we supposed to skip this one?
|
|
250
|
-
if port in avoid: # pragma: no cover
|
|
251
|
-
continue # pragma: no cover
|
|
252
|
-
# is anyone listening?
|
|
253
|
-
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
254
|
-
result = sock.connect_ex(("127.0.0.1", port))
|
|
255
|
-
if result != 0:
|
|
256
|
-
ports.append(port)
|
|
257
|
-
else:
|
|
258
|
-
sock.close()
|
|
259
|
-
if len(ports) >= count:
|
|
260
|
-
return ports
|
|
261
|
-
# in case we failed...
|
|
262
|
-
if len(ports) < count: # pragma: no cover
|
|
263
|
-
return None # pragma: no cover
|
|
264
|
-
return ports # pragma: no cover
|
|
265
|
-
|
|
266
210
|
def _use_egl(self) -> bool:
|
|
267
211
|
"""Return True if the system supports the EGL and if EGL was desired.
|
|
268
212
|
|