Skip to content

add_alerts doesnt work when provided names #694

@wk9874

Description

@wk9874
with Run() as myrun:
    print("here 4")
    myrun.init(name="myrun", folder="/my/test/")
    myrun.create_metric_threshold_alert(
        name="my_test_alert_2",
        metric="test_metric",
        threshold = 20.0,
        rule = "is above",
        description = "dddh"
    )
    myrun.add_alerts(names=["my_test_alert_2"])

Gives:

INFO:simvue.run:Existing alert found with id: Spxq46ShSvBsJqqaH4EqYC
Traceback (most recent call last):
  File "/home/wk9874/Documents/simvue/python-api/test.py", line 24, in <module>
    myrun.add_alerts(names=["my_test_alert_2"])
  File "/home/wk9874/Documents/simvue/python-api/simvue/utilities.py", line 244, in wrapper
    return class_func(self, *args, **kwargs)
  File "/home/wk9874/Documents/simvue/python-api/simvue/run.py", line 100, in _wrapper
    return _function(self, *args, **kwargs)
  File "/home/wk9874/Documents/simvue/python-api/simvue/utilities.py", line 281, in wrapper
    return class_func(self, *args, **kwargs)
  File "/home/wk9874/.cache/pypoetry/virtualenvs/simvue-EU1pkP6Z-py3.10/lib/python3.10/site-packages/pydantic/_internal/_validate_call.py", line 38, in wrapper_function
    return wrapper(*args, **kwargs)
  File "/home/wk9874/.cache/pypoetry/virtualenvs/simvue-EU1pkP6Z-py3.10/lib/python3.10/site-packages/pydantic/_internal/_validate_call.py", line 111, in __call__
    res = self.__pydantic_validator__.validate_python(pydantic_core.ArgsKwargs(args, kwargs))
  File "/home/wk9874/Documents/simvue/python-api/simvue/run.py", line 1635, in add_alerts
    if alert.name in names:
AttributeError: 'tuple' object has no attribute 'name'

Because Alert.get returns a list of tuples of (id, Alert).

Metadata

Metadata

Assignees

Labels

ready for testingThis issue has been fixed and is ready for testing

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions