Skip to content

Commit

Permalink
Merge branch 'main' into ci/add-timeout-to-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
germa89 authored Dec 10, 2024
2 parents b1732b2 + 27c6ec9 commit 8426a7f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions doc/changelog.d/3608.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fix: avoid verbose grpc interface when solving
8 changes: 8 additions & 0 deletions src/ansys/mapdl/core/mapdl_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,9 @@ def _set_no_abort(self):
def _run_at_connect(self):
"""Run house-keeping commands when initially connecting to MAPDL."""
# increase the number of variables allowed in POST26 to the maximum
with self.run_as_routine("Begin level"):
self._run("/verify", mute=False)

with self.run_as_routine("POST26"):
self.numvar(200, mute=True)

Expand Down Expand Up @@ -1623,6 +1626,11 @@ def _ctrl(self, cmd: str, opt1: str = ""):
return

resp = self._stub.Ctrl(request)

if cmd.lower() == "set_verb" and str(opt1) == "0":
warn("Disabling gRPC verbose ('_ctr') by issuing also '/VERIFY' command.")
self.run("/verify")

if hasattr(resp, "response"):
return resp.response

Expand Down
2 changes: 2 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,8 @@ def run_before_and_after_tests(

yield # this is where the testing happens

mapdl.prep7()

# Check resetting state
assert prev == mapdl.is_local
assert not mapdl.exited, "MAPDL is exited after the test. It should have not!"
Expand Down
11 changes: 9 additions & 2 deletions tests/test_mapdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -2429,8 +2429,15 @@ def test_not_correct_et_element(mapdl, cleared):


def test_ctrl(mapdl, cleared):
mapdl._ctrl("set_verb", 5) # Setting verbosity on the server
mapdl._ctrl("set_verb", 0) # Returning to non-verbose
with patch("ansys.mapdl.core.mapdl_grpc.MapdlGrpc.run") as mck_run:

mapdl._ctrl("set_verb", 5) # Setting verbosity on the server
mapdl._ctrl("set_verb", 0) # Returning to non-verbose

assert "/verify" in mck_run.call_args_list[0].args[0]

mapdl.finish()
mapdl.run("/verify") # mocking might skip running this inside mapdl._ctrl


def test_cleanup_loggers(mapdl, cleared):
Expand Down

0 comments on commit 8426a7f

Please sign in to comment.