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

@@ -10,12 +10,15 @@ import platform
10
10
  import sys
11
11
  import tempfile
12
12
  import threading
13
- from typing import Any, Callable, List, Optional, Tuple, Union
13
+ from typing import TYPE_CHECKING, Any, Callable, List, Optional, Tuple, Union
14
14
  import uuid
15
15
 
16
16
  from ansys.api.pyensight.v0 import dynamic_scene_graph_pb2_grpc, ensight_pb2, ensight_pb2_grpc
17
17
  import grpc
18
18
 
19
+ if TYPE_CHECKING:
20
+ from ansys.pyensight.core.utils.dsg_server import DSGSession
21
+
19
22
 
20
23
  class EnSightGRPC(object):
21
24
  """Wrapper around a gRPC connection to an EnSight instance
@@ -60,6 +63,10 @@ class EnSightGRPC(object):
60
63
  self._image = None
61
64
  self._image_number = 0
62
65
  self._sub_service = None
66
+ self._dsg_session: Optional["DSGSession"] = None
67
+
68
+ def set_dsg_session(self, dsg_session: "DSGSession"):
69
+ self._dsg_session = dsg_session
63
70
 
64
71
  @property
65
72
  def host(self) -> str:
@@ -45,6 +45,7 @@ if TYPE_CHECKING:
45
45
  from ansys.api.pyensight import ensight_api
46
46
  from ansys.pyensight.core import enscontext, ensight_grpc, renderable
47
47
  from ansys.pyensight.core.ensobj import ENSOBJ
48
+ from ansys.pyensight.core.utils.dsg_server import DSGSession
48
49
 
49
50
 
50
51
  class InvalidEnSightVersion(Exception):
@@ -140,6 +141,7 @@ class Session:
140
141
  webui_port: Optional[int] = None,
141
142
  ) -> None:
142
143
  # every session instance needs a unique name that can be used as a cache key
144
+ self._dsg_session: Optional["DSGSession"] = None
143
145
  self._session_name = str(uuid.uuid1())
144
146
  # when objects come into play, we can reuse them, so hash ID to instance here
145
147
  self._ensobj_hash: Dict[int, "ENSOBJ"] = {}
@@ -962,8 +964,12 @@ class Session:
962
964
  >>> print(session.cmd("10+4"))
963
965
  14
964
966
  """
967
+ if self._dsg_session:
968
+ self._dsg_session._pyensight_grpc_coming = True
965
969
  self._establish_connection()
966
970
  ret = self._grpc.command(value, do_eval=do_eval)
971
+ if self._dsg_session:
972
+ self._dsg_session._pyensight_grpc_coming = False
967
973
  if do_eval:
968
974
  ret = self._convert_ctor(ret)
969
975
  value = eval(ret, dict(session=self, ensobjlist=ensobjlist))
@@ -1820,3 +1826,17 @@ class Session:
1820
1826
  cmd += f"ports = find_unused_ports({count}, start={start}, end={end}, avoid={avoid})"
1821
1827
  self.cmd(cmd, do_eval=False)
1822
1828
  return self.cmd("ports")
1829
+
1830
+ def set_dsg_session(self, dsg_session: "DSGSession"):
1831
+ """Set a DSG Session for the current PyEnSight session.
1832
+
1833
+ This is required if a DSGSession is running together with
1834
+ PyEnSight and the second might send gRPC requests while the first
1835
+ is blocked because the gRPC queue is full.
1836
+
1837
+ Parameters
1838
+ ----------
1839
+ dsg_session: DSGSession
1840
+ a DSGSession object
1841
+ """
1842
+ self._dsg_session = dsg_session
@@ -6,12 +6,15 @@ import queue
6
6
  import sys
7
7
  import threading
8
8
  import time
9
- from typing import Any, Dict, List, Optional
9
+ from typing import TYPE_CHECKING, Any, Dict, List, Optional
10
10
 
11
11
  from ansys.api.pyensight.v0 import dynamic_scene_graph_pb2
12
12
  from ansys.pyensight.core import ensight_grpc
13
13
  import numpy
14
14
 
15
+ if TYPE_CHECKING:
16
+ from ansys.pyensight.core import Session
17
+
15
18
 
16
19
  class Part(object):
17
20
  def __init__(self, session: "DSGSession"):
@@ -640,6 +643,7 @@ class DSGSession(object):
640
643
  vrmode: bool = False,
641
644
  time_scale: float = 1.0,
642
645
  handler: UpdateHandler = UpdateHandler(),
646
+ session: Optional["Session"] = None,
643
647
  ):
644
648
  """
645
649
  Manage a gRPC connection and link it to an UpdateHandler instance
@@ -678,6 +682,9 @@ class DSGSession(object):
678
682
  """
679
683
  super().__init__()
680
684
  self._grpc = ensight_grpc.EnSightGRPC(port=port, host=host, secret_key=security_code)
685
+ self._session = session
686
+ if self._session:
687
+ self._session.set_dsg_session(self)
681
688
  self._callback_handler = handler
682
689
  self._verbose = verbose
683
690
  self._thread: Optional[threading.Thread] = None
@@ -705,6 +712,7 @@ class DSGSession(object):
705
712
  # log any status changes to this file. external apps will be monitoring
706
713
  self._status_file = os.environ.get("ANSYS_OV_SERVER_STATUS_FILENAME", "")
707
714
  self._status = dict(status="idle", start_time=0.0, processed_buffers=0, total_buffers=0)
715
+ self._pyensight_grpc_coming = False
708
716
 
709
717
  @property
710
718
  def scene_bounds(self) -> Optional[List]:
@@ -892,6 +900,13 @@ class DSGSession(object):
892
900
  cmd.init.maximum_chunk_size = 1024 * 1024
893
901
  self._dsg_queue.put(cmd) # type:ignore
894
902
 
903
+ def _is_queue_full(self):
904
+ if not self.max_dsg_queue_size:
905
+ return False
906
+ if self._pyensight_grpc_coming:
907
+ return False
908
+ return self._message_queue.qsize() >= self.max_dsg_queue_size
909
+
895
910
  def _poll_messages(self) -> None:
896
911
  """Core interface to grab DSG events from gRPC and queue them for processing
897
912
 
@@ -905,7 +920,7 @@ class DSGSession(object):
905
920
  # if the queue is getting too deep, wait a bit to avoid holding too
906
921
  # many messages (filling up memory)
907
922
  if self.max_dsg_queue_size:
908
- while self._message_queue.qsize() >= self.max_dsg_queue_size:
923
+ while self._is_queue_full():
909
924
  time.sleep(0.001)
910
925
  except Exception:
911
926
  self._shutdown = True
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: ansys-pyensight-core
3
- Version: 0.9.3
3
+ Version: 0.9.5
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>
@@ -26,7 +26,7 @@ Requires-Dist: pypng>=0.0.20
26
26
  Requires-Dist: psutil>=5.9.2
27
27
  Requires-Dist: usd-core>=24.8
28
28
  Requires-Dist: pygltflib>=1.16.2
29
- Requires-Dist: grpcio==1.67.0
29
+ Requires-Dist: grpcio>=1.51.1,<1.67.1
30
30
  Requires-Dist: build>=0.10.0 ; extra == "dev"
31
31
  Requires-Dist: bump2version>=1.0.1 ; extra == "dev"
32
32
  Requires-Dist: ipdb>=0.9.4 ; extra == "dev"
@@ -5,7 +5,7 @@ ansys/pyensight/core/dockerlauncher.py,sha256=Fgl9FhCNHEAvRthXed5Mo0iXjh_gj3TRxn
5
5
  ansys/pyensight/core/dvs.py,sha256=iPVs4ugVSlxVvhhh8Dx6mxjNHZLdivlCU7TlX_WpmLc,31545
6
6
  ansys/pyensight/core/enscontext.py,sha256=GSKkjZt1QEPyHEQ59EEBgKGMik9vjCdR9coR4uX7fEw,12141
7
7
  ansys/pyensight/core/enshell_grpc.py,sha256=-OxSdFI_p3DmQnqh1jT_a_aSh_w-EUD2IaWGKxrnyjI,17122
8
- ansys/pyensight/core/ensight_grpc.py,sha256=IkntqzHmNzhADZ1VZJtWGpaB3ZlSThcovsbXyliW_Sk,29458
8
+ ansys/pyensight/core/ensight_grpc.py,sha256=IitEgMzBJTyTgQff0sXPvGkVnC2E9qRKw-HXCF-mVvA,29713
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=ymwfixwoHO7_c4qOetqccQbZjGT1HjeA7jwPi2JxlmE,10585
@@ -14,11 +14,11 @@ ansys/pyensight/core/listobj.py,sha256=Trw87IxIMXtmUd1DzywRmMzORU704AG4scX4fqYmO
14
14
  ansys/pyensight/core/locallauncher.py,sha256=ot05X0vj-xDqNSx-2A_RDBBuN9Fyk2dONjkkD9gtVyM,16264
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=gNWuihZEjmPcnEE5t7CXdK53e2Ah8MgdI5Tb3yE6CpQ,72876
17
+ ansys/pyensight/core/session.py,sha256=AGLLWfiqlQJnLvu_CqXZM4Fyno1AxBl_f5g3HHw8hlM,73649
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
- ansys/pyensight/core/utils/dsg_server.py,sha256=FfiTJ7XsTW3OhI2w7PKMX5SLVoznGgZ6In-Q_wpkggE,45017
21
+ ansys/pyensight/core/utils/dsg_server.py,sha256=olSRP_M3PWVPxnJbSGAcDk5zu9KrcmYekjJ2y6gEXnE,45489
22
22
  ansys/pyensight/core/utils/export.py,sha256=UAJQcrElo3esQD0CWdxxjMQ8yE1vB4cdAhF33_uZfQw,22605
23
23
  ansys/pyensight/core/utils/omniverse.py,sha256=irghU1wcIvo_lHhZV2VxYKCSQkNWCF8njJjWfExiFgI,18455
24
24
  ansys/pyensight/core/utils/omniverse_cli.py,sha256=aVYu4HsSZBl7A9_xU3DfItNB-hpxCdMPXm_oMAOU_HQ,20261
@@ -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.9.3.dist-info/LICENSE,sha256=qQWivZ12ETN5l3QxvTARY-QI5eoRRlyHdwLlAj0Bg5I,1089
35
- ansys_pyensight_core-0.9.3.dist-info/WHEEL,sha256=CpUCUxeHQbRN5UGRQHYRJorO5Af-Qy_fHMctcQ8DSGI,82
36
- ansys_pyensight_core-0.9.3.dist-info/METADATA,sha256=gg7LkGtkjcypPJ7sl-xNCT-lh-k0V8tWZzC9yLKIhoI,12143
37
- ansys_pyensight_core-0.9.3.dist-info/RECORD,,
34
+ ansys_pyensight_core-0.9.5.dist-info/LICENSE,sha256=qQWivZ12ETN5l3QxvTARY-QI5eoRRlyHdwLlAj0Bg5I,1089
35
+ ansys_pyensight_core-0.9.5.dist-info/WHEEL,sha256=CpUCUxeHQbRN5UGRQHYRJorO5Af-Qy_fHMctcQ8DSGI,82
36
+ ansys_pyensight_core-0.9.5.dist-info/METADATA,sha256=AVTrmAfDheh-3ahRh3QLY-VDcjHEDF7dVXjTtJcVdNY,12151
37
+ ansys_pyensight_core-0.9.5.dist-info/RECORD,,