Skip to content

Commit

Permalink
fix: fixed alerts when importing
Browse files Browse the repository at this point in the history
  • Loading branch information
SteZamboni committed Oct 28, 2024
1 parent af7c03e commit 2505c77
Showing 1 changed file with 28 additions and 27 deletions.
55 changes: 28 additions & 27 deletions api/app/services/model_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,34 +137,35 @@ def get_last_n_alerts(self, n_alerts) -> List[AlertDTO]:
latest_reference_dataset, latest_current_dataset = self.get_latest_datasets(
model.uuid
)
for perc in ['data_quality', 'model_quality', 'drift']:
if count_alerts == n_alerts:
return res
if 0 <= metrics.percentages[perc]['value'] < 1:
res.append(
AlertDTO.from_dict(
{
'model_uuid': model.uuid,
'reference_uuid': latest_reference_dataset.uuid
if latest_reference_dataset
else None,
'current_uuid': latest_current_dataset.uuid
if latest_current_dataset
else None,
'anomaly_type': AnomalyType[perc.upper()],
'anomaly_features': [
x['feature_name']
for x in sorted(
metrics.percentages[perc]['details'],
key=lambda e: e['score'],
reverse=True,
)
if x['score'] > 0
],
}
if metrics:
for perc in ['data_quality', 'model_quality', 'drift']:
if count_alerts == n_alerts:
return res
if 0 <= metrics.percentages[perc]['value'] < 1:
res.append(
AlertDTO.from_dict(
{
'model_uuid': model.uuid,
'reference_uuid': latest_reference_dataset.uuid
if latest_reference_dataset
else None,
'current_uuid': latest_current_dataset.uuid
if latest_current_dataset
else None,
'anomaly_type': AnomalyType[perc.upper()],
'anomaly_features': [
x['feature_name']
for x in sorted(
metrics.percentages[perc]['details'],
key=lambda e: e['score'],
reverse=True,
)
if x['score'] > 0
],
}
)
)
)
count_alerts += 1
count_alerts += 1

return res

Expand Down

0 comments on commit 2505c77

Please sign in to comment.