@@ -1309,7 +1309,7 @@ def add_alerts(
1309
1309
return False
1310
1310
1311
1311
@pydantic .validate_call
1312
- @skip_if_failed ("_aborted" , "_suppress_errors" , False )
1312
+ @skip_if_failed ("_aborted" , "_suppress_errors" , None )
1313
1313
@pydantic .validate_call
1314
1314
def create_alert (
1315
1315
self ,
@@ -1332,7 +1332,7 @@ def create_alert(
1332
1332
] = "average" ,
1333
1333
notification : typing .Literal ["email" , "none" ] = "none" ,
1334
1334
pattern : typing .Optional [str ] = None ,
1335
- ) -> bool :
1335
+ ) -> typing . Optional [ str ] :
1336
1336
"""Creates an alert with the specified name (if it doesn't exist)
1337
1337
and applies it to the current run. If alert already exists it will
1338
1338
not be duplicated.
@@ -1394,27 +1394,27 @@ def create_alert(
1394
1394
1395
1395
Returns
1396
1396
-------
1397
- bool
1398
- returns True on success
1397
+ str | None
1398
+ returns the created alert ID if successful
1399
1399
"""
1400
1400
if self ._mode == "disabled" :
1401
- return True
1401
+ return None
1402
1402
1403
1403
if not self ._simvue :
1404
1404
self ._error ("Cannot add alert, run not initialised" )
1405
- return False
1405
+ return None
1406
1406
1407
1407
if rule in ("is below" , "is above" ) and threshold is None :
1408
1408
self ._error ("threshold must be defined for the specified alert type" )
1409
- return False
1409
+ return None
1410
1410
1411
1411
if rule in ("is outside range" , "is inside range" ) and (
1412
1412
range_low is None or range_high is None
1413
1413
):
1414
1414
self ._error (
1415
1415
"range_low and range_high must be defined for the specified alert type"
1416
1416
)
1417
- return False
1417
+ return None
1418
1418
1419
1419
alert_definition = {}
1420
1420
@@ -1461,15 +1461,14 @@ def create_alert(
1461
1461
alert_id = response ["id" ]
1462
1462
else :
1463
1463
self ._error ("unable to create alert" )
1464
- return False
1464
+ return None
1465
1465
1466
1466
if alert_id :
1467
1467
# TODO: What if we keep existing alerts/add a new one later?
1468
1468
data = {"id" : self ._id , "alerts" : [alert_id ]}
1469
- if self ._simvue .update (data ):
1470
- return True
1469
+ self ._simvue .update (data )
1471
1470
1472
- return False
1471
+ return alert_id
1473
1472
1474
1473
@pydantic .validate_call
1475
1474
@skip_if_failed ("_aborted" , "_suppress_errors" , False )
0 commit comments