in otava/main.py [0:0]
def remove_grafana_annotations(self, test: Optional[TestConfig], force: bool):
"""Removes all Otava annotations (optionally for a given test) in Grafana"""
grafana = self.__get_grafana()
if test:
logging.info(f"Fetching Grafana annotations for test {test.name}...")
else:
logging.info("Fetching Grafana annotations...")
tags_to_query = {"otava", "change-point"}
if test:
tags_to_query.add(f"test: {test.name}")
annotations = grafana.fetch_annotations(None, None, list(tags_to_query))
if not annotations:
logging.info("No annotations found.")
return
if not force:
print(
f"Are you sure to remove {len(annotations)} annotations from {grafana.url}? [y/N]"
)
decision = input().strip()
if decision.lower() != "y" and decision.lower() != "yes":
return
logging.info(f"Removing {len(annotations)} annotations...")
grafana.delete_annotations(*(a.id for a in annotations))