Skip to content
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

Merged
merged 22 commits into from
Dec 23, 2024

Conversation

thiagohora
Copy link
Contributor

Details

Add project-level aggregations

Issues

OPIK-287

@thiagohora thiagohora force-pushed the thiagohora/OPIK-287_add_project_level_aggregations branch from 46b6d4f to fb94fbd Compare December 14, 2024 15:58
@thiagohora thiagohora marked this pull request as ready for review December 14, 2024 15:59
@thiagohora thiagohora requested a review from a team as a code owner December 14, 2024 15:59
Copy link
Contributor

@idoberko2 idoberko2 left a 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.

@idoberko2 idoberko2 requested review from a team and idoberko2 December 16, 2024 13:55
@idoberko2 idoberko2 force-pushed the thiagohora/OPIK-446_add_duration_metric branch 2 times, most recently from fc6bf7b to cb763b3 Compare December 18, 2024 11:43
Base automatically changed from thiagohora/OPIK-446_add_duration_metric to main December 18, 2024 14:01
@idoberko2 idoberko2 force-pushed the thiagohora/OPIK-287_add_project_level_aggregations branch from 8af27de to 7295cf4 Compare December 18, 2024 16:03
Copy link
Collaborator

@andrescrz andrescrz left a 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,
Copy link
Collaborator

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.

Copy link
Contributor

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:

return traces.stream()
.map(Trace::totalEstimatedCost)
.reduce(BigDecimal.ZERO, BigDecimal::add)
.divide(BigDecimal.valueOf(count), ValidationUtils.SCALE, RoundingMode.HALF_UP).doubleValue();

Copy link
Collaborator

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.

Copy link
Collaborator

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) {
Copy link
Collaborator

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.

Copy link
Contributor

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.

Copy link
Collaborator

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.

@idoberko2 idoberko2 requested a review from andrescrz December 23, 2024 09:16
Copy link
Collaborator

@andrescrz andrescrz left a 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,
Copy link
Collaborator

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) {
Copy link
Collaborator

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.

@idoberko2 idoberko2 merged commit d43c18f into main Dec 23, 2024
7 checks passed
@idoberko2 idoberko2 deleted the thiagohora/OPIK-287_add_project_level_aggregations branch December 23, 2024 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants