From 1561b8a134fa9b2d0fddfa4e52fc1f100ee821a6 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Sun, 14 Sep 2025 18:57:59 +0200 Subject: [PATCH 1/4] feat: add STATUS enum for MAPDL state management --- src/ansys/mapdl/core/mapdl_core.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/ansys/mapdl/core/mapdl_core.py b/src/ansys/mapdl/core/mapdl_core.py index 111c1a0164d..da2bea6d9ce 100644 --- a/src/ansys/mapdl/core/mapdl_core.py +++ b/src/ansys/mapdl/core/mapdl_core.py @@ -22,6 +22,7 @@ """Module to control interaction with MAPDL through Python""" +from enum import StrEnum from functools import wraps import glob import logging @@ -233,6 +234,12 @@ ] +class STATUS(StrEnum): + EXITED = "exited" + EXITING = "exiting" + RUNNING = "running" + + def parse_to_short_cmd(command): """Takes any MAPDL command and returns the first 4 characters of the command @@ -472,18 +479,18 @@ def chain_commands(self): return self._chain_commands(self) @property - def check_status(self): + def check_status(self) -> STATUS: """Return MAPDL status. * 'exited' if MAPDL is exited * 'exiting' if MAPDL is exiting - * Otherwise returns 'OK'. + * Otherwise returns 'running'. """ if self.exited: - return "exited" + return STATUS.EXITED elif self.exiting: - return "exiting" + return STATUS.EXITING else: - return "OK" + return STATUS.RUNNING @property def components(self) -> "ComponentManager": From 5a5c5fc34e28f755c0fce3fc969b91c435cebb8a Mon Sep 17 00:00:00 2001 From: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com> Date: Sun, 14 Sep 2025 16:59:40 +0000 Subject: [PATCH 2/4] chore: adding changelog file 4221.added.md [dependabot-skip] --- doc/changelog.d/4221.added.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changelog.d/4221.added.md diff --git a/doc/changelog.d/4221.added.md b/doc/changelog.d/4221.added.md new file mode 100644 index 00000000000..b57475a222e --- /dev/null +++ b/doc/changelog.d/4221.added.md @@ -0,0 +1 @@ +Add STATUS enum for MAPDL state management From 36744fe782ddc458790baeaba90c89853e751b3f Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Mon, 29 Sep 2025 14:34:05 +0200 Subject: [PATCH 3/4] refactor: change STATUS class to inherit from str and Enum2 --- src/ansys/mapdl/core/mapdl_core.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ansys/mapdl/core/mapdl_core.py b/src/ansys/mapdl/core/mapdl_core.py index da2bea6d9ce..e6ba3d9b982 100644 --- a/src/ansys/mapdl/core/mapdl_core.py +++ b/src/ansys/mapdl/core/mapdl_core.py @@ -22,7 +22,7 @@ """Module to control interaction with MAPDL through Python""" -from enum import StrEnum +from enum import Enum from functools import wraps import glob import logging @@ -234,7 +234,7 @@ ] -class STATUS(StrEnum): +class STATUS(str, Enum): EXITED = "exited" EXITING = "exiting" RUNNING = "running" From a23667aeb28218e3146eb12c15f5f1d30d27f4ee Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Mon, 29 Sep 2025 15:48:29 +0200 Subject: [PATCH 4/4] test: update check_status assertion to reflect running state --- tests/test_mapdl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_mapdl.py b/tests/test_mapdl.py index 56ef1beb906..7e1796d56b4 100644 --- a/tests/test_mapdl.py +++ b/tests/test_mapdl.py @@ -2254,7 +2254,7 @@ def test_exiting(mapdl, cleared): def test_check_status(mapdl, cleared): - assert mapdl.check_status == "OK" + assert mapdl.check_status == "running" mapdl._exited = True assert mapdl.exited