From e79cf75c6a364464a34e9b854e293299b437b640 Mon Sep 17 00:00:00 2001 From: Mario Ostieri Date: Mon, 21 Aug 2023 15:00:14 +0100 Subject: [PATCH 1/2] add option to start the gRPC connections without secret keys and add the option to monitor new timesteps --- src/ansys/pyensight/core/locallauncher.py | 3 ++- src/ansys/pyensight/core/session.py | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ansys/pyensight/core/locallauncher.py b/src/ansys/pyensight/core/locallauncher.py index 8fc056de206..64b58242107 100644 --- a/src/ansys/pyensight/core/locallauncher.py +++ b/src/ansys/pyensight/core/locallauncher.py @@ -131,7 +131,8 @@ def start(self) -> "pyensight.Session": # Launch EnSight # create the environmental variables local_env = os.environ.copy() - local_env["ENSIGHT_SECURITY_TOKEN"] = self._secret_key + if not local_env.get("ENSIGHT_GRPC_DISABLE_SECURITY_TOKEN"): + local_env["ENSIGHT_SECURITY_TOKEN"] = self._secret_key local_env["WEBSOCKETSERVER_SECURITY_TOKEN"] = self._secret_key local_env["ENSIGHT_SESSION_TEMPDIR"] = self.session_directory # If for some reason, the ENSIGHT_ANSYS_LAUNCH is set previously, diff --git a/src/ansys/pyensight/core/session.py b/src/ansys/pyensight/core/session.py index 79a090f7895..9d40c1253b9 100644 --- a/src/ansys/pyensight/core/session.py +++ b/src/ansys/pyensight/core/session.py @@ -964,6 +964,10 @@ def _build_utils_interface(self) -> None: # Warn on import errors print(f"Error loading ensight.utils from: '{_filename}' : {e}") + MONITOR_NEW_TIMESTEPS_OFF = "off" + MONITOR_NEW_TIMESTEPS_STAY_AT_CURRENT = "stay_at_current" + MONITOR_NEW_TIMESTEPS_JUMP_TO_END = "jump_to_end" + def load_data( self, data_file: str, @@ -972,6 +976,7 @@ def load_data( reader_options: Optional[dict] = None, new_case: bool = False, representation: str = "3D_feature_2D_full", + monitor_new_timesteps: str = MONITOR_NEW_TIMESTEPS_OFF, ) -> None: """Load a dataset into the EnSight instance. @@ -1076,7 +1081,7 @@ def load_data( if result_file: cmds.append(f'ensight.data.result(r"""{result_file}""")') cmds.append("ensight.data.shift_time(1.000000, 0.000000, 0.000000)") - cmds.append('ensight.solution_time.monitor_for_new_steps("off")') + cmds.append(f'ensight.solution_time.monitor_for_new_steps("{monitor_new_timesteps}")') cmds.append(f'ensight.data.replace(r"""{data_file}""")') for cmd in cmds: if self.cmd(cmd) != 0: From 84b460285d5059715045215469364f011d1c7628 Mon Sep 17 00:00:00 2001 From: Mario Ostieri Date: Mon, 21 Aug 2023 15:57:24 +0100 Subject: [PATCH 2/2] document new option for load_data --- src/ansys/pyensight/core/session.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ansys/pyensight/core/session.py b/src/ansys/pyensight/core/session.py index 9d40c1253b9..53f45ffb3f0 100644 --- a/src/ansys/pyensight/core/session.py +++ b/src/ansys/pyensight/core/session.py @@ -1002,6 +1002,10 @@ def load_data( representation : str, optional Default representation for the parts loaded. The default is ``"3D_feature_2D_full"``. + monitor_new_timesteps: str, optional + Defaulted to off, if changed EnSight will monitor for new timesteps. + The allowed values are MONITOR_NEW_TIMESTEPS_OFF, MONITOR_NEW_TIMESTEPS_STAY_AT_CURRENT + and MONITOR_NEW_TIMESTEPS_JUMP_TO_END Raises ------