Skip to content
This repository has been archived by the owner on Oct 5, 2023. It is now read-only.

Commit

Permalink
fix: set model for metrickeys using deep copy (#764)
Browse files Browse the repository at this point in the history
* fix: set model for metrickeys using deep copy

* remove console log
  • Loading branch information
stevenyh3 authored May 9, 2023
1 parent 8645e37 commit 60baffe
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions frontend/src/api/slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,19 @@ function setModelForMetricKey(
pred.column.columnType === ZenoColumnType.POSTDISTILL ||
pred.column.columnType === ZenoColumnType.OUTPUT
) {
pred.column.model = model;
pred = {
...pred,
column: {
...pred.column,
model: model,
},
};
}
} else {
pred.predicates = pred.predicates.map((p) =>
setModelForMetricKey(p, model)
);
return {
...pred,
predicates: pred.predicates.map((p) => setModelForMetricKey(p, model)),
};
}
return pred;
}
Expand All @@ -35,11 +42,20 @@ function setModelForMetricKeys(metricKeys: MetricKey[]) {
key.sli.filterPredicates &&
key.sli.filterPredicates.predicates.length > 0
) {
key.sli.filterPredicates.predicates.map((pred) =>
setModelForMetricKey(pred, key.model)
);
return {
...key,
sli: {
...key.sli,
filterPredicates: {
...key.sli.filterPredicates,
predicates: key.sli.filterPredicates.predicates.map((pred) => {
return { ...pred, ...setModelForMetricKey(pred, key.model) };
}),
},
},
};
}
return key;
return { ...key };
});
}

Expand Down Expand Up @@ -71,8 +87,7 @@ export async function getMetricsForSlices(
metricKeys = metricKeys.map((k) => ({ ...k, model: "" }));
}
// Update model in predicates if slices are dependent on postdistill or output columns.
metricKeys = setModelForMetricKeys(metricKeys);

metricKeys = <MetricKey[]>setModelForMetricKeys(metricKeys);
if (metricKeys.length > 0) {
return await ZenoService.getMetricsForSlices({
metricKeys,
Expand All @@ -97,7 +112,7 @@ export async function getMetricsForSlicesAndTags(
metricKeys = metricKeys.map((k) => ({ ...k, model: "" }));
}
// Update model in predicates if slices are dependent on postdistill columns.
metricKeys = setModelForMetricKeys(metricKeys);
metricKeys = <MetricKey[]>setModelForMetricKeys(metricKeys);
if (metricKeys.length > 0) {
return await ZenoService.getMetricsForSlicesAndTags({
metricKeys,
Expand Down

0 comments on commit 60baffe

Please sign in to comment.