Skip to content

Commit

Permalink
apply spotless (#994)
Browse files Browse the repository at this point in the history
  • Loading branch information
idoberko2 authored Jan 8, 2025
1 parent 07e2953 commit b695293
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import java.util.UUID;

@Builder(toBuilder = true)
public record ExperimentItemSearchCriteria (
public record ExperimentItemSearchCriteria(
String experimentName,
Integer limit,
UUID lastRetrievedId,
boolean truncate
) {}
boolean truncate) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ public record ExperimentItemStreamRequest(
@NotBlank String experimentName,
@Min(1) @Max(2000) Integer limit,
UUID lastRetrievedId,
@Schema(description = "Truncate image included in either input, output or metadata", defaultValue = "true")
@DefaultValue("true") boolean truncate) {
@Schema(description = "Truncate image included in either input, output or metadata", defaultValue = "true") @DefaultValue("true") boolean truncate) {

@Override
public Integer limit() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ private Publisher<? extends Result> get(UUID id, Connection connection) {
return makeFluxContextAware(bindWorkspaceIdToFlux(statement));
}

public Flux<ExperimentItem> getItems(@NonNull Set<UUID> experimentIds, @NonNull ExperimentItemSearchCriteria criteria) {
public Flux<ExperimentItem> getItems(@NonNull Set<UUID> experimentIds,
@NonNull ExperimentItemSearchCriteria criteria) {
if (experimentIds.isEmpty()) {
log.info("Getting experiment items by empty experimentIds, limit '{}', lastRetrievedId '{}'",
criteria.limit(), criteria.lastRetrievedId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.comet.opik.api.Experiment;
import com.comet.opik.api.ExperimentItem;
import com.comet.opik.api.ExperimentItemSearchCriteria;
import com.comet.opik.api.ExperimentItemStreamRequest;
import com.comet.opik.infrastructure.auth.RequestContext;
import com.google.common.base.Preconditions;
import jakarta.inject.Inject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.SecretKeySpec;

import java.nio.charset.StandardCharsets;
import java.security.InvalidKeyException;
import java.security.Key;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.comet.opik.api.resources.utils;

import com.comet.opik.api.FeedbackScoreNames;
import com.comet.opik.api.ExperimentItem;
import com.comet.opik.api.FeedbackScoreNames;
import lombok.experimental.UtilityClass;

import java.util.List;
Expand All @@ -20,7 +20,8 @@ public static void assertFeedbackScoreNames(FeedbackScoreNames actual, List<Stri
.toList()).containsExactlyInAnyOrderElementsOf(expectedNames);
}

public static ExperimentItem assertFeedbackScoresIgnoredFieldsAndSetThemToNull(ExperimentItem actualExperimentItem, String user) {
public static ExperimentItem assertFeedbackScoresIgnoredFieldsAndSetThemToNull(ExperimentItem actualExperimentItem,
String user) {
if (actualExperimentItem.feedbackScores() == null) {
return actualExperimentItem;
}
Expand All @@ -38,8 +39,8 @@ public static ExperimentItem assertFeedbackScoresIgnoredFieldsAndSetThemToNull(E
.lastUpdatedBy(null)
.createdAt(null)
.lastUpdatedAt(null)
.build()
).toList())
.build())
.toList())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@
import static com.comet.opik.api.resources.utils.AssertionUtils.assertFeedbackScoresIgnoredFieldsAndSetThemToNull;
import static com.comet.opik.api.resources.utils.ClickHouseContainerUtils.DATABASE_NAME;
import static com.comet.opik.api.resources.utils.MigrationUtils.CLICKHOUSE_CHANGELOG_FILE;
import static com.comet.opik.api.resources.utils.TestHttpClientUtils.UNAUTHORIZED_RESPONSE;
import static com.comet.opik.api.resources.utils.WireMockUtils.WireMockRuntime;
import static com.comet.opik.infrastructure.auth.RequestContext.SESSION_COOKIE;
import static com.comet.opik.infrastructure.auth.RequestContext.WORKSPACE_HEADER;
import static com.comet.opik.api.resources.utils.TestHttpClientUtils.UNAUTHORIZED_RESPONSE;
import static com.comet.opik.infrastructure.db.TransactionTemplateAsync.WRITE;
import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
import static com.github.tomakehurst.wiremock.client.WireMock.matching;
Expand Down Expand Up @@ -3832,7 +3832,8 @@ void find() {
.containsExactlyElementsOf(expectedExperimentItems);

for (var j = 0; j < actualDatasetItem.experimentItems().size(); j++) {
var actualExperimentItem = assertFeedbackScoresIgnoredFieldsAndSetThemToNull(actualDatasetItem.experimentItems().get(j), USER);
var actualExperimentItem = assertFeedbackScoresIgnoredFieldsAndSetThemToNull(
actualDatasetItem.experimentItems().get(j), USER);
var expectedExperimentItem = expectedExperimentItems.get(j);

assertThat(actualExperimentItem.feedbackScores())
Expand Down Expand Up @@ -4841,7 +4842,8 @@ private void assertDatasetItemExperiments(DatasetItemPage actualPage, List<Datas
.ignoringFields(IGNORED_FIELDS_LIST)
.isEqualTo(experimentItems.get(i));

var actualFeedbackScores = assertFeedbackScoresIgnoredFieldsAndSetThemToNull(actualExperimentItems.getFirst(), USER).feedbackScores();
var actualFeedbackScores = assertFeedbackScoresIgnoredFieldsAndSetThemToNull(
actualExperimentItems.getFirst(), USER).feedbackScores();
assertThat(actualFeedbackScores).hasSize(1);

assertThat(actualFeedbackScores.getFirst())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@
import static com.comet.opik.api.resources.utils.MigrationUtils.CLICKHOUSE_CHANGELOG_FILE;
import static com.comet.opik.api.resources.utils.TestDropwizardAppExtensionUtils.AppContextConfig;
import static com.comet.opik.api.resources.utils.TestDropwizardAppExtensionUtils.newTestDropwizardAppExtension;
import static com.comet.opik.api.resources.utils.TestHttpClientUtils.UNAUTHORIZED_RESPONSE;
import static com.comet.opik.infrastructure.auth.RequestContext.SESSION_COOKIE;
import static com.comet.opik.infrastructure.auth.RequestContext.WORKSPACE_HEADER;
import static com.comet.opik.api.resources.utils.TestHttpClientUtils.UNAUTHORIZED_RESPONSE;
import static com.comet.opik.utils.ValidationUtils.SCALE;
import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
import static com.github.tomakehurst.wiremock.client.WireMock.matching;
Expand Down Expand Up @@ -2378,7 +2378,8 @@ void streamByExperimentName() {
var traceWithScores1 = createTraceWithScores(apiKey, workspaceName);
var traceWithScores2 = createTraceWithScores(apiKey, workspaceName);

var traceIdToScoresMap = Stream.concat(traceWithScores1.getRight().stream(), traceWithScores2.getRight().stream())
var traceIdToScoresMap = Stream
.concat(traceWithScores1.getRight().stream(), traceWithScores2.getRight().stream())
.collect(groupingBy(FeedbackScoreBatchItem::id));

// When storing the scores in batch, adding some more unrelated random ones
Expand All @@ -2405,13 +2406,15 @@ void streamByExperimentName() {
createAndAssert(experiment3, apiKey, workspaceName);

var experimentItems1 = PodamFactoryUtils.manufacturePojoList(podamFactory, ExperimentItem.class).stream()
.map(experimentItem -> experimentItem.toBuilder().experimentId(experiment1.id()).traceId(traceWithScores1.getLeft().id()).build())
.map(experimentItem -> experimentItem.toBuilder().experimentId(experiment1.id())
.traceId(traceWithScores1.getLeft().id()).build())
.collect(toUnmodifiableSet());
var createRequest1 = ExperimentItemsBatch.builder().experimentItems(experimentItems1).build();
createAndAssert(createRequest1, apiKey, workspaceName);

var experimentItems2 = PodamFactoryUtils.manufacturePojoList(podamFactory, ExperimentItem.class).stream()
.map(experimentItem -> experimentItem.toBuilder().experimentId(experiment2.id()).traceId(traceWithScores2.getLeft().id()).build())
.map(experimentItem -> experimentItem.toBuilder().experimentId(experiment2.id())
.traceId(traceWithScores2.getLeft().id()).build())
.collect(toUnmodifiableSet());
var createRequest2 = ExperimentItemsBatch.builder().experimentItems(experimentItems2).build();
createAndAssert(createRequest2, apiKey, workspaceName);
Expand All @@ -2434,14 +2437,16 @@ void streamByExperimentName() {
.map(experimentItem -> experimentItem.toBuilder()
.input(traceWithScores2.getLeft().input())
.output(traceWithScores2.getLeft().output())
.feedbackScores(traceWithScores2.getRight().stream().map(FeedbackScoreMapper.INSTANCE::toFeedbackScore).toList())
.feedbackScores(traceWithScores2.getRight().stream()
.map(FeedbackScoreMapper.INSTANCE::toFeedbackScore).toList())
.build())
.toList();
var expectedExperimentItems2 = expectedExperimentItems.subList(limit, size).stream()
.map(experimentItem -> experimentItem.toBuilder()
.input(traceWithScores1.getLeft().input())
.output(traceWithScores1.getLeft().output())
.feedbackScores(traceWithScores1.getRight().stream().map(FeedbackScoreMapper.INSTANCE::toFeedbackScore).toList())
.feedbackScores(traceWithScores1.getRight().stream()
.map(FeedbackScoreMapper.INSTANCE::toFeedbackScore).toList())
.build())
.toList();

Expand Down Expand Up @@ -2807,15 +2812,18 @@ private void assertIgnoredFields(
}
}

private void assertIgnoredFieldsFullContent(ExperimentItem actualExperimentItem, ExperimentItem expectedExperimentItem) {
private void assertIgnoredFieldsFullContent(ExperimentItem actualExperimentItem,
ExperimentItem expectedExperimentItem) {
assertIgnoredFields(actualExperimentItem, expectedExperimentItem, true);
}

private void assertIgnoredFieldsWithoutFeedbacks(ExperimentItem actualExperimentItem, ExperimentItem expectedExperimentItem) {
private void assertIgnoredFieldsWithoutFeedbacks(ExperimentItem actualExperimentItem,
ExperimentItem expectedExperimentItem) {
assertIgnoredFields(actualExperimentItem, expectedExperimentItem, false);
}

private void assertIgnoredFields(ExperimentItem actualExperimentItem, ExperimentItem expectedExperimentItem, boolean isFullContent) {
private void assertIgnoredFields(ExperimentItem actualExperimentItem, ExperimentItem expectedExperimentItem,
boolean isFullContent) {
assertThat(actualExperimentItem.createdAt()).isAfter(expectedExperimentItem.createdAt());
assertThat(actualExperimentItem.lastUpdatedAt()).isAfter(expectedExperimentItem.lastUpdatedAt());
assertThat(actualExperimentItem.createdBy()).isEqualTo(USER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@
import static com.comet.opik.api.FeedbackDefinition.CategoricalFeedbackDefinition.CategoricalFeedbackDetail;
import static com.comet.opik.api.FeedbackDefinition.FeedbackDefinitionPage;
import static com.comet.opik.api.FeedbackDefinition.NumericalFeedbackDefinition;
import static com.comet.opik.api.resources.utils.TestHttpClientUtils.UNAUTHORIZED_RESPONSE;
import static com.comet.opik.domain.FeedbackDefinitionModel.FeedbackType;
import static com.comet.opik.infrastructure.auth.RequestContext.SESSION_COOKIE;
import static com.comet.opik.infrastructure.auth.RequestContext.WORKSPACE_HEADER;
import static com.comet.opik.api.resources.utils.TestHttpClientUtils.UNAUTHORIZED_RESPONSE;
import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
import static com.github.tomakehurst.wiremock.client.WireMock.matching;
import static com.github.tomakehurst.wiremock.client.WireMock.matchingJsonPath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@

import static com.comet.opik.api.resources.utils.ClickHouseContainerUtils.DATABASE_NAME;
import static com.comet.opik.api.resources.utils.MigrationUtils.CLICKHOUSE_CHANGELOG_FILE;
import static com.comet.opik.api.resources.utils.TestHttpClientUtils.UNAUTHORIZED_RESPONSE;
import static com.comet.opik.infrastructure.auth.RequestContext.SESSION_COOKIE;
import static com.comet.opik.infrastructure.auth.RequestContext.WORKSPACE_HEADER;
import static com.comet.opik.api.resources.utils.TestHttpClientUtils.UNAUTHORIZED_RESPONSE;
import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
import static com.github.tomakehurst.wiremock.client.WireMock.matching;
import static com.github.tomakehurst.wiremock.client.WireMock.matchingJsonPath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@
import static com.comet.opik.api.resources.utils.AssertionUtils.assertFeedbackScoreNames;
import static com.comet.opik.api.resources.utils.ClickHouseContainerUtils.DATABASE_NAME;
import static com.comet.opik.api.resources.utils.MigrationUtils.CLICKHOUSE_CHANGELOG_FILE;
import static com.comet.opik.api.resources.utils.TestHttpClientUtils.UNAUTHORIZED_RESPONSE;
import static com.comet.opik.domain.ProjectService.DEFAULT_PROJECT;
import static com.comet.opik.infrastructure.auth.RequestContext.SESSION_COOKIE;
import static com.comet.opik.infrastructure.auth.RequestContext.WORKSPACE_HEADER;
import static com.comet.opik.api.resources.utils.TestHttpClientUtils.UNAUTHORIZED_RESPONSE;
import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
import static com.github.tomakehurst.wiremock.client.WireMock.matching;
import static com.github.tomakehurst.wiremock.client.WireMock.matchingJsonPath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@

import static com.comet.opik.api.resources.utils.ClickHouseContainerUtils.DATABASE_NAME;
import static com.comet.opik.api.resources.utils.MigrationUtils.CLICKHOUSE_CHANGELOG_FILE;
import static com.comet.opik.api.resources.utils.TestHttpClientUtils.UNAUTHORIZED_RESPONSE;
import static com.comet.opik.infrastructure.auth.RequestContext.SESSION_COOKIE;
import static com.comet.opik.infrastructure.auth.RequestContext.WORKSPACE_HEADER;
import static com.comet.opik.api.resources.utils.TestHttpClientUtils.UNAUTHORIZED_RESPONSE;
import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
import static com.github.tomakehurst.wiremock.client.WireMock.matching;
import static com.github.tomakehurst.wiremock.client.WireMock.matchingJsonPath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@
import static com.comet.opik.api.resources.utils.ClickHouseContainerUtils.DATABASE_NAME;
import static com.comet.opik.api.resources.utils.MigrationUtils.CLICKHOUSE_CHANGELOG_FILE;
import static com.comet.opik.api.resources.utils.StatsUtils.getProjectSpanStatItems;
import static com.comet.opik.api.resources.utils.TestHttpClientUtils.UNAUTHORIZED_RESPONSE;
import static com.comet.opik.domain.ProjectService.DEFAULT_PROJECT;
import static com.comet.opik.domain.SpanService.PROJECT_AND_WORKSPACE_NAME_MISMATCH;
import static com.comet.opik.infrastructure.auth.RequestContext.SESSION_COOKIE;
import static com.comet.opik.infrastructure.auth.RequestContext.WORKSPACE_HEADER;
import static com.comet.opik.api.resources.utils.TestHttpClientUtils.UNAUTHORIZED_RESPONSE;
import static com.comet.opik.utils.ValidationUtils.MAX_FEEDBACK_SCORE_VALUE;
import static com.comet.opik.utils.ValidationUtils.MIN_FEEDBACK_SCORE_VALUE;
import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@
import static com.comet.opik.api.resources.utils.ClickHouseContainerUtils.DATABASE_NAME;
import static com.comet.opik.api.resources.utils.MigrationUtils.CLICKHOUSE_CHANGELOG_FILE;
import static com.comet.opik.api.resources.utils.StatsUtils.getProjectTraceStatItems;
import static com.comet.opik.api.resources.utils.TestHttpClientUtils.UNAUTHORIZED_RESPONSE;
import static com.comet.opik.domain.ProjectService.DEFAULT_PROJECT;
import static com.comet.opik.domain.TraceService.PROJECT_NAME_AND_WORKSPACE_NAME_MISMATCH;
import static com.comet.opik.infrastructure.auth.RequestContext.SESSION_COOKIE;
import static com.comet.opik.infrastructure.auth.RequestContext.WORKSPACE_HEADER;
import static com.comet.opik.api.resources.utils.TestHttpClientUtils.UNAUTHORIZED_RESPONSE;
import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
import static com.github.tomakehurst.wiremock.client.WireMock.matching;
import static com.github.tomakehurst.wiremock.client.WireMock.matchingJsonPath;
Expand Down

0 comments on commit b695293

Please sign in to comment.