Skip to content

Commit

Permalink
Disabling session ID check by default (#2778)
Browse files Browse the repository at this point in the history
* Disabling session id check

* Moving some checks after the non interactive so we make sure we do not perform those checks

* fixing test
  • Loading branch information
germa89 authored Feb 19, 2024
1 parent 4e773b9 commit 1b078da
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
28 changes: 15 additions & 13 deletions src/ansys/mapdl/core/mapdl_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2106,19 +2106,6 @@ def run(
>>> mapdl.prep7()
"""
if self._session_id is not None:
self._check_session_id()
else:
# For some reason the session hasn't been created
if self.is_grpc:
self._create_session()

if mute is None:
if hasattr(self, "mute"):
mute = self.mute
else: # if not gRPC
mute = False

# check if multiline
if "\n" in command or "\r" in command:
raise ValueError("Use ``input_strings`` for multi-line commands")
Expand Down Expand Up @@ -2146,11 +2133,26 @@ def run(
UserWarning,
)

# Early exit if on non-interactive.
if self._store_commands and not avoid_non_interactive:
# If you are using NBLOCK on input, you should not strip the string
self._stored_commands.append(command)
return

# Actually sending the message
if self._session_id is not None:
self._check_session_id()
else:
# For some reason the session hasn't been created
if self.is_grpc:
self._create_session()

if mute is None:
if hasattr(self, "mute"):
mute = self.mute
else: # if not gRPC
mute = False

command = command.strip()

# always reset the cache
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/mapdl/core/mapdl_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3293,7 +3293,7 @@ def _session_id(self):

def _check_session_id(self):
"""Verify that the local session ID matches the remote MAPDL session ID."""
if self._checking_session_id_:
if self._checking_session_id_ or not self._strict_session_id_check:
# To avoid recursion error
return

Expand Down
2 changes: 2 additions & 0 deletions tests/test_mapdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1882,6 +1882,7 @@ def test_force_output(mapdl):


def test_session_id(mapdl, running_test):
mapdl._strict_session_id_check = True
assert mapdl._session_id is not None

# already checking version
Expand All @@ -1908,6 +1909,7 @@ def test_session_id(mapdl, running_test):
assert not mapdl._check_session_id()

mapdl._session_id_ = id_
mapdl._strict_session_id_check = False


def test_check_empty_session_id(mapdl):
Expand Down

0 comments on commit 1b078da

Please sign in to comment.