-
Notifications
You must be signed in to change notification settings - Fork 229
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
[Online Scoring] Automation Rules endpoints #945
Conversation
Data model, DAO, service layer and endpoints for Automation Rule Evaluators. I've started with a more complicated approach, but in the end decided for a much simpler one which hopefully is easy enough to extend later into non-evaluator automation rules. Also as we've decided for a non-validation approach in the code, we're just going with a text field. ## Issues OPIK-590 OPIK-591
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.
As discussed in the design, the rule, action and evaluator can be up to 3 different entities. Fine to go with an approach where they're all collapsed into 1 in order to deliver faster. However, this can make extendability for future requirements harder.
For this PR, focus on making the evaluator payload a polymorphic value, so we can define any type of evaluator (python, llm as a judge). The current code
field of type string
is a concerning implementation.
Then review a bit the paths of the new resource and adjust them.
Everything else is minor polishings. I didn't go in the tests deeply, as still commented out and because this is in-progress.
Thank you very much for putting this together and congrats for your first PR in Opik!
apps/opik-backend/src/main/java/com/comet/opik/api/AutomationRuleEvaluator.java
Outdated
Show resolved
Hide resolved
apps/opik-backend/src/main/java/com/comet/opik/api/AutomationRuleEvaluator.java
Outdated
Show resolved
Hide resolved
apps/opik-backend/src/main/java/com/comet/opik/api/AutomationRuleEvaluator.java
Outdated
Show resolved
Hide resolved
return new AutomationRuleEvaluator.AutomationRuleEvaluatorPage(page, 0, 0, List.of()); | ||
} | ||
} | ||
} |
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.
Minor: run spotless on your PRs, so code is automatically formatted.
This is a previous miss from our side, we need to automate this.
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.
New line in the end would be nice.
...end/src/main/java/com/comet/opik/api/resources/v1/priv/AutomationRuleEvaluatorsResource.java
Outdated
Show resolved
Hide resolved
apps/opik-backend/src/main/java/com/comet/opik/domain/AutomationRuleDAO.java
Outdated
Show resolved
Hide resolved
apps/opik-backend/src/main/java/com/comet/opik/domain/AutomationRuleService.java
Outdated
Show resolved
Hide resolved
apps/opik-backend/src/main/java/com/comet/opik/domain/AutomationRuleService.java
Outdated
Show resolved
Hide resolved
apps/opik-backend/src/main/java/com/comet/opik/domain/AutomationRuleService.java
Outdated
Show resolved
Hide resolved
...d/src/main/resources/liquibase/db-app-state/migrations/000008_add_automation_rule_tables.sql
Outdated
Show resolved
Hide resolved
…o be based in a sample
…rogramming in case the string changes.
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.
This is in better state, but let's keep polishing.
apps/opik-backend/src/main/java/com/comet/opik/api/AutomationRuleEvaluatorUpdate.java
Outdated
Show resolved
Hide resolved
...end/src/main/java/com/comet/opik/api/resources/v1/priv/AutomationRuleEvaluatorsResource.java
Outdated
Show resolved
Hide resolved
...end/src/main/java/com/comet/opik/api/resources/v1/priv/AutomationRuleEvaluatorsResource.java
Outdated
Show resolved
Hide resolved
...end/src/main/java/com/comet/opik/api/resources/v1/priv/AutomationRuleEvaluatorsResource.java
Outdated
Show resolved
Hide resolved
...d/src/main/resources/liquibase/db-app-state/migrations/000009_add_automation_rule_tables.sql
Outdated
Show resolved
Hide resolved
...d/src/main/resources/liquibase/db-app-state/migrations/000009_add_automation_rule_tables.sql
Outdated
Show resolved
Hide resolved
...d/src/main/resources/liquibase/db-app-state/migrations/000009_add_automation_rule_tables.sql
Outdated
Show resolved
Hide resolved
...d/src/main/resources/liquibase/db-app-state/migrations/000009_add_automation_rule_tables.sql
Show resolved
Hide resolved
apps/opik-backend/src/main/java/com/comet/opik/api/AutomationRuleEvaluator.java
Outdated
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.
Overall looks good, left some comments
apps/opik-backend/src/main/java/com/comet/opik/api/AutomationRuleEvaluator.java
Outdated
Show resolved
Hide resolved
apps/opik-backend/src/main/java/com/comet/opik/api/AutomationRule.java
Outdated
Show resolved
Hide resolved
apps/opik-backend/src/main/java/com/comet/opik/api/AutomationRuleEvaluatorUpdate.java
Outdated
Show resolved
Hide resolved
...end/src/main/java/com/comet/opik/api/resources/v1/priv/AutomationRuleEvaluatorsResource.java
Show resolved
Hide resolved
apps/opik-backend/src/main/java/com/comet/opik/domain/AutomationRuleEvaluatorService.java
Outdated
Show resolved
Hide resolved
apps/opik-backend/src/main/java/com/comet/opik/domain/AutomationRuleEvaluatorService.java
Outdated
Show resolved
Hide resolved
apps/opik-backend/src/main/java/com/comet/opik/domain/AutomationRuleEvaluatorService.java
Outdated
Show resolved
Hide resolved
|
||
|
||
@Override | ||
public void update(@NonNull UUID id, @NonNull UUID projectId, @NonNull String workspaceId, |
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.
For consistency it would be better to add logs to all methods. Or remove from all, if we could use logs from Resource class.
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.
adding log
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.
save and delete methods do not have logging
apps/opik-backend/src/main/java/com/comet/opik/domain/AutomationRuleEvaluatorService.java
Outdated
Show resolved
Hide resolved
…uleEvaluator.java Co-authored-by: BorisTkachenko <[email protected]>
apps/opik-backend/src/main/java/com/comet/opik/api/AutomationRuleEvaluator.java
Outdated
Show resolved
Hide resolved
return new AutomationRuleEvaluator.AutomationRuleEvaluatorPage(page, 0, 0, List.of()); | ||
} | ||
} | ||
} |
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.
New line in the end would be nice.
apps/opik-backend/src/main/java/com/comet/opik/api/AutomationRuleEvaluatorType.java
Outdated
Show resolved
Hide resolved
|
||
|
||
@Override | ||
public void update(@NonNull UUID id, @NonNull UUID projectId, @NonNull String workspaceId, |
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.
save and delete methods do not have logging
...src/test/java/com/comet/opik/api/resources/v1/priv/AutomationRuleEvaluatorsResourceTest.java
Outdated
Show resolved
Hide resolved
private UUID create(AutomationRuleEvaluator<?> evaluator, String apiKey, String workspaceName) { | ||
try (var actualResponse = client.target(URL_TEMPLATE.formatted(baseURI, evaluator.getProjectId())) | ||
.request() | ||
.accept(MediaType.APPLICATION_JSON_TYPE) | ||
.header(HttpHeaders.AUTHORIZATION, apiKey) | ||
.header(WORKSPACE_HEADER, workspaceName) | ||
.post(Entity.json(evaluator))) { | ||
|
||
assertThat(actualResponse.getStatusInfo().getStatusCode()).isEqualTo(201); | ||
|
||
return TestUtils.getIdFromLocation(actualResponse.getLocation()); | ||
} |
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.
Please move it to test client (ex. TraceResourceClient
), in case we need it in other tests. Now we have a lot of code duplication in tests, due to making such same calls in each test class.
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.
Looks good
Details
Data model, DAO, service layer and endpoints for Automation Rule Evaluators.
We're using a polymorphic type for the evaluator code, which at least for now for LLM-as-Judge, we will use a JsonNode type
Issues
OPIK-590
OPIK-591
Testing
Documentation