Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disabling session ID check by default #2778

Merged
merged 3 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1907,6 +1907,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 @@ -1933,6 +1934,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
Loading