@@ -74,7 +74,7 @@ def check_run_initialised(
74
74
) -> typing .Callable [..., typing .Any ]:
75
75
@functools .wraps (function )
76
76
def _wrapper (self : Self , * args : typing .Any , ** kwargs : typing .Any ) -> typing .Any :
77
- if self ._mode == "disabled" :
77
+ if self ._user_config . run . mode == "disabled" :
78
78
return True
79
79
80
80
if self ._retention and time .time () - self ._timer > self ._retention :
@@ -129,7 +129,6 @@ def __init__(
129
129
run in debug mode, default is False
130
130
"""
131
131
self ._uuid : str = f"{ uuid .uuid4 ()} "
132
- self ._mode : typing .Literal ["online" , "offline" , "disabled" ] = mode
133
132
self ._name : typing .Optional [str ] = None
134
133
135
134
# monitor duration with respect to retention period
@@ -202,7 +201,9 @@ def _handle_exception_throw(
202
201
)
203
202
_is_running : bool = self ._status == "running"
204
203
_is_running_online : bool = self ._id is not None and _is_running
205
- _is_running_offline : bool = self ._mode == "offline" and _is_running
204
+ _is_running_offline : bool = (
205
+ self ._user_config .run .mode == "offline" and _is_running
206
+ )
206
207
_is_terminated : bool = (
207
208
_exception_thrown is not None and _exception_thrown == "KeyboardInterrupt"
208
209
)
@@ -250,7 +251,7 @@ def __exit__(
250
251
) -> None :
251
252
logger .debug (
252
253
"Automatically closing run '%s' in status %s" ,
253
- self ._id if self ._mode == "online" else "unregistered" ,
254
+ self ._id if self ._user_config . run . mode == "online" else "unregistered" ,
254
255
self ._status ,
255
256
)
256
257
@@ -315,7 +316,7 @@ def _create_heartbeat_callback(
315
316
self ,
316
317
) -> typing .Callable [[threading .Event ], None ]:
317
318
if (
318
- self ._mode == "online"
319
+ self ._user_config . run . mode == "online"
319
320
and (not self ._user_config .server .url or not self ._id )
320
321
) or not self ._heartbeat_termination_trigger :
321
322
raise RuntimeError ("Could not commence heartbeat, run not initialised" )
@@ -395,7 +396,7 @@ def _create_dispatch_callback(
395
396
executed on metrics and events objects held in a buffer.
396
397
"""
397
398
398
- if self ._mode == "online" and not self ._id :
399
+ if self ._user_config . run . mode == "online" and not self ._id :
399
400
raise RuntimeError ("Expected identifier for run" )
400
401
401
402
if not self ._user_config .server .url :
@@ -456,7 +457,7 @@ def _online_dispatch_callback(
456
457
457
458
return (
458
459
_online_dispatch_callback
459
- if self ._mode == "online"
460
+ if self ._user_config . run . mode == "online"
460
461
else _offline_dispatch_callback
461
462
)
462
463
@@ -473,10 +474,10 @@ def _start(self, reconnect: bool = False) -> bool:
473
474
bool
474
475
if successful
475
476
"""
476
- if self ._mode == "disabled" :
477
+ if self ._user_config . run . mode == "disabled" :
477
478
return True
478
479
479
- if self ._mode != "offline" :
480
+ if self ._user_config . run . mode != "offline" :
480
481
self ._uuid = "notused"
481
482
482
483
logger .debug ("Starting run" )
@@ -631,7 +632,7 @@ def init(
631
632
bool
632
633
whether the initialisation was successful
633
634
"""
634
- if self ._mode == "disabled" :
635
+ if self ._user_config . run . mode == "disabled" :
635
636
logger .warning (
636
637
"Simvue monitoring has been deactivated for this run, metrics and artifacts will not be recorded."
637
638
)
@@ -650,7 +651,7 @@ def init(
650
651
"invalid visibility option, must be either None, 'public', 'tenant' or a list of users"
651
652
)
652
653
653
- if self ._mode not in ("online" , "offline" ):
654
+ if self ._user_config . run . mode not in ("online" , "offline" ):
654
655
self ._error ("invalid mode specified, must be online, offline or disabled" )
655
656
return False
656
657
@@ -709,7 +710,7 @@ def init(
709
710
self ._simvue = Simvue (
710
711
name = self ._name ,
711
712
uniq_id = self ._uuid ,
712
- mode = self ._mode ,
713
+ mode = self ._user_config . run . mode ,
713
714
config = self ._user_config ,
714
715
suppress_errors = self ._suppress_errors ,
715
716
)
@@ -726,7 +727,7 @@ def init(
726
727
if self ._status == "running" :
727
728
self ._start ()
728
729
729
- if self ._mode == "online" :
730
+ if self ._user_config . run . mode == "online" :
730
731
click .secho (
731
732
f"[simvue] Run { self ._name } created" ,
732
733
bold = self ._term_color ,
@@ -941,7 +942,11 @@ def reconnect(self, run_id: str) -> bool:
941
942
942
943
self ._id = run_id
943
944
self ._simvue = Simvue (
944
- self ._name , self ._id , self ._mode , self ._user_config , self ._suppress_errors
945
+ self ._name ,
946
+ self ._id ,
947
+ self ._user_config .run .mode ,
948
+ self ._user_config ,
949
+ self ._suppress_errors ,
945
950
)
946
951
self ._start (reconnect = True )
947
952
@@ -1192,7 +1197,7 @@ def _add_metrics_to_dispatch(
1192
1197
timestamp : typing .Optional [str ] = None ,
1193
1198
join_on_fail : bool = True ,
1194
1199
) -> bool :
1195
- if self ._mode == "disabled" :
1200
+ if self ._user_config . run . mode == "disabled" :
1196
1201
return True
1197
1202
1198
1203
# If there are no metrics to log just ignore
0 commit comments