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

@@ -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
@@ -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"
@@ -47,12 +47,12 @@ class OmniverseKitInstance:
47
47
  if psutil.pid_exists(child.pid):
48
48
  # This can be a race condition, so it is ok if the child is dead already
49
49
  try:
50
- child.kill()
50
+ child.terminate()
51
51
  except psutil.NoSuchProcess:
52
52
  pass
53
53
  # Same issue, this process might already be shutting down, so NoSuchProcess is ok.
54
54
  try:
55
- proc.kill()
55
+ proc.terminate()
56
56
  except psutil.NoSuchProcess:
57
57
  pass
58
58
  self._pid = None
@@ -73,6 +73,7 @@ class OmniverseKitInstance:
73
73
  return False
74
74
 
75
75
 
76
+ # Deprecated
76
77
  def find_kit_filename(fallback_directory: Optional[str] = None) -> Optional[str]:
77
78
  """
78
79
  Use a combination of the current omniverse application and the information
@@ -146,6 +147,7 @@ def find_kit_filename(fallback_directory: Optional[str] = None) -> Optional[str]
146
147
  return None
147
148
 
148
149
 
150
+ # Deprecated
149
151
  def launch_kit_instance(
150
152
  kit_path: Optional[str] = None,
151
153
  extension_paths: Optional[List[str]] = None,
@@ -210,6 +212,99 @@ def launch_kit_instance(
210
212
  return OmniverseKitInstance(p.pid)
211
213
 
212
214
 
215
+ def find_app() -> Optional[str]:
216
+ dirs_to_check = []
217
+ if "PYENSIGHT_ANSYS_INSTALLATION" in os.environ:
218
+ env_inst = os.environ["PYENSIGHT_ANSYS_INSTALLATION"]
219
+ dirs_to_check.append(os.path.join(env_inst, "tp", "omni_viewer"))
220
+
221
+ # Look for most recent Ansys install, 25.2 or later
222
+ awp_roots = []
223
+ for env_name in dict(os.environ).keys():
224
+ if env_name.startswith("AWP_ROOT") and int(env_name[len("AWP_ROOT") :]) >= 252:
225
+ awp_roots.append(env_name)
226
+ awp_roots.sort(reverse=True)
227
+ for env_name in awp_roots:
228
+ dirs_to_check.append(os.path.join(os.environ[env_name], "tp", "omni_viewer"))
229
+
230
+ # check all the collected locations in order
231
+ for install_dir in dirs_to_check:
232
+ launch_file = os.path.join(install_dir, "ansys_tools_omni_core.py")
233
+ if os.path.isfile(launch_file):
234
+ return launch_file
235
+ return None
236
+
237
+
238
+ def launch_app(
239
+ usd_file: Optional[str] = "",
240
+ layout: Optional[str] = "default",
241
+ streaming: Optional[bool] = False,
242
+ offscreen: Optional[bool] = False,
243
+ log_file: Optional[str] = None,
244
+ log_level: Optional[str] = "warn",
245
+ cli_options: Optional[List[str]] = None,
246
+ ) -> "OmniverseKitInstance":
247
+ """Launch the Ansys Omniverse application
248
+
249
+ Parameters
250
+ ----------
251
+ # usd_file : Optional[str]
252
+ # A .usd file to open on startup
253
+ # layout : Optional[str]
254
+ # A UI layout. viewer, composer, or composer_slim
255
+ # streaming : Optional[bool]
256
+ # Enable webrtc streaming to enable the window in a web page
257
+ # offscreen : Optional[str]
258
+ # Run the app offscreen. Useful when streaming.
259
+ # log_file : Optional[str]
260
+ # The name of a text file where the logging information for the instance will be saved.
261
+ # log_level : Optional[str]
262
+ # The level of the logging information to record: "verbose", "info", "warn", "error", "fatal",
263
+ # the default is "warn".
264
+ # cli_options : Optional[List[str]]
265
+ # Other command line options
266
+
267
+ Returns
268
+ -------
269
+ OmniverseKitInstance
270
+ The object interface for the launched instance
271
+
272
+ Examples
273
+ --------
274
+ Run the app with default options
275
+
276
+ >>> from ansys.pyensight.core.utils import omniverse
277
+ >>> ov = omniverse.launch_app()
278
+
279
+ """
280
+ cmd = [sys.executable]
281
+ app = find_app()
282
+ if not app:
283
+ raise RuntimeError("Unable to find the Ansys Omniverse app")
284
+ cmd.extend([app])
285
+ if usd_file:
286
+ cmd.extend(["-f", usd_file])
287
+ if layout:
288
+ cmd.extend(["-l", layout])
289
+ if streaming:
290
+ cmd.extend(["-s"])
291
+ if offscreen:
292
+ cmd.extend(["-o"])
293
+ if cli_options:
294
+ cmd.extend(cli_options)
295
+ if log_level:
296
+ if log_level not in ("verbose", "info", "warn", "error", "fatal"):
297
+ raise RuntimeError(f"Invalid logging level: {log_level}")
298
+ cmd.extend([f"--/log/level={log_level}"])
299
+ if log_file:
300
+ cmd.extend(["--/log/enabled=true", f"--/log/file={log_file}"])
301
+
302
+ # Launch the process
303
+ env_vars = os.environ.copy()
304
+ p = subprocess.Popen(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, env=env_vars)
305
+ return OmniverseKitInstance(p.pid)
306
+
307
+
213
308
  class Omniverse:
214
309
  """Provides the ``ensight.utils.omniverse`` interface.
215
310
 
@@ -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):
@@ -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.3
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>
@@ -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"
@@ -9,20 +9,20 @@ ansys/pyensight/core/ensight_grpc.py,sha256=IitEgMzBJTyTgQff0sXPvGkVnC2E9qRKw-HX
9
9
  ansys/pyensight/core/ensobj.py,sha256=uDtM2KHcAwd4hu5pcUYWbSD729ApHGIvuqZhEq8PxTI,18558
10
10
  ansys/pyensight/core/launch_ensight.py,sha256=iZJM6GdpzGRDLzrv1V2QZ5veIOpNSB5xPpJUFY7rBuo,10254
11
11
  ansys/pyensight/core/launcher.py,sha256=x6L1E6OGpqL2jrDdIGI0p4BxQZhHt93yl1Pwj_2lAiQ,13143
12
- ansys/pyensight/core/libuserd.py,sha256=YKXY1aaaTBT2uwcyhPEW-f93KLtCYQNMJXTlBsenWDI,75459
12
+ ansys/pyensight/core/libuserd.py,sha256=er49fOZJ050OU122cYQgtdDSFr2YNNvKoqFk7Ogjiro,76018
13
13
  ansys/pyensight/core/listobj.py,sha256=Trw87IxIMXtmUd1DzywRmMzORU704AG4scX4fqYmO6M,9340
14
14
  ansys/pyensight/core/locallauncher.py,sha256=1zrBK2NTdodMaKYI2588a8HR7_SqMVmoUW7ItqwxMEI,17039
15
15
  ansys/pyensight/core/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  ansys/pyensight/core/renderable.py,sha256=KidVTVCZ4hKYq54pP9KoJ8OCxeWBXNUJYyKSwMZ2Sls,36362
17
- ansys/pyensight/core/session.py,sha256=6UEMn6X_08JzaAhmpIi4TQfv8zdONDG1cH8UaO7MQR8,74114
17
+ ansys/pyensight/core/session.py,sha256=nNYKzbmVRELUHtj0XRU80JNiAVcuXsOeXXh3CbJLsLA,74450
18
18
  ansys/pyensight/core/sgeo_poll.html,sha256=1M4BIc5CZpYA3b40qzk22NcPCLhjFnWdoS2PrS6Rhn4,752
19
19
  ansys/pyensight/core/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
20
  ansys/pyensight/core/utils/adr.py,sha256=XslZhlwcrSGzOlnhzprOv3ju_ppxxsWBjCnQL5KiNms,3570
21
21
  ansys/pyensight/core/utils/dsg_server.py,sha256=2jCPhOplPrlDaQNSKSk9qo7bEgfcrhx0rHS_cqW2zAY,47003
22
22
  ansys/pyensight/core/utils/export.py,sha256=UAJQcrElo3esQD0CWdxxjMQ8yE1vB4cdAhF33_uZfQw,22605
23
- ansys/pyensight/core/utils/omniverse.py,sha256=qeIA9WgHHsf-fylT5I3z7rBUZUlSEOR-fLTvqgCPqbQ,18996
23
+ ansys/pyensight/core/utils/omniverse.py,sha256=j8yB5776Nd42skVZSARRx-zJxODUODhdYgg8OryADlc,22208
24
24
  ansys/pyensight/core/utils/omniverse_cli.py,sha256=ujoBbBGMYsYUn83nrk2dFkOd7kn7-6cs7ljBmmSXodw,20578
25
- ansys/pyensight/core/utils/omniverse_dsg_server.py,sha256=-62_pDAJ0UlFnjf91Ra4W63musyJxdBON1L66bve7ns,40186
25
+ ansys/pyensight/core/utils/omniverse_dsg_server.py,sha256=pyZTZ63xMUmjR5PQNp5M-ab0iofLveCo3WR3f7Ibgus,40404
26
26
  ansys/pyensight/core/utils/omniverse_glb_server.py,sha256=dx2cfR036d3DY6meooNfLZOQpOMaiaLKqBjztpew2_Q,32167
27
27
  ansys/pyensight/core/utils/parts.py,sha256=222XFRCjLgH7hho-cK9JrGCg3-KlTf54KIgc7y50sTE,52173
28
28
  ansys/pyensight/core/utils/query.py,sha256=OXKDbf1sOTX0sUvtKcp64LhVl-BcrEsE43w8uMxLOYI,19828
@@ -31,7 +31,7 @@ ansys/pyensight/core/utils/support.py,sha256=QI3z9ex7zJxjFbkCPba9DWqWgPFIThORqr0
31
31
  ansys/pyensight/core/utils/variables.py,sha256=ZUiJdDIeRcowrnLXaJQqGwA0RbrfXhc1s4o4v9A4PiY,95133
32
32
  ansys/pyensight/core/utils/views.py,sha256=ZKhJ6vMT7Rdd4bwJ0egMYTV7-D7Q7I19fF2_j_CMQ0o,12489
33
33
  ansys/pyensight/core/utils/resources/Materials/000_sky.exr,sha256=xAR1gFd2uxPZDnvgfegdhEhRaqKtZldQDiR_-1rHKO0,8819933
34
- ansys_pyensight_core-0.10.2.dist-info/licenses/LICENSE,sha256=K6LiJHOa9IbWFelXmXNRzFr3zG45SOGZIN7vdLdURGU,1097
35
- ansys_pyensight_core-0.10.2.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
36
- ansys_pyensight_core-0.10.2.dist-info/METADATA,sha256=rkwABz7C5a1cXJQolvlyIOMAyHD96ZWk8pbbWUDJ62c,12169
37
- ansys_pyensight_core-0.10.2.dist-info/RECORD,,
34
+ ansys_pyensight_core-0.10.3.dist-info/licenses/LICENSE,sha256=K6LiJHOa9IbWFelXmXNRzFr3zG45SOGZIN7vdLdURGU,1097
35
+ ansys_pyensight_core-0.10.3.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
36
+ ansys_pyensight_core-0.10.3.dist-info/METADATA,sha256=mN7adXDQiyjNjDdBdybX_yZDHlUDkP0iewgw3ucHmWY,12203
37
+ ansys_pyensight_core-0.10.3.dist-info/RECORD,,