-
Notifications
You must be signed in to change notification settings - Fork 215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[OPIK-287] Add project level aggregations #894
[OPIK-287] Add project level aggregations #894
Conversation
46b6d4f
to
fb94fbd
Compare
apps/opik-backend/src/main/java/com/comet/opik/domain/ProjectService.java
Outdated
Show resolved
Hide resolved
...-backend/src/test/java/com/comet/opik/api/resources/utils/resources/TraceResourceClient.java
Outdated
Show resolved
Hide resolved
apps/opik-backend/src/test/java/com/comet/opik/api/resources/v1/priv/ProjectsResourceTest.java
Outdated
Show resolved
Hide resolved
apps/opik-backend/src/test/java/com/comet/opik/api/resources/v1/priv/ProjectsResourceTest.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments related to lastUpdatedTraceAt
logic. Other than that, LGTM.
fc6bf7b
to
cb763b3
Compare
This reverts commit d9a1f68.
8af27de
to
7295cf4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's double check the floating type for the total cost before moving forward with this PR.
@JsonView({ | ||
Project.View.Public.class}) @Schema(accessMode = Schema.AccessMode.READ_ONLY) @Nullable PercentageValues duration, | ||
@JsonView({ | ||
Project.View.Public.class}) @Schema(accessMode = Schema.AccessMode.READ_ONLY) @Nullable Double totalEstimatedCost, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Monetary cost as floating type. For other aggregations such as avg, it wouldn't be that bad. But for a total, I assume is a sum, better as BigDecimal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name is a bit misleading. This holds the average total cost of a trace in a project. This is calculated here:
avgIf(total_estimated_cost, total_estimated_cost > 0) AS total_estimated_cost_, |
In addition, you can see that the coverage for this logic asserts on an average:
opik/apps/opik-backend/src/test/java/com/comet/opik/api/resources/v1/priv/ProjectsResourceTest.java
Lines 1358 to 1361 in ab0f8bb
return traces.stream() | |
.map(Trace::totalEstimatedCost) | |
.reduce(BigDecimal.ZERO, BigDecimal::add) | |
.divide(BigDecimal.valueOf(count), ValidationUtils.SCALE, RoundingMode.HALF_UP).doubleValue(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you rename it to something more significative and less confusing then? e.g: avgTotalEstimatedCost
or similar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are arguable not clear names, in comparison with other aggregations such as lastUpdatedTraceAt
. On the other hand, List<FeedbackScoreAverage> feedbackScores,
already exists in Experiments
.
Not a blocker so far.
apps/opik-backend/src/main/java/com/comet/opik/domain/ProjectService.java
Outdated
Show resolved
Hide resolved
apps/opik-backend/src/main/java/com/comet/opik/domain/TraceDAO.java
Outdated
Show resolved
Hide resolved
apps/opik-backend/src/test/java/com/comet/opik/api/resources/utils/BigDecimalCollectors.java
Show resolved
Hide resolved
@@ -318,4 +319,50 @@ public static int bigDecimalComparator(BigDecimal v1, BigDecimal v2) { | |||
return strippedV1.toBigInteger().compareTo(strippedV2.toBigInteger()); | |||
} | |||
|
|||
public static int closeToEpsilonComparator(Object v1, Object v2) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most likely, we don't need this. There are assertJ assertions such as isCloseTo that allow different types of approximations e.g: based on percentage, boundaries etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I can't find a way to make it using assertj's isCloseTo
due to the recursive comparison. I can try to simplify closeToEpsilonComparator
's logic if you think it's worth it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's fine to keep this then, as it's just a test. We attempt to get rid of it later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just the debate on the names. Everything else is good to go.
@JsonView({ | ||
Project.View.Public.class}) @Schema(accessMode = Schema.AccessMode.READ_ONLY) @Nullable PercentageValues duration, | ||
@JsonView({ | ||
Project.View.Public.class}) @Schema(accessMode = Schema.AccessMode.READ_ONLY) @Nullable Double totalEstimatedCost, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are arguable not clear names, in comparison with other aggregations such as lastUpdatedTraceAt
. On the other hand, List<FeedbackScoreAverage> feedbackScores,
already exists in Experiments
.
Not a blocker so far.
@@ -318,4 +319,50 @@ public static int bigDecimalComparator(BigDecimal v1, BigDecimal v2) { | |||
return strippedV1.toBigInteger().compareTo(strippedV2.toBigInteger()); | |||
} | |||
|
|||
public static int closeToEpsilonComparator(Object v1, Object v2) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's fine to keep this then, as it's just a test. We attempt to get rid of it later.
Details
Add project-level aggregations
Issues
OPIK-287