Skip to content

Commit 2ecca81

Browse files
feat: add STATUS enum for MAPDL state management (#4221)
* feat: add STATUS enum for MAPDL state management * chore: adding changelog file 4221.added.md [dependabot-skip] * refactor: change STATUS class to inherit from str and Enum2 * test: update check_status assertion to reflect running state --------- Co-authored-by: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com>
1 parent 6041d37 commit 2ecca81

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

doc/changelog.d/4221.added.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add STATUS enum for MAPDL state management

src/ansys/mapdl/core/mapdl_core.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
"""Module to control interaction with MAPDL through Python"""
2424

25+
from enum import Enum
2526
from functools import wraps
2627
import glob
2728
import logging
@@ -233,6 +234,12 @@
233234
]
234235

235236

237+
class STATUS(str, Enum):
238+
EXITED = "exited"
239+
EXITING = "exiting"
240+
RUNNING = "running"
241+
242+
236243
def parse_to_short_cmd(command):
237244
"""Takes any MAPDL command and returns the first 4 characters of
238245
the command
@@ -472,18 +479,18 @@ def chain_commands(self):
472479
return self._chain_commands(self)
473480

474481
@property
475-
def check_status(self):
482+
def check_status(self) -> STATUS:
476483
"""Return MAPDL status.
477484
* 'exited' if MAPDL is exited
478485
* 'exiting' if MAPDL is exiting
479-
* Otherwise returns 'OK'.
486+
* Otherwise returns 'running'.
480487
"""
481488
if self.exited:
482-
return "exited"
489+
return STATUS.EXITED
483490
elif self.exiting:
484-
return "exiting"
491+
return STATUS.EXITING
485492
else:
486-
return "OK"
493+
return STATUS.RUNNING
487494

488495
@property
489496
def components(self) -> "ComponentManager":

tests/test_mapdl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2286,7 +2286,7 @@ def test_exiting(mapdl, cleared):
22862286

22872287

22882288
def test_check_status(mapdl, cleared):
2289-
assert mapdl.check_status == "OK"
2289+
assert mapdl.check_status == "running"
22902290

22912291
mapdl._exited = True
22922292
assert mapdl.exited

0 commit comments

Comments
 (0)