ansys-pyensight-core 0.10.2__tar.gz → 0.10.4__tar.gz

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 (37) hide show
  1. {ansys_pyensight_core-0.10.2 → ansys_pyensight_core-0.10.4}/PKG-INFO +3 -3
  2. {ansys_pyensight_core-0.10.2 → ansys_pyensight_core-0.10.4}/pyproject.toml +3 -3
  3. {ansys_pyensight_core-0.10.2 → ansys_pyensight_core-0.10.4}/src/ansys/pyensight/core/libuserd.py +18 -7
  4. {ansys_pyensight_core-0.10.2 → ansys_pyensight_core-0.10.4}/src/ansys/pyensight/core/locallauncher.py +3 -8
  5. {ansys_pyensight_core-0.10.2 → ansys_pyensight_core-0.10.4}/src/ansys/pyensight/core/session.py +13 -5
  6. {ansys_pyensight_core-0.10.2 → ansys_pyensight_core-0.10.4}/src/ansys/pyensight/core/utils/export.py +1 -1
  7. {ansys_pyensight_core-0.10.2 → ansys_pyensight_core-0.10.4}/src/ansys/pyensight/core/utils/omniverse.py +120 -2
  8. {ansys_pyensight_core-0.10.2 → ansys_pyensight_core-0.10.4}/src/ansys/pyensight/core/utils/omniverse_dsg_server.py +5 -0
  9. {ansys_pyensight_core-0.10.2 → ansys_pyensight_core-0.10.4}/LICENSE +0 -0
  10. {ansys_pyensight_core-0.10.2 → ansys_pyensight_core-0.10.4}/README.rst +0 -0
  11. {ansys_pyensight_core-0.10.2 → ansys_pyensight_core-0.10.4}/src/ansys/pyensight/core/__init__.py +0 -0
  12. {ansys_pyensight_core-0.10.2 → ansys_pyensight_core-0.10.4}/src/ansys/pyensight/core/common.py +0 -0
  13. {ansys_pyensight_core-0.10.2 → ansys_pyensight_core-0.10.4}/src/ansys/pyensight/core/deep_pixel_view.html +0 -0
  14. {ansys_pyensight_core-0.10.2 → ansys_pyensight_core-0.10.4}/src/ansys/pyensight/core/dockerlauncher.py +0 -0
  15. {ansys_pyensight_core-0.10.2 → ansys_pyensight_core-0.10.4}/src/ansys/pyensight/core/dvs.py +0 -0
  16. {ansys_pyensight_core-0.10.2 → ansys_pyensight_core-0.10.4}/src/ansys/pyensight/core/enscontext.py +0 -0
  17. {ansys_pyensight_core-0.10.2 → ansys_pyensight_core-0.10.4}/src/ansys/pyensight/core/enshell_grpc.py +0 -0
  18. {ansys_pyensight_core-0.10.2 → ansys_pyensight_core-0.10.4}/src/ansys/pyensight/core/ensight_grpc.py +0 -0
  19. {ansys_pyensight_core-0.10.2 → ansys_pyensight_core-0.10.4}/src/ansys/pyensight/core/ensobj.py +0 -0
  20. {ansys_pyensight_core-0.10.2 → ansys_pyensight_core-0.10.4}/src/ansys/pyensight/core/launch_ensight.py +0 -0
  21. {ansys_pyensight_core-0.10.2 → ansys_pyensight_core-0.10.4}/src/ansys/pyensight/core/launcher.py +0 -0
  22. {ansys_pyensight_core-0.10.2 → ansys_pyensight_core-0.10.4}/src/ansys/pyensight/core/listobj.py +0 -0
  23. {ansys_pyensight_core-0.10.2 → ansys_pyensight_core-0.10.4}/src/ansys/pyensight/core/py.typed +0 -0
  24. {ansys_pyensight_core-0.10.2 → ansys_pyensight_core-0.10.4}/src/ansys/pyensight/core/renderable.py +0 -0
  25. {ansys_pyensight_core-0.10.2 → ansys_pyensight_core-0.10.4}/src/ansys/pyensight/core/sgeo_poll.html +0 -0
  26. {ansys_pyensight_core-0.10.2 → ansys_pyensight_core-0.10.4}/src/ansys/pyensight/core/utils/__init__.py +0 -0
  27. {ansys_pyensight_core-0.10.2 → ansys_pyensight_core-0.10.4}/src/ansys/pyensight/core/utils/adr.py +0 -0
  28. {ansys_pyensight_core-0.10.2 → ansys_pyensight_core-0.10.4}/src/ansys/pyensight/core/utils/dsg_server.py +0 -0
  29. {ansys_pyensight_core-0.10.2 → ansys_pyensight_core-0.10.4}/src/ansys/pyensight/core/utils/omniverse_cli.py +0 -0
  30. {ansys_pyensight_core-0.10.2 → ansys_pyensight_core-0.10.4}/src/ansys/pyensight/core/utils/omniverse_glb_server.py +0 -0
  31. {ansys_pyensight_core-0.10.2 → ansys_pyensight_core-0.10.4}/src/ansys/pyensight/core/utils/parts.py +0 -0
  32. {ansys_pyensight_core-0.10.2 → ansys_pyensight_core-0.10.4}/src/ansys/pyensight/core/utils/query.py +0 -0
  33. {ansys_pyensight_core-0.10.2 → ansys_pyensight_core-0.10.4}/src/ansys/pyensight/core/utils/readers.py +0 -0
  34. {ansys_pyensight_core-0.10.2 → ansys_pyensight_core-0.10.4}/src/ansys/pyensight/core/utils/resources/Materials/000_sky.exr +0 -0
  35. {ansys_pyensight_core-0.10.2 → ansys_pyensight_core-0.10.4}/src/ansys/pyensight/core/utils/support.py +0 -0
  36. {ansys_pyensight_core-0.10.2 → ansys_pyensight_core-0.10.4}/src/ansys/pyensight/core/utils/variables.py +0 -0
  37. {ansys_pyensight_core-0.10.2 → ansys_pyensight_core-0.10.4}/src/ansys/pyensight/core/utils/views.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ansys-pyensight-core
3
- Version: 0.10.2
3
+ Version: 0.10.4
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>
@@ -17,7 +17,7 @@ Classifier: Programming Language :: Python :: 3.12
17
17
  Classifier: Programming Language :: Python :: 3.13
18
18
  License-File: LICENSE
19
19
  Requires-Dist: importlib-metadata>=4.0; python_version<='3.8'
20
- Requires-Dist: ansys-api-pyensight==0.4.7
20
+ Requires-Dist: ansys-api-pyensight==0.4.8
21
21
  Requires-Dist: requests>=2.28.2
22
22
  Requires-Dist: docker>=6.1.0
23
23
  Requires-Dist: urllib3<2.4.0
@@ -25,7 +25,7 @@ Requires-Dist: numpy>=1.21.0,<3
25
25
  Requires-Dist: Pillow>=9.3.0
26
26
  Requires-Dist: pypng>=0.0.20
27
27
  Requires-Dist: psutil>=5.9.2
28
- Requires-Dist: usd-core==24.8; python_version < '3.13'
28
+ Requires-Dist: usd-core==24.8; python_version < '3.13' and platform_machine != 'aarch64'
29
29
  Requires-Dist: pygltflib>=1.16.2
30
30
  Requires-Dist: build>=0.10.0 ; extra == "dev"
31
31
  Requires-Dist: bump2version>=1.0.1 ; extra == "dev"
@@ -6,7 +6,7 @@ build-backend = "flit_core.buildapi"
6
6
 
7
7
  [project]
8
8
  name = "ansys-pyensight-core"
9
- version = "0.10.2"
9
+ version = "0.10.4"
10
10
  description = "A python wrapper for Ansys EnSight"
11
11
  readme = "README.rst"
12
12
  requires-python = ">=3.10,<3.14"
@@ -27,7 +27,7 @@ classifiers = [
27
27
 
28
28
  dependencies = [
29
29
  "importlib-metadata>=4.0; python_version<='3.8'",
30
- "ansys-api-pyensight==0.4.7",
30
+ "ansys-api-pyensight==0.4.8",
31
31
  "requests>=2.28.2",
32
32
  "docker>=6.1.0",
33
33
  "urllib3<2.4.0",
@@ -35,7 +35,7 @@ dependencies = [
35
35
  "Pillow>=9.3.0",
36
36
  "pypng>=0.0.20",
37
37
  "psutil>=5.9.2",
38
- "usd-core==24.8; python_version < '3.13'",
38
+ "usd-core==24.8; python_version < '3.13' and platform_machine != 'aarch64'",
39
39
  "pygltflib>=1.16.2"
40
40
  ]
41
41
 
@@ -1983,7 +1983,7 @@ class LibUserd(object):
1983
1983
  return output
1984
1984
 
1985
1985
  @staticmethod
1986
- def _download_files(uri: str, pathname: str, folder: bool = False):
1986
+ def _download_files(uri: str, pathname: str, folder: bool = False, override_root: bool = False):
1987
1987
  """Download files from the input uri and save them on the input pathname.
1988
1988
 
1989
1989
  Parameters:
@@ -1996,9 +1996,21 @@ class LibUserd(object):
1996
1996
  folder : bool
1997
1997
  True if the uri will server files from a directory. In this case,
1998
1998
  pathname will be used as the directory were to save the files.
1999
+ override_root: bool
2000
+ True if the root has been overridden. So don't consider the case
2001
+ of getting the download URL from the github API
1999
2002
  """
2000
2003
  if not folder:
2001
- with requests.get(uri, stream=True) as r:
2004
+ if override_root:
2005
+ correct_url = uri
2006
+ else:
2007
+ correct_url = None
2008
+ with requests.get(uri) as r:
2009
+ data = r.json()
2010
+ correct_url = data["download_url"]
2011
+ if not correct_url:
2012
+ raise RuntimeError(f"Couldn't retrieve download URL from github uri {uri}")
2013
+ with requests.get(correct_url, stream=True) as r:
2002
2014
  with open(pathname, "wb") as f:
2003
2015
  shutil.copyfileobj(r.raw, f)
2004
2016
  else:
@@ -2054,13 +2066,12 @@ class LibUserd(object):
2054
2066
  >>> cas_file = l.download_pyansys_example("mixing_elbow.cas.h5","pyfluent/mixing_elbow")
2055
2067
  >>> dat_file = l.download_pyansys_example("mixing_elbow.dat.h5","pyfluent/mixing_elbow")
2056
2068
  """
2057
- base_uri = "https://github.com/ansys/example-data/raw/master"
2058
- base_api_uri = "https://api.github.com/repos/ansys/example-data/contents"
2069
+ base_uri = "https://api.github.com/repos/ansys/example-data/contents"
2070
+ override_root = False
2059
2071
  if not folder:
2060
2072
  if root is not None:
2061
2073
  base_uri = root
2062
- else:
2063
- base_uri = base_api_uri
2074
+ override_root = True
2064
2075
  uri = f"{base_uri}/{filename}"
2065
2076
  if directory:
2066
2077
  uri = f"{base_uri}/{directory}/{filename}"
@@ -2069,7 +2080,7 @@ class LibUserd(object):
2069
2080
  if self._container and self._data_directory:
2070
2081
  # Docker Image
2071
2082
  download_path = os.path.join(self._data_directory, filename)
2072
- self._download_files(uri, download_path, folder=folder)
2083
+ self._download_files(uri, download_path, folder=folder, override_root=override_root)
2073
2084
  pathname = download_path
2074
2085
  if self._container:
2075
2086
  # Convert local path to Docker mounted volume path
@@ -110,15 +110,10 @@ class LocalLauncher(Launcher):
110
110
  path_to_webui, f"nexus{version}", f"ansys{version}", "ensight", "WebUI", "web", "ui"
111
111
  )
112
112
  # Ansys environment
113
- paths_to_webui_ansys = [
114
- os.path.join(os.path.dirname(path_to_webui), "simcfd", "web", "ui"),
115
- os.path.join(os.path.dirname(path_to_webui), "fluidsone", "web", "ui"),
116
- ]
113
+ path_to_webui_ansys = os.path.join(os.path.dirname(path_to_webui), "FluidsOne", "web", "ui")
117
114
  path_to_webui = path_to_webui_internal
118
- for path in paths_to_webui_ansys:
119
- if os.path.exists(path):
120
- path_to_webui = path
121
- break
115
+ if os.path.exists(path_to_webui_ansys):
116
+ path_to_webui = path_to_webui_ansys
122
117
  cmd += ["--server-listen-port", str(self._ports[5])]
123
118
  cmd += ["--server-web-roots", path_to_webui]
124
119
  cmd += ["--ensight-grpc-port", str(self._ports[0])]
@@ -1278,22 +1278,30 @@ class Session:
1278
1278
  >>> remote = session.show("remote")
1279
1279
  >>> remote.browser()
1280
1280
  """
1281
- base_uri = "https://github.com/ansys/example-data/raw/master"
1282
- base_api_uri = "https://api.github.com/repos/ansys/example-data/contents"
1281
+ base_uri = "https://api.github.com/repos/ansys/example-data/contents"
1282
+ override_root = False
1283
1283
  if not folder:
1284
1284
  if root is not None:
1285
1285
  base_uri = root
1286
- else:
1287
- base_uri = base_api_uri
1286
+ override_root = True
1288
1287
  uri = f"{base_uri}/{filename}"
1289
1288
  if directory:
1290
1289
  uri = f"{base_uri}/{directory}/{filename}"
1291
1290
  pathname = f"{self.launcher.session_directory}/{filename}"
1292
1291
  if not folder:
1292
+ if override_root:
1293
+ correct_url = uri
1294
+ else:
1295
+ correct_url = None
1296
+ with requests.get(uri) as r:
1297
+ data = r.json()
1298
+ correct_url = data["download_url"]
1299
+ if not correct_url:
1300
+ raise RuntimeError(f"Couldn't retrieve download URL from github uri {uri}")
1293
1301
  script = "import requests\n"
1294
1302
  script += "import shutil\n"
1295
1303
  script += "import os\n"
1296
- script += f'url = "{uri}"\n'
1304
+ script += f'url = "{correct_url}"\n'
1297
1305
  script += f'outpath = r"""{pathname}"""\n'
1298
1306
  script += "with requests.get(url, stream=True) as r:\n"
1299
1307
  script += " with open(outpath, 'wb') as f:\n"
@@ -175,7 +175,7 @@ class Export:
175
175
  """
176
176
  if array is None:
177
177
  return None
178
- return dict(shape=array.shape, dtype=array.dtype.str, data=array.tostring())
178
+ return dict(shape=array.shape, dtype=array.dtype.str, data=array.tobytes())
179
179
 
180
180
  @staticmethod
181
181
  def _numpy_from_dict(obj: Optional[dict]) -> Any:
@@ -18,6 +18,14 @@ if TYPE_CHECKING:
18
18
  from ansys.api.pyensight import ensight_api
19
19
 
20
20
 
21
+ def _handle_fluids_one(install_path):
22
+ cei_path = install_path
23
+ interpreter = os.path.join(cei_path, "bin", "cpython")
24
+ if platform.system() == "Windows":
25
+ interpreter += ".bat"
26
+ return interpreter
27
+
28
+
21
29
  class OmniverseKitInstance:
22
30
  """Interface to an Omniverse application instance
23
31
 
@@ -47,12 +55,12 @@ class OmniverseKitInstance:
47
55
  if psutil.pid_exists(child.pid):
48
56
  # This can be a race condition, so it is ok if the child is dead already
49
57
  try:
50
- child.kill()
58
+ child.terminate()
51
59
  except psutil.NoSuchProcess:
52
60
  pass
53
61
  # Same issue, this process might already be shutting down, so NoSuchProcess is ok.
54
62
  try:
55
- proc.kill()
63
+ proc.terminate()
56
64
  except psutil.NoSuchProcess:
57
65
  pass
58
66
  self._pid = None
@@ -73,6 +81,7 @@ class OmniverseKitInstance:
73
81
  return False
74
82
 
75
83
 
84
+ # Deprecated
76
85
  def find_kit_filename(fallback_directory: Optional[str] = None) -> Optional[str]:
77
86
  """
78
87
  Use a combination of the current omniverse application and the information
@@ -146,6 +155,7 @@ def find_kit_filename(fallback_directory: Optional[str] = None) -> Optional[str]
146
155
  return None
147
156
 
148
157
 
158
+ # Deprecated
149
159
  def launch_kit_instance(
150
160
  kit_path: Optional[str] = None,
151
161
  extension_paths: Optional[List[str]] = None,
@@ -210,6 +220,112 @@ def launch_kit_instance(
210
220
  return OmniverseKitInstance(p.pid)
211
221
 
212
222
 
223
+ def find_app(ansys_installation: Optional[str] = None) -> Optional[str]:
224
+ dirs_to_check = []
225
+ if ansys_installation:
226
+ # Given a different Ansys install
227
+ local_tp = os.path.join(os.path.join(ansys_installation, "tp", "omni_viewer"))
228
+ if os.path.exists(local_tp):
229
+ dirs_to_check.append(local_tp)
230
+ # Dev Folder
231
+ local_dev_omni = os.path.join(ansys_installation, "omni_build")
232
+ if os.path.exists(local_dev_omni):
233
+ dirs_to_check.append(local_dev_omni)
234
+ if "PYENSIGHT_ANSYS_INSTALLATION" in os.environ:
235
+ env_inst = os.environ["PYENSIGHT_ANSYS_INSTALLATION"]
236
+ dirs_to_check.append(os.path.join(env_inst, "tp", "omni_viewer"))
237
+
238
+ # Look for most recent Ansys install, 25.2 or later
239
+ awp_roots = []
240
+ for env_name in dict(os.environ).keys():
241
+ if env_name.startswith("AWP_ROOT") and int(env_name[len("AWP_ROOT") :]) >= 252:
242
+ awp_roots.append(env_name)
243
+ awp_roots.sort(reverse=True)
244
+ for env_name in awp_roots:
245
+ dirs_to_check.append(os.path.join(os.environ[env_name], "tp", "omni_viewer"))
246
+
247
+ # check all the collected locations in order
248
+ for install_dir in dirs_to_check:
249
+ launch_file = os.path.join(install_dir, "ansys_tools_omni_core.py")
250
+ if os.path.isfile(launch_file):
251
+ return launch_file
252
+ return None
253
+
254
+
255
+ def launch_app(
256
+ usd_file: Optional[str] = "",
257
+ layout: Optional[str] = "default",
258
+ streaming: Optional[bool] = False,
259
+ offscreen: Optional[bool] = False,
260
+ log_file: Optional[str] = None,
261
+ log_level: Optional[str] = "warn",
262
+ cli_options: Optional[List[str]] = None,
263
+ ansys_installation: Optional[str] = None,
264
+ interpreter: Optional[str] = None,
265
+ ) -> "OmniverseKitInstance":
266
+ """Launch the Ansys Omniverse application
267
+
268
+ Parameters
269
+ ----------
270
+ # usd_file : Optional[str]
271
+ # A .usd file to open on startup
272
+ # layout : Optional[str]
273
+ # A UI layout. viewer, composer, or composer_slim
274
+ # streaming : Optional[bool]
275
+ # Enable webrtc streaming to enable the window in a web page
276
+ # offscreen : Optional[str]
277
+ # Run the app offscreen. Useful when streaming.
278
+ # log_file : Optional[str]
279
+ # The name of a text file where the logging information for the instance will be saved.
280
+ # log_level : Optional[str]
281
+ # The level of the logging information to record: "verbose", "info", "warn", "error", "fatal",
282
+ # the default is "warn".
283
+ # cli_options : Optional[List[str]]
284
+ # Other command line options
285
+
286
+ Returns
287
+ -------
288
+ OmniverseKitInstance
289
+ The object interface for the launched instance
290
+
291
+ Examples
292
+ --------
293
+ Run the app with default options
294
+
295
+ >>> from ansys.pyensight.core.utils import omniverse
296
+ >>> ov = omniverse.launch_app()
297
+
298
+ """
299
+ cmd = [sys.executable]
300
+ if interpreter:
301
+ cmd = [interpreter]
302
+ app = find_app(ansys_installation=ansys_installation)
303
+ if not app:
304
+ raise RuntimeError("Unable to find the Ansys Omniverse app")
305
+ cmd.extend([app])
306
+ if usd_file:
307
+ cmd.extend(["-f", usd_file])
308
+ if layout:
309
+ cmd.extend(["-l", layout])
310
+ if streaming:
311
+ cmd.extend(["-s"])
312
+ if offscreen:
313
+ cmd.extend(["-o"])
314
+ if cli_options:
315
+ cmd.extend(cli_options)
316
+ if log_level:
317
+ if log_level not in ("verbose", "info", "warn", "error", "fatal"):
318
+ raise RuntimeError(f"Invalid logging level: {log_level}")
319
+ cmd.extend([f"--/log/level={log_level}"])
320
+ if log_file:
321
+ cmd.extend(["--/log/enabled=true", f"--/log/file={log_file}"])
322
+
323
+ # Launch the process
324
+ env_vars = os.environ.copy()
325
+ p = subprocess.Popen(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, env=env_vars)
326
+ return OmniverseKitInstance(p.pid)
327
+
328
+
213
329
  class Omniverse:
214
330
  """Provides the ``ensight.utils.omniverse`` interface.
215
331
 
@@ -284,6 +400,8 @@ class Omniverse:
284
400
  pass
285
401
  # Using the python interpreter running this code
286
402
  self._interpreter = sys.executable
403
+ if "fluids_one" in self._interpreter: # compiled simba-app
404
+ self._interpreter = _handle_fluids_one(self._ensight._session._install_path)
287
405
  if is_omni:
288
406
  kit_path = os.path.dirname(sys.executable)
289
407
  self._interpreter = os.path.join(kit_path, "python")
@@ -26,6 +26,7 @@
26
26
  import logging
27
27
  import math
28
28
  import os
29
+ import platform
29
30
  import shutil
30
31
  import sys
31
32
  import tempfile
@@ -42,6 +43,10 @@ except ModuleNotFoundError:
42
43
  if sys.version_info.minor >= 13:
43
44
  warnings.warn("USD Export not supported for Python >= 3.13")
44
45
  sys.exit(1)
46
+ is_linux_arm64 = platform.system() == "Linux" and platform.machine() == "aarch64"
47
+ if is_linux_arm64:
48
+ warnings.warn("USD Export not supported on Linux ARM platforms")
49
+ sys.exit(1)
45
50
 
46
51
 
47
52
  class OmniverseWrapper(object):