ansys-pyensight-core 0.8.9__py3-none-any.whl → 0.8.11__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.

@@ -12,6 +12,7 @@ import glob
12
12
  import logging
13
13
  import os.path
14
14
  import platform
15
+ import re
15
16
  import shutil
16
17
  import subprocess
17
18
  import tempfile
@@ -20,6 +21,7 @@ from typing import Optional
20
21
  import uuid
21
22
 
22
23
  import ansys.pyensight.core as pyensight
24
+ from ansys.pyensight.core.common import find_unused_ports
23
25
  from ansys.pyensight.core.launcher import Launcher
24
26
  import ansys.pyensight.core.session
25
27
 
@@ -89,6 +91,7 @@ class LocalLauncher(Launcher):
89
91
  # launched process ids
90
92
  self._ensight_pid = None
91
93
  self._websocketserver_pid = None
94
+ self._webui_pid = None
92
95
  # and ports
93
96
  self._ports = None
94
97
  # Are we running the instance in batch
@@ -99,6 +102,36 @@ class LocalLauncher(Launcher):
99
102
  """Type of app to launch. Options are ``ensight`` and ``envision``."""
100
103
  return self._application
101
104
 
105
+ def launch_webui(self, cpython, webui_script, popen_common):
106
+ cmd = [cpython]
107
+ cmd += [webui_script]
108
+ version = re.findall(r"nexus(\d+)", webui_script)[0]
109
+ path_to_webui = self._install_path
110
+ path_to_webui = os.path.join(
111
+ path_to_webui, f"nexus{version}", f"ansys{version}", "ensight", "WebUI", "web", "ui"
112
+ )
113
+ cmd += ["--server-listen-port", str(self._ports[5])]
114
+ cmd += ["--server-web-roots", path_to_webui]
115
+ cmd += ["--ensight-grpc-port", str(self._ports[0])]
116
+ cmd += ["--ensight-html-port", str(self._ports[2])]
117
+ cmd += ["--ensight-ws-port", str(self._ports[3])]
118
+ cmd += ["--ensight-session-directory", self._session_directory]
119
+ cmd += ["--ensight-secret-key", self._secret_key]
120
+ if "PYENSIGHT_DEBUG" in os.environ:
121
+ try:
122
+ if int(os.environ["PYENSIGHT_DEBUG"]) > 0:
123
+ del popen_common["stdout"]
124
+ del popen_common["stderr"]
125
+ except (ValueError, KeyError):
126
+ pass
127
+ popen_common["env"].update(
128
+ {
129
+ "SIMBA_WEBSERVER_TOKEN": self._secret_key,
130
+ "FLUENT_WEBSERVER_TOKEN": self._secret_key,
131
+ }
132
+ )
133
+ self._webui_pid = subprocess.Popen(cmd, **popen_common).pid
134
+
102
135
  def start(self) -> "pyensight.Session":
103
136
  """Start an EnSight session using the local EnSight installation.
104
137
 
@@ -126,7 +159,10 @@ class LocalLauncher(Launcher):
126
159
 
127
160
  # gRPC port, VNC port, websocketserver ws, websocketserver html
128
161
  to_avoid = self._find_ports_used_by_other_pyensight_and_ensight()
129
- self._ports = self._find_unused_ports(5, avoid=to_avoid)
162
+ num_ports = 5
163
+ if self._launch_webui:
164
+ num_ports = 6
165
+ self._ports = find_unused_ports(num_ports, avoid=to_avoid)
130
166
  if self._ports is None:
131
167
  raise RuntimeError("Unable to allocate local ports for EnSight session")
132
168
  is_windows = self._is_windows()
@@ -211,11 +247,12 @@ class LocalLauncher(Launcher):
211
247
  except Exception:
212
248
  pass
213
249
  websocket_script = found_scripts[idx]
214
-
250
+ webui_script = websocket_script.replace("websocketserver.py", "webui_launcher.py")
215
251
  # build the commandline
216
252
  cmd = [os.path.join(self._install_path, "bin", "cpython"), websocket_script]
217
253
  if is_windows:
218
254
  cmd[0] += ".bat"
255
+ ensight_python = cmd[0]
219
256
  cmd.extend(["--http_directory", self.session_directory])
220
257
  # http port
221
258
  cmd.extend(["--http_port", str(self._ports[2])])
@@ -256,9 +293,13 @@ class LocalLauncher(Launcher):
256
293
  timeout=self._timeout,
257
294
  sos=use_sos,
258
295
  rest_api=self._enable_rest_api,
296
+ webui_port=self._ports[5] if self._launch_webui else None,
259
297
  )
260
298
  session.launcher = self
261
299
  self._sessions.append(session)
300
+
301
+ if self._launch_webui:
302
+ self.launch_webui(ensight_python, webui_script, popen_common)
262
303
  return session
263
304
 
264
305
  def stop(self) -> None:
@@ -3,10 +3,12 @@
3
3
  This module provides the interface for creating objects in the EnSight session
4
4
  that can be displayed via HTML over the websocket server interface.
5
5
  """
6
+ import hashlib
6
7
  import os
7
8
  import shutil
8
9
  from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union, no_type_check
9
10
  import uuid
11
+ import warnings
10
12
  import webbrowser
11
13
 
12
14
  import requests
@@ -812,3 +814,31 @@ class RenderableSGEO(Renderable): # pragma: no cover
812
814
  html = html.replace("REVURL_ITEMID", revision_uri)
813
815
  html = html.replace("ITEMID", self._guid)
814
816
  return html
817
+
818
+
819
+ class RenderableFluidsWebUI(Renderable):
820
+ def __init__(self, *args, **kwargs) -> None:
821
+ super().__init__(*args, **kwargs)
822
+ self._session.ensight_version_check("2025 R1")
823
+ warnings.warn("The webUI is still under active development and should be considered beta.")
824
+ self._rendertype = "webui"
825
+ self._generate_url()
826
+ self.update()
827
+
828
+ def _generate_url(self) -> None:
829
+ sha256_hash = hashlib.sha256()
830
+ sha256_hash.update(self._session._secret_key.encode())
831
+ token = sha256_hash.hexdigest()
832
+ optional_query = self._get_query_parameters_str()
833
+ port = self._session._webui_port
834
+ if "instance_name" in self._session._launcher._get_query_parameters():
835
+ instance_name = self._session._launcher._get_query_parameters()["instance_name"]
836
+ # If using PIM, the port needs to be the 443 HTTPS Port;
837
+ port = self._session.html_port
838
+ # In the webUI code there's already a workflow to pass down the query parameter
839
+ # ans_instance_id, just use it
840
+ instance_name = self._session._launcher._get_query_parameters()["instance_name"]
841
+ optional_query = f"?ans_instance_id={instance_name}"
842
+ url = f"{self._http_protocol}://{self._session.html_hostname}:{port}"
843
+ url += f"{optional_query}#{token}"
844
+ self._url = url
@@ -31,6 +31,7 @@ from ansys.pyensight.core.listobj import ensobjlist
31
31
  from ansys.pyensight.core.renderable import (
32
32
  RenderableDeepPixel,
33
33
  RenderableEVSN,
34
+ RenderableFluidsWebUI,
34
35
  RenderableImage,
35
36
  RenderableMP4,
36
37
  RenderableSGEO,
@@ -136,6 +137,7 @@ class Session:
136
137
  timeout: float = 120.0,
137
138
  rest_api: bool = False,
138
139
  sos: bool = False,
140
+ webui_port: Optional[int] = None,
139
141
  ) -> None:
140
142
  # every session instance needs a unique name that can be used as a cache key
141
143
  self._session_name = str(uuid.uuid1())
@@ -161,6 +163,7 @@ class Session:
161
163
  self._grpc_port = grpc_port
162
164
  self._halt_ensight_on_close = True
163
165
  self._callbacks: Dict[str, Tuple[int, Any]] = dict()
166
+ self._webui_port = webui_port
164
167
  # if the caller passed a session directory we will assume they are
165
168
  # creating effectively a proxy Session and create a (stub) launcher
166
169
  if session_directory is not None:
@@ -927,6 +930,8 @@ class Session:
927
930
  # Undocumented. Available only internally
928
931
  elif what == "webensight":
929
932
  render = RenderableVNCAngular(self, **kwargs)
933
+ elif what == "webui":
934
+ render = RenderableFluidsWebUI(self, **kwargs)
930
935
 
931
936
  if render is None:
932
937
  raise RuntimeError("Unable to generate requested visualization")
@@ -44,7 +44,7 @@ class Omniverse:
44
44
  >>> from ansys.pyensight.core import LocalLauncher
45
45
  >>> session = LocalLauncher().start()
46
46
  >>> ov = session.ensight.utils.omniverse
47
- >>> ov.create_connection()
47
+ >>> ov.create_connection(r"D:\Omniverse\Example")
48
48
  >>> ov.update()
49
49
  >>> ov.close_connection()
50
50
 
@@ -202,8 +202,8 @@ class Omniverse:
202
202
  Parameters
203
203
  ----------
204
204
  omniverse_path : str
205
- The URI to the Omniverse server. It will look like this:
206
- "omniverse://localhost/Users/test"
205
+ The directory name where the USD files should be saved. For example:
206
+ "C:/Users/test/OV/usdfiles"
207
207
  include_camera : bool
208
208
  If True, apply the EnSight camera to the Omniverse scene. This option
209
209
  should be used if the target viewer is in AR/VR mode. Defaults to False.
@@ -10,8 +10,6 @@ from types import ModuleType
10
10
  from typing import Optional, Tuple, Union
11
11
  import uuid
12
12
 
13
- from ansys.pyensight.core import LocalLauncher
14
-
15
13
  try:
16
14
  import ensight
17
15
  except ImportError:
@@ -27,6 +25,7 @@ class Readers:
27
25
 
28
26
  @property
29
27
  def dvs(self) -> "DVS":
28
+ """The ensight interface"""
30
29
  return self._dvs
31
30
 
32
31
 
@@ -104,15 +103,20 @@ class DVS:
104
103
  """Find the dvs port allocated from the input temporary name"""
105
104
  if not tmp_name:
106
105
  raise RuntimeError("Temporary name for dvs port file not available")
107
- is_local = isinstance(self._ensight._session._launcher, LocalLauncher)
108
- if is_local:
109
- with open(tmp_name) as dvs_port_file:
110
- self._dvs_port = int(dvs_port_file.read().strip())
111
- else:
112
- log_content = self._ensight._session._launcher.enshell_log_contents()
113
- dvs_port_match = re.search(r"\(0.0.0.0\):([0-9]{4,5})\n", log_content)
114
- if dvs_port_match:
115
- self._dvs_port = int(str(dvs_port_match.groups(1)[0]).strip())
106
+ try_local = True
107
+ if self._ensight._session._launcher:
108
+ if hasattr(self._ensight._session._launcher, "_enshell"):
109
+ try_local = False
110
+ log_content = self._ensight._session._launcher.enshell_log_contents()
111
+ dvs_port_match = re.search(r"\(0.0.0.0\):([0-9]{4,5})\n", log_content)
112
+ if dvs_port_match:
113
+ self._dvs_port = int(str(dvs_port_match.groups(1)[0]).strip())
114
+ if try_local:
115
+ try:
116
+ with open(tmp_name) as dvs_port_file:
117
+ self._dvs_port = int(dvs_port_file.read().strip())
118
+ except Exception:
119
+ raise RuntimeError("Cannot retrieve DVS Port")
116
120
 
117
121
  @staticmethod
118
122
  def _launch_dvs_callback_in_ensight(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ansys-pyensight-core
3
- Version: 0.8.9
3
+ Version: 0.8.11
4
4
  Summary: A python wrapper for Ansys EnSight
5
5
  Author-email: "ANSYS, Inc." <pyansys.core@ansys.com>
6
6
  Maintainer-email: "ANSYS, Inc." <pyansys.core@ansys.com>
@@ -16,7 +16,7 @@ Classifier: Programming Language :: Python :: 3.10
16
16
  Classifier: Programming Language :: Python :: 3.11
17
17
  Classifier: Programming Language :: Python :: 3.12
18
18
  Requires-Dist: importlib-metadata>=4.0; python_version<='3.8'
19
- Requires-Dist: ansys-api-pyensight==0.4.1
19
+ Requires-Dist: ansys-api-pyensight==0.4.2
20
20
  Requires-Dist: requests>=2.28.2
21
21
  Requires-Dist: docker>=6.1.0
22
22
  Requires-Dist: urllib3<3.0.0
@@ -24,13 +24,13 @@ Requires-Dist: numpy>=1.21.0,<2
24
24
  Requires-Dist: Pillow>=9.3.0
25
25
  Requires-Dist: pypng>=0.0.20
26
26
  Requires-Dist: psutil>=5.9.2
27
+ Requires-Dist: usd-core>=24.8
28
+ Requires-Dist: pygltflib>=1.16.2
27
29
  Requires-Dist: build>=0.10.0 ; extra == "dev"
28
30
  Requires-Dist: bump2version>=1.0.1 ; extra == "dev"
29
31
  Requires-Dist: ipdb>=0.9.4 ; extra == "dev"
30
32
  Requires-Dist: dill>=0.3.5.1 ; extra == "dev"
31
33
  Requires-Dist: pre-commit>=3.3.3 ; extra == "dev"
32
- Requires-Dist: usd-core>=24.8 ; extra == "dev"
33
- Requires-Dist: pygltflib>=1.16.2 ; extra == "dev"
34
34
  Requires-Dist: Sphinx==8.0.2 ; extra == "doc"
35
35
  Requires-Dist: numpydoc==1.5.0 ; extra == "doc"
36
36
  Requires-Dist: ansys-sphinx-theme==0.9.9 ; extra == "doc"
@@ -53,8 +53,6 @@ Requires-Dist: pytest-mock==3.10.0 ; extra == "tests"
53
53
  Requires-Dist: urllib3==2.2.2 ; extra == "tests"
54
54
  Requires-Dist: requests>=2.28.2 ; extra == "tests"
55
55
  Requires-Dist: docker>=6.1.0 ; extra == "tests"
56
- Requires-Dist: usd-core>=24.8 ; extra == "tests"
57
- Requires-Dist: pygltflib>=1.16.2 ; extra == "tests"
58
56
  Project-URL: Changelog, https://github.com/ansys/pyensight/blob/main/CHANGELOG.rst
59
57
  Project-URL: Documentation, https://ensight.docs.pyansys.com/
60
58
  Project-URL: Homepage, https://github.com/ansys/pyensight
@@ -1,34 +1,36 @@
1
- ansys/pyensight/core/__init__.py,sha256=6iKVEEtxt-6mw7wu_AocOGYO1T1WYHAnk-X_jeTeA8k,828
1
+ ansys/pyensight/core/__init__.py,sha256=yF8ER4bnq8oPCdC1iyO-0Po8zg1hnmkXIooOtyz2INQ,845
2
+ ansys/pyensight/core/common.py,sha256=BgnRfE5NltIjVkI96U98zWv_u4QcLyeMetD59LKVAI4,7086
2
3
  ansys/pyensight/core/deep_pixel_view.html,sha256=oZmcCIS3Dqqsoj8oheYubLAH2ZVKXao3iJM2WXYBEKs,3421
3
- ansys/pyensight/core/dockerlauncher.py,sha256=AEuBA24hdWn82vPSyBkx66OyEHeIyozICWeF_zDx-yA,28540
4
+ ansys/pyensight/core/dockerlauncher.py,sha256=LmgEFEjl0l3D_JaeJu5bbGR28aluHYtzb0-BmrC7ta8,28251
4
5
  ansys/pyensight/core/enscontext.py,sha256=GSKkjZt1QEPyHEQ59EEBgKGMik9vjCdR9coR4uX7fEw,12141
5
- ansys/pyensight/core/enshell_grpc.py,sha256=ijRcByqdG0ZIi958Co860w2mnBIklfguI6s8sewcR8Q,15904
6
+ ansys/pyensight/core/enshell_grpc.py,sha256=-OxSdFI_p3DmQnqh1jT_a_aSh_w-EUD2IaWGKxrnyjI,17122
6
7
  ansys/pyensight/core/ensight_grpc.py,sha256=BJaErleSPrtI8myTIh0m9awFWPaUxrQmHpbuyR3RpM4,16847
7
8
  ansys/pyensight/core/ensobj.py,sha256=uDtM2KHcAwd4hu5pcUYWbSD729ApHGIvuqZhEq8PxTI,18558
8
- ansys/pyensight/core/launch_ensight.py,sha256=UyTDDmxru864YAihTY9EQ5NIbKFRiLpWGPHMu7JUgyY,6175
9
- ansys/pyensight/core/launcher.py,sha256=J9yZnP3ygfGmw26hCYS_H1zk_YI_IE6QS8ItWJ80vwU,12659
9
+ ansys/pyensight/core/launch_ensight.py,sha256=iZJM6GdpzGRDLzrv1V2QZ5veIOpNSB5xPpJUFY7rBuo,10254
10
+ ansys/pyensight/core/launcher.py,sha256=ymwfixwoHO7_c4qOetqccQbZjGT1HjeA7jwPi2JxlmE,10585
11
+ ansys/pyensight/core/libuserd.py,sha256=P5ewBFey_a9YYhRhbWSCCy2KXtyccsJyyLWlYh-Hxgo,72592
10
12
  ansys/pyensight/core/listobj.py,sha256=Trw87IxIMXtmUd1DzywRmMzORU704AG4scX4fqYmO6M,9340
11
- ansys/pyensight/core/locallauncher.py,sha256=s70b7sYurRy1VD5ZI2JFVhruX3bmxCOTp7_YWQXoZs8,14376
13
+ ansys/pyensight/core/locallauncher.py,sha256=MnSyKVe0JGXN0YJ9f_msw_TBbLGfqDpjWWC4-haAjJ4,16205
12
14
  ansys/pyensight/core/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
- ansys/pyensight/core/renderable.py,sha256=hm4sXV-ZcpdfC_AJexycAX8zdsbWnsd-tMeUvewGekE,35003
14
- ansys/pyensight/core/session.py,sha256=W7sSuZEK648va69lE6EiiOqd_h9YRwgRXihZoNB9V78,74386
15
+ ansys/pyensight/core/renderable.py,sha256=Z59F0u1Znot_MU_fT77F4CO7qbDxqDetFGzzgZcekCs,36440
16
+ ansys/pyensight/core/session.py,sha256=jQA1sT7N3Q4iATH0vtzKf3v6ghg461LphZ2nUeyufCU,74587
15
17
  ansys/pyensight/core/sgeo_poll.html,sha256=1M4BIc5CZpYA3b40qzk22NcPCLhjFnWdoS2PrS6Rhn4,752
16
18
  ansys/pyensight/core/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
19
  ansys/pyensight/core/utils/adr.py,sha256=XslZhlwcrSGzOlnhzprOv3ju_ppxxsWBjCnQL5KiNms,3570
18
20
  ansys/pyensight/core/utils/dsg_server.py,sha256=zPvIHlgiJxiy0NQm3uIsh2nPY8TyAHaHaXtDMN28jiY,38869
19
21
  ansys/pyensight/core/utils/export.py,sha256=ZNpU3earAnRMBHZa6I8nTwMYY54WctXApJfMTkREBNA,23189
20
- ansys/pyensight/core/utils/omniverse.py,sha256=GWTYQhhVMT9x4kpMPpI51mHNiV1ths2zk8YzBZ2eeD0,14222
22
+ ansys/pyensight/core/utils/omniverse.py,sha256=k3SxbK_BDmwbiUPr9PLKEswZAyri6EEiT_gaMWIu6zw,14250
21
23
  ansys/pyensight/core/utils/omniverse_cli.py,sha256=aePr-2AWla2mMgPx8NlwIApAD1rAdVLmNOBWKjMXNQA,18786
22
24
  ansys/pyensight/core/utils/omniverse_dsg_server.py,sha256=SjKY8-q-M26tge13HW6Js71RoQnFgkjWELtHpXk707c,28185
23
25
  ansys/pyensight/core/utils/omniverse_glb_server.py,sha256=VYSbIwKMZASAmgYwRGbN5PrCjbSdaL7MaFxMnOJlTFg,9793
24
26
  ansys/pyensight/core/utils/parts.py,sha256=zST00r76kjsLLclBaKoOtuYhDUSdQr0vAooOG7AUea0,53372
25
27
  ansys/pyensight/core/utils/query.py,sha256=OXKDbf1sOTX0sUvtKcp64LhVl-BcrEsE43w8uMxLOYI,19828
26
- ansys/pyensight/core/utils/readers.py,sha256=WUpmCtMo9BHlUOwGtIrD5jjyS9HE9wDak8eEjrYeR2Y,11764
28
+ ansys/pyensight/core/utils/readers.py,sha256=cNNzrE5pjy4wpQKWAzIIJfJCSpY3HU43az02f5I3pVU,11968
27
29
  ansys/pyensight/core/utils/support.py,sha256=QI3z9ex7zJxjFbkCPba9DWqWgPFIThORqr0nvRfVjuc,4089
28
30
  ansys/pyensight/core/utils/variables.py,sha256=T96aL-qR2FtxH6QafeD9ddcWL9BB6IRSOYs2JauRTlg,95133
29
31
  ansys/pyensight/core/utils/views.py,sha256=ZKhJ6vMT7Rdd4bwJ0egMYTV7-D7Q7I19fF2_j_CMQ0o,12489
30
32
  ansys/pyensight/core/utils/resources/Materials/000_sky.exr,sha256=xAR1gFd2uxPZDnvgfegdhEhRaqKtZldQDiR_-1rHKO0,8819933
31
- ansys_pyensight_core-0.8.9.dist-info/LICENSE,sha256=qQWivZ12ETN5l3QxvTARY-QI5eoRRlyHdwLlAj0Bg5I,1089
32
- ansys_pyensight_core-0.8.9.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
33
- ansys_pyensight_core-0.8.9.dist-info/METADATA,sha256=Tvyi5fhWgWo09nNEPF99-_iSKrHtNHkj6AlAbGcA19A,12133
34
- ansys_pyensight_core-0.8.9.dist-info/RECORD,,
33
+ ansys_pyensight_core-0.8.11.dist-info/LICENSE,sha256=qQWivZ12ETN5l3QxvTARY-QI5eoRRlyHdwLlAj0Bg5I,1089
34
+ ansys_pyensight_core-0.8.11.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
35
+ ansys_pyensight_core-0.8.11.dist-info/METADATA,sha256=7HoVAVfhnAucYeDmIIrcRhCXjcObDnISxnMQHENPKgM,11999
36
+ ansys_pyensight_core-0.8.11.dist-info/RECORD,,