Skip to content

Commit e64eef3

Browse files
committed
Made id, name and status return None or cached vals instead of raising error
1 parent 6a42cd8 commit e64eef3

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

simvue/run.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,9 @@ def __exit__(
257257
) -> None:
258258
logger.debug(
259259
"Automatically closing run '%s' in status %s",
260-
self.id if self._user_config.run.mode == "online" else "unregistered",
260+
self.id
261+
if self._user_config.run.mode == "online" and self._sv_obj
262+
else "unregistered",
261263
self._status,
262264
)
263265

@@ -940,7 +942,10 @@ def executor(self) -> Executor:
940942
def name(self) -> str | None:
941943
"""Return the name of the run"""
942944
if not self._sv_obj:
943-
raise RuntimeError("Run has not been initialised")
945+
logger.warning(
946+
"Attempted to get name on non initialized run - returning None"
947+
)
948+
return None
944949
return self._sv_obj.name
945950

946951
@property
@@ -954,7 +959,10 @@ def status(
954959
):
955960
"""Return the status of the run"""
956961
if not self._sv_obj:
957-
raise RuntimeError("Run has not been initialised")
962+
logger.warning(
963+
"Attempted to get name on non initialized run - returning cached value"
964+
)
965+
return self._status
958966
return self._sv_obj.status
959967

960968
@property
@@ -966,7 +974,10 @@ def uid(self) -> str:
966974
def id(self) -> str | None:
967975
"""Return the unique id of the run"""
968976
if not self._sv_obj:
969-
raise RuntimeError("Run has not been initialised")
977+
logger.warning(
978+
"Attempted to get name on non initialized run - returning None"
979+
)
980+
return None
970981
return self._sv_obj.id
971982

972983
@skip_if_failed("_aborted", "_suppress_errors", False)

0 commit comments

Comments
 (0)