From 0ad85129da7db85983a3fd8d1ed0de2f068af94e Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 25 Oct 2024 09:28:58 +0000 Subject: [PATCH 01/17] feat: simplifying directory property --- src/ansys/mapdl/core/mapdl_core.py | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/src/ansys/mapdl/core/mapdl_core.py b/src/ansys/mapdl/core/mapdl_core.py index c380cda782..62b7154fd6 100644 --- a/src/ansys/mapdl/core/mapdl_core.py +++ b/src/ansys/mapdl/core/mapdl_core.py @@ -281,7 +281,6 @@ def __init__( self._krylov = None self._on_docker = None self._platform = None - self._path_cache = None # Cache self._print_com: bool = print_com # print the command /COM input. # Start_parameters @@ -499,17 +498,11 @@ def directory(self) -> str: a warning. """ # always attempt to cache the path - i = 0 - while (not self._path and i > 5) or i == 0: - try: - self._path = self.inquire("", "DIRECTORY") - except Exception as e: # pragma: no cover - logger.warning( - f"Failed to get the directory due to the following error: {e}" - ) - i += 1 - if not self._path: # pragma: no cover - time.sleep(0.1) + + try: + self._path = self.inquire("", "DIRECTORY") + except MapdlExitedError: + return self._path # os independent path format if self._path: # self.inquire might return ''. @@ -517,14 +510,10 @@ def directory(self) -> str: # new line to fix path issue, see #416 self._path = repr(self._path)[1:-1] else: # pragma: no cover - if self._path_cache: - return self._path_cache - else: - raise IOError( - f"The directory returned by /INQUIRE is not valid ('{self._path}')." - ) + raise MapdlRuntimeError( + f"The directory returned by /INQUIRE is not valid ('{self._path}')." + ) - self._path_cache = self._path # update return self._path @directory.setter @@ -532,6 +521,7 @@ def directory(self) -> str: def directory(self, path: Union[str, pathlib.Path]) -> None: """Change the directory using ``Mapdl.cwd``""" self.cwd(path) + self._path = path @property def exited(self): From 07a4cf989e86ef95d68f037ac6da37d171a9936c Mon Sep 17 00:00:00 2001 From: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com> Date: Fri, 25 Oct 2024 09:35:22 +0000 Subject: [PATCH 02/17] chore: adding changelog file 3517.miscellaneous.md [dependabot-skip] --- doc/changelog.d/3517.miscellaneous.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changelog.d/3517.miscellaneous.md diff --git a/doc/changelog.d/3517.miscellaneous.md b/doc/changelog.d/3517.miscellaneous.md new file mode 100644 index 0000000000..649e202524 --- /dev/null +++ b/doc/changelog.d/3517.miscellaneous.md @@ -0,0 +1 @@ +feat: simplifying directory setter property \ No newline at end of file From 4c6d12265acde6756f1518eea1f31cab12c31354 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 25 Oct 2024 11:59:39 +0200 Subject: [PATCH 03/17] test: adding test --- src/ansys/mapdl/core/mapdl_core.py | 3 +- tests/test_mapdl.py | 59 +++++++++++++++++++++--------- 2 files changed, 43 insertions(+), 19 deletions(-) diff --git a/src/ansys/mapdl/core/mapdl_core.py b/src/ansys/mapdl/core/mapdl_core.py index 62b7154fd6..9e9f593007 100644 --- a/src/ansys/mapdl/core/mapdl_core.py +++ b/src/ansys/mapdl/core/mapdl_core.py @@ -502,7 +502,8 @@ def directory(self) -> str: try: self._path = self.inquire("", "DIRECTORY") except MapdlExitedError: - return self._path + # Let's return the cached path + pass # os independent path format if self._path: # self.inquire might return ''. diff --git a/tests/test_mapdl.py b/tests/test_mapdl.py index 909860f461..5fa9ee6ee8 100644 --- a/tests/test_mapdl.py +++ b/tests/test_mapdl.py @@ -28,6 +28,7 @@ import shutil import tempfile import time +from unittest.mock import patch import grpc import numpy as np @@ -49,6 +50,7 @@ IncorrectWorkingDirectory, MapdlCommandIgnoredError, MapdlConnectionError, + MapdlExitedError, MapdlRuntimeError, ) from ansys.mapdl.core.launcher import launch_mapdl @@ -67,36 +69,26 @@ PORT1 = 50090 DEPRECATED_COMMANDS = [ + "edadapt", + "edale", "edasmp", "edbound", + "edbvis", "edbx", + "edcadapt", "edcgen", "edclist", "edcmore", "edcnstr", "edcontact", - "edcrb", - "edcurve", - "eddbl", - "eddc", - "edipart", - "edlcs", - "edmp", - "ednb", - "edndtsd", - "ednrot", - "edpart", - "edpc", - "edsp", - "edweld", - "edadapt", - "edale", - "edbvis", - "edcadapt", "edcpu", + "edcrb", "edcsc", "edcts", + "edcurve", "eddamp", + "eddbl", + "eddc", "eddrelax", "eddump", "edenergy", @@ -106,10 +98,18 @@ "edhist", "edhtime", "edint", + "edipart", "edis", + "edlcs", "edload", + "edmp", + "ednb", + "edndtsd", + "ednrot", "edopt", "edout", + "edpart", + "edpc", "edpl", "edpvel", "edrc", @@ -119,10 +119,12 @@ "edrun", "edshell", "edsolv", + "edsp", "edstart", "edterm", "edtp", "edvel", + "edweld", "edwrite", "rexport", ] @@ -2460,3 +2462,24 @@ def test_no_flush_stored(mapdl): assert not mapdl._store_commands assert mapdl._stored_commands == [] + + +def test_directory_setter(mapdl): + # Testing edge cases + prev_path = mapdl._path + + with patch( + "ansys.mapdl.core.Mapdl.inquire", side_effect=MapdlExitedError("mocked error") + ) as mck_inquire: + + assert prev_path == mapdl.directory + + mck_inquire.assert_called_once() + + mapdl._path = None + with pytest.raises( + MapdlRuntimeError, match="The directory returned by /INQUIRE is not valid" + ): + mapdl.directory + + mapdl._path = prev_path From f3438b592a99ee731709095123095175fa8747ab Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 25 Oct 2024 12:25:07 +0200 Subject: [PATCH 04/17] feat: caching directory in cwd --- src/ansys/mapdl/core/mapdl_extended.py | 3 +-- src/ansys/mapdl/core/mapdl_grpc.py | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ansys/mapdl/core/mapdl_extended.py b/src/ansys/mapdl/core/mapdl_extended.py index 0e5c859eb8..058e1aacd1 100644 --- a/src/ansys/mapdl/core/mapdl_extended.py +++ b/src/ansys/mapdl/core/mapdl_extended.py @@ -357,11 +357,10 @@ def cwd(self, *args, **kwargs): output = super().cwd(*args, mute=False, **kwargs) if output is not None: - if "*** WARNING ***" in output: + if "*** WARNING ***" in output or not self.directory: raise IncorrectWorkingDirectory( "\n" + "\n".join(output.splitlines()[1:]) ) - return output @wraps(_MapdlCore.list) diff --git a/src/ansys/mapdl/core/mapdl_grpc.py b/src/ansys/mapdl/core/mapdl_grpc.py index ea0aac63d8..4da72eec3b 100644 --- a/src/ansys/mapdl/core/mapdl_grpc.py +++ b/src/ansys/mapdl/core/mapdl_grpc.py @@ -906,6 +906,11 @@ def _run_at_connect(self): self.numvar(200, mute=True) self.inquire("", "DIRECTORY") + + # Caching directory + if not self.directory: + self.directory # try again + self.show(self._file_type_for_plots) self.version # Caching version self.file_type_for_plots # Setting /show,png and caching it. From 6c7f718457bd8ea1281d6373a69305cb70f49b88 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 25 Oct 2024 12:34:04 +0200 Subject: [PATCH 05/17] feat: caching directory for sure. --- src/ansys/mapdl/core/mapdl_extended.py | 4 +++- tests/test_mapdl.py | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/ansys/mapdl/core/mapdl_extended.py b/src/ansys/mapdl/core/mapdl_extended.py index 058e1aacd1..b282b514bb 100644 --- a/src/ansys/mapdl/core/mapdl_extended.py +++ b/src/ansys/mapdl/core/mapdl_extended.py @@ -357,10 +357,12 @@ def cwd(self, *args, **kwargs): output = super().cwd(*args, mute=False, **kwargs) if output is not None: - if "*** WARNING ***" in output or not self.directory: + if "*** WARNING ***" in output: raise IncorrectWorkingDirectory( "\n" + "\n".join(output.splitlines()[1:]) ) + + self.directory # caching return output @wraps(_MapdlCore.list) diff --git a/tests/test_mapdl.py b/tests/test_mapdl.py index 5fa9ee6ee8..f23842197a 100644 --- a/tests/test_mapdl.py +++ b/tests/test_mapdl.py @@ -2483,3 +2483,13 @@ def test_directory_setter(mapdl): mapdl.directory mapdl._path = prev_path + + +def test_cwd_changing_directory(mapdl): + prev_path = mapdl._path + mapdl._path = None + + mapdl.cwd(prev_path) + + assert mapdl._path == prev_path + assert mapdl.directory == prev_path From d2e70be598da3dbbffd53988722f59f450d72345 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 25 Oct 2024 12:48:08 +0200 Subject: [PATCH 06/17] feat: caching dir at the cwd level. --- src/ansys/mapdl/core/mapdl_core.py | 1 - src/ansys/mapdl/core/mapdl_extended.py | 14 ++++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/ansys/mapdl/core/mapdl_core.py b/src/ansys/mapdl/core/mapdl_core.py index 9e9f593007..0971b71348 100644 --- a/src/ansys/mapdl/core/mapdl_core.py +++ b/src/ansys/mapdl/core/mapdl_core.py @@ -522,7 +522,6 @@ def directory(self) -> str: def directory(self, path: Union[str, pathlib.Path]) -> None: """Change the directory using ``Mapdl.cwd``""" self.cwd(path) - self._path = path @property def exited(self): diff --git a/src/ansys/mapdl/core/mapdl_extended.py b/src/ansys/mapdl/core/mapdl_extended.py index b282b514bb..ad1e8ab557 100644 --- a/src/ansys/mapdl/core/mapdl_extended.py +++ b/src/ansys/mapdl/core/mapdl_extended.py @@ -37,6 +37,7 @@ CommandDeprecated, ComponentDoesNotExits, IncorrectWorkingDirectory, + MapdlCommandIgnoredError, MapdlRuntimeError, ) from ansys.mapdl.core.mapdl_core import _MapdlCore @@ -354,15 +355,12 @@ def mpread(self, fname="", ext="", lib="", **kwargs): @wraps(_MapdlCore.cwd) def cwd(self, *args, **kwargs): """Wraps cwd.""" - output = super().cwd(*args, mute=False, **kwargs) + try: + output = super().cwd(*args, mute=False, **kwargs) + except MapdlCommandIgnoredError as e: + raise IncorrectWorkingDirectory(e.args[0]) - if output is not None: - if "*** WARNING ***" in output: - raise IncorrectWorkingDirectory( - "\n" + "\n".join(output.splitlines()[1:]) - ) - - self.directory # caching + self._path = args[0] # caching return output @wraps(_MapdlCore.list) From 393d70d6e7b4e8a77bdc4957cb9e76ec0648decd Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 25 Oct 2024 13:26:12 +0200 Subject: [PATCH 07/17] feat: retry mechanism inside /INQUIRE --- src/ansys/mapdl/core/mapdl_extended.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ansys/mapdl/core/mapdl_extended.py b/src/ansys/mapdl/core/mapdl_extended.py index ad1e8ab557..f7af20a0b5 100644 --- a/src/ansys/mapdl/core/mapdl_extended.py +++ b/src/ansys/mapdl/core/mapdl_extended.py @@ -1422,8 +1422,16 @@ def inquire(self, strarray="", func="", arg1="", arg2=""): raise ValueError( f"The arguments (strarray='{strarray}', func='{func}') are not valid." ) + response = "" + n_try = 3 + i_try = 0 + while i_try < n_try and not response: + response = self.run(f"/INQUIRE,{strarray},{func},{arg1},{arg2}", mute=False) + i_try += 1 + else: + if not response: + raise MapdlRuntimeError("/INQUIRE command didn't return a response.") - response = self.run(f"/INQUIRE,{strarray},{func},{arg1},{arg2}", mute=False) if func.upper() in [ "ENV", "TITLE", From 51f528b86b1e34a9dcbdca9537dc0577ff9d5477 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 25 Oct 2024 13:27:14 +0200 Subject: [PATCH 08/17] feat: changing exception message --- src/ansys/mapdl/core/mapdl_core.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/ansys/mapdl/core/mapdl_core.py b/src/ansys/mapdl/core/mapdl_core.py index 0971b71348..3bf1fe8a38 100644 --- a/src/ansys/mapdl/core/mapdl_core.py +++ b/src/ansys/mapdl/core/mapdl_core.py @@ -497,8 +497,7 @@ def directory(self) -> str: accessible, ``cwd`` (:func:`MapdlBase.cwd`) will raise a warning. """ - # always attempt to cache the path - + # Inside inquire there is already a retry mechanisim try: self._path = self.inquire("", "DIRECTORY") except MapdlExitedError: @@ -510,9 +509,9 @@ def directory(self) -> str: self._path = self._path.replace("\\", "/") # new line to fix path issue, see #416 self._path = repr(self._path)[1:-1] - else: # pragma: no cover + else: raise MapdlRuntimeError( - f"The directory returned by /INQUIRE is not valid ('{self._path}')." + f"MAPDL could provide a path using /INQUIRE or the cached path ('{self._path}')." ) return self._path From bc7a0055ef3e6e47606d5e6f597779006f380344 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 25 Oct 2024 13:28:11 +0200 Subject: [PATCH 09/17] feat: adding tests --- tests/test_mapdl.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_mapdl.py b/tests/test_mapdl.py index f23842197a..4f5be64dad 100644 --- a/tests/test_mapdl.py +++ b/tests/test_mapdl.py @@ -2476,9 +2476,10 @@ def test_directory_setter(mapdl): mck_inquire.assert_called_once() - mapdl._path = None + mapdl._path = "" with pytest.raises( - MapdlRuntimeError, match="The directory returned by /INQUIRE is not valid" + MapdlRuntimeError, + match="MAPDL could provide a path using /INQUIRE or the cached path", ): mapdl.directory From 87711b78c9dcf4bbfc8c0ab6dbe72d6c2c1ed3b7 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 25 Oct 2024 13:30:23 +0200 Subject: [PATCH 10/17] feat: caching directory --- src/ansys/mapdl/core/mapdl_grpc.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/ansys/mapdl/core/mapdl_grpc.py b/src/ansys/mapdl/core/mapdl_grpc.py index 4da72eec3b..120ba7b804 100644 --- a/src/ansys/mapdl/core/mapdl_grpc.py +++ b/src/ansys/mapdl/core/mapdl_grpc.py @@ -905,11 +905,8 @@ def _run_at_connect(self): with self.run_as_routine("POST26"): self.numvar(200, mute=True) - self.inquire("", "DIRECTORY") - # Caching directory - if not self.directory: - self.directory # try again + self.directory self.show(self._file_type_for_plots) self.version # Caching version From b2faf9342a7484fecddc03fcd53800aadd87b235 Mon Sep 17 00:00:00 2001 From: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com> Date: Fri, 25 Oct 2024 11:36:14 +0000 Subject: [PATCH 11/17] chore: adding changelog file 3517.added.md [dependabot-skip] --- doc/changelog.d/3517.added.md | 1 + doc/changelog.d/3517.miscellaneous.md | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 doc/changelog.d/3517.added.md delete mode 100644 doc/changelog.d/3517.miscellaneous.md diff --git a/doc/changelog.d/3517.added.md b/doc/changelog.d/3517.added.md new file mode 100644 index 0000000000..d245230f94 --- /dev/null +++ b/doc/changelog.d/3517.added.md @@ -0,0 +1 @@ +refactor: simplifying directory setter property \ No newline at end of file diff --git a/doc/changelog.d/3517.miscellaneous.md b/doc/changelog.d/3517.miscellaneous.md deleted file mode 100644 index 649e202524..0000000000 --- a/doc/changelog.d/3517.miscellaneous.md +++ /dev/null @@ -1 +0,0 @@ -feat: simplifying directory setter property \ No newline at end of file From f29405888ae67e5a53975e488ef2c438998dd7f0 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 25 Oct 2024 13:36:23 +0200 Subject: [PATCH 12/17] refactor: avoid else in while. --- src/ansys/mapdl/core/mapdl_extended.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ansys/mapdl/core/mapdl_extended.py b/src/ansys/mapdl/core/mapdl_extended.py index f7af20a0b5..b2834c5d46 100644 --- a/src/ansys/mapdl/core/mapdl_extended.py +++ b/src/ansys/mapdl/core/mapdl_extended.py @@ -1428,9 +1428,9 @@ def inquire(self, strarray="", func="", arg1="", arg2=""): while i_try < n_try and not response: response = self.run(f"/INQUIRE,{strarray},{func},{arg1},{arg2}", mute=False) i_try += 1 - else: - if not response: - raise MapdlRuntimeError("/INQUIRE command didn't return a response.") + + if not response: + raise MapdlRuntimeError("/INQUIRE command didn't return a response.") if func.upper() in [ "ENV", From 6811cc2351c0f2f32b3f798e79889e4e57a13d59 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 25 Oct 2024 14:08:02 +0200 Subject: [PATCH 13/17] refactor: using a temporary variable to avoid overwrite self._path Raise error if empty response only if non_interactive mode. --- src/ansys/mapdl/core/mapdl_core.py | 13 ++++++++----- src/ansys/mapdl/core/mapdl_extended.py | 19 +++++++++++-------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/ansys/mapdl/core/mapdl_core.py b/src/ansys/mapdl/core/mapdl_core.py index 3bf1fe8a38..6c47400cb8 100644 --- a/src/ansys/mapdl/core/mapdl_core.py +++ b/src/ansys/mapdl/core/mapdl_core.py @@ -498,18 +498,21 @@ def directory(self) -> str: a warning. """ # Inside inquire there is already a retry mechanisim + path = None try: - self._path = self.inquire("", "DIRECTORY") + path = self.inquire("", "DIRECTORY") except MapdlExitedError: # Let's return the cached path pass # os independent path format - if self._path: # self.inquire might return ''. - self._path = self._path.replace("\\", "/") + if path: # self.inquire might return ''. + path = path.replace("\\", "/") # new line to fix path issue, see #416 - self._path = repr(self._path)[1:-1] - else: + path = repr(path)[1:-1] + self._path = path + + elif not self._path: raise MapdlRuntimeError( f"MAPDL could provide a path using /INQUIRE or the cached path ('{self._path}')." ) diff --git a/src/ansys/mapdl/core/mapdl_extended.py b/src/ansys/mapdl/core/mapdl_extended.py index b2834c5d46..92ea2f89aa 100644 --- a/src/ansys/mapdl/core/mapdl_extended.py +++ b/src/ansys/mapdl/core/mapdl_extended.py @@ -1430,15 +1430,18 @@ def inquire(self, strarray="", func="", arg1="", arg2=""): i_try += 1 if not response: - raise MapdlRuntimeError("/INQUIRE command didn't return a response.") - - if func.upper() in [ - "ENV", - "TITLE", - ]: # the output is multiline, we just need the last line. - response = response.splitlines()[-1] + if not self._store_commands: + raise MapdlRuntimeError("/INQUIRE command didn't return a response.") + else: + if func.upper() in [ + "ENV", + "TITLE", + ]: # the output is multiline, we just need the last line. + response = response.splitlines()[-1] + else: + response = response.split("=")[1].strip() - return response.split("=")[1].strip() + return response @wraps(_MapdlCore.parres) def parres(self, lab="", fname="", ext="", **kwargs): From 4b9648f54b2786ce2d72341973236060735786bc Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 25 Oct 2024 14:26:59 +0200 Subject: [PATCH 14/17] fix: not keeping state between tests --- tests/conftest.py | 1 + tests/test_mapdl.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index b0434fe308..703bd3a36d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -439,6 +439,7 @@ def run_before_and_after_tests( assert prev == mapdl.is_local assert not mapdl.exited + assert not mapdl.ignore_errors make_sure_not_instances_are_left_open() diff --git a/tests/test_mapdl.py b/tests/test_mapdl.py index 4f5be64dad..506c0bbabe 100644 --- a/tests/test_mapdl.py +++ b/tests/test_mapdl.py @@ -469,7 +469,7 @@ def test_error(mapdl): mapdl.a(0, 0, 0, 0) -def test_ignore_error(mapdl): +def test_ignore_errors(mapdl): mapdl.ignore_errors = False assert not mapdl.ignore_errors mapdl.ignore_errors = True @@ -480,8 +480,8 @@ def test_ignore_error(mapdl): out = mapdl._run("A, 0, 0, 0") assert "*** ERROR ***" in out - mapdl.ignore_error = False - assert mapdl.ignore_error is False + mapdl.ignore_errors = False + assert mapdl.ignore_errors is False @requires("grpc") From ed714bd87da601a5ba0a5b433be5571ed9dd3305 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 25 Oct 2024 14:33:07 +0200 Subject: [PATCH 15/17] fix: making sure the state is reset between tests --- tests/test_mapdl.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_mapdl.py b/tests/test_mapdl.py index 506c0bbabe..c3812a17f6 100644 --- a/tests/test_mapdl.py +++ b/tests/test_mapdl.py @@ -1728,6 +1728,7 @@ def test_on_docker(mapdl): def test_deprecation_allow_ignore_warning(mapdl): with pytest.warns(DeprecationWarning, match="'allow_ignore' is being deprecated"): mapdl.allow_ignore = True + mapdl.ignore_errors = False def test_deprecation_allow_ignore_errors_mapping(mapdl): From ed2eb770d372125119658bb9cf583e015c012450 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 25 Oct 2024 14:49:18 +0200 Subject: [PATCH 16/17] fix: warning when exiting. --- src/ansys/mapdl/core/mapdl_core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ansys/mapdl/core/mapdl_core.py b/src/ansys/mapdl/core/mapdl_core.py index 6c47400cb8..f9664ad6a8 100644 --- a/src/ansys/mapdl/core/mapdl_core.py +++ b/src/ansys/mapdl/core/mapdl_core.py @@ -2311,7 +2311,7 @@ def __del__(self): self.exit() except Exception as e: try: # logger might be closed - if self._log is not None: + if hasattr(self, "_log") and self._log is not None: self._log.error("exit: %s", str(e)) except ValueError: pass From 521473f5aea08841e2eafd50d31200b5619c8bc0 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 25 Oct 2024 14:50:34 +0200 Subject: [PATCH 17/17] fix: test --- src/ansys/mapdl/core/mapdl_extended.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ansys/mapdl/core/mapdl_extended.py b/src/ansys/mapdl/core/mapdl_extended.py index 185ea885bd..fa8ce48de9 100644 --- a/src/ansys/mapdl/core/mapdl_extended.py +++ b/src/ansys/mapdl/core/mapdl_extended.py @@ -1440,8 +1440,8 @@ def inquire(self, strarray="", func="", arg1="", arg2="", **kwargs): "TITLE", ]: # the output is multiline, we just need the last line. response = response.splitlines()[-1] - else: - response = response.split("=")[1].strip() + + response = response.split("=")[1].strip() return response