Skip to content

Commit

Permalink
NO-JIRA: Exclude Open API spec and code from pre-commit hooks (#748)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrescrz authored Nov 28, 2024
1 parent 9440771 commit ec20404
Show file tree
Hide file tree
Showing 28 changed files with 1,190 additions and 1,145 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# IntelliJ
.idea/
**/dependency-reduced-pom.xml
*.iml

# Maven
target/
Expand Down Expand Up @@ -47,6 +47,7 @@ __pycache__
pip-log.txt
.venv*
.ipynb_checkpoints
.python-version

# VS Code
.vscode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,8 @@ public Mono<Long> partialInsert(@NonNull UUID id, @NonNull UUID projectId, @NonN
.reduce(0L, Long::sum);
}

private Publisher<? extends Result> update(UUID id, SpanUpdate spanUpdate, Connection connection, Span existingSpan) {
private Publisher<? extends Result> update(UUID id, SpanUpdate spanUpdate, Connection connection,
Span existingSpan) {
if (spanUpdate.model() != null || spanUpdate.usage() != null) {
spanUpdate = spanUpdate.toBuilder()
.model(spanUpdate.model() != null ? spanUpdate.model() : existingSpan.model())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class DatasetsResourceIntegrationTest {
private static final DatasetItemService itemService = Mockito.mock(DatasetItemService.class);
private static final RequestContext requestContext = Mockito.mock(RequestContext.class);
private static final TimeBasedEpochGenerator timeBasedGenerator = Generators.timeBasedEpochGenerator();
public static final SortingFactoryDatasets sortingFactory = new SortingFactoryDatasets();
public static final SortingFactoryDatasets sortingFactory = new SortingFactoryDatasets();

private static final ResourceExtension EXT = ResourceExtension.builder()
.addResource(new DatasetsResource(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1685,7 +1685,8 @@ void getDatasets__whenFetchingAllDatasets__thenReturnDatasetsSortedByCreatedDate
@ParameterizedTest
@MethodSource("sortDirectionProvider")
@DisplayName("when fetching all datasets, then return datasets sorted by last_created_experiment_at")
void getDatasets__whenFetchingAllDatasets__thenReturnDatasetsSortedByLastCreatedExperimentAt(Direction requestDirection, Direction expectedDirection) {
void getDatasets__whenFetchingAllDatasets__thenReturnDatasetsSortedByLastCreatedExperimentAt(
Direction requestDirection, Direction expectedDirection) {
String workspaceName = UUID.randomUUID().toString();
String apiKey = UUID.randomUUID().toString();
String workspaceId = UUID.randomUUID().toString();
Expand Down Expand Up @@ -1719,7 +1720,7 @@ public static Stream<Arguments> sortDirectionProvider() {
}

private void requestAndAssertDatasetsSorting(String workspaceName, String apiKey, List<Dataset> allDatasets,
Direction request, Direction expected) {
Direction request, Direction expected) {
var sorting = List.of(SortingField.builder()
.field(SortableFields.LAST_CREATED_EXPERIMENT_AT)
.direction(request)
Expand All @@ -1745,7 +1746,8 @@ private void requestAndAssertDatasetsSorting(String workspaceName, String apiKey
allDatasets = allDatasets.reversed();
}

assertThat(actualEntity.content()).usingRecursiveFieldByFieldElementComparatorIgnoringFields(DATASET_IGNORED_FIELDS)
assertThat(actualEntity.content())
.usingRecursiveFieldByFieldElementComparatorIgnoringFields(DATASET_IGNORED_FIELDS)
.containsExactlyElementsOf(allDatasets);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3781,8 +3781,10 @@ void update__whenCostIsChanged__thenAcceptUpdate(SpanUpdate expectedSpanUpdate)
var expectedSpanBuilder = expectedSpan.toBuilder();
SpanMapper.INSTANCE.updateSpanBuilder(expectedSpanBuilder, expectedSpanUpdate);
var actualSpan = getAndAssert(expectedSpanBuilder.build(), API_KEY, TEST_WORKSPACE);
BigDecimal expectedCost = ModelPrice.fromString(expectedSpanUpdate.model() != null ? expectedSpanUpdate.model() : expectedSpan.model())
.calculateCost(expectedSpanUpdate.usage() != null ? expectedSpanUpdate.usage() : expectedSpan.usage());
BigDecimal expectedCost = ModelPrice
.fromString(expectedSpanUpdate.model() != null ? expectedSpanUpdate.model() : expectedSpan.model())
.calculateCost(
expectedSpanUpdate.usage() != null ? expectedSpanUpdate.usage() : expectedSpan.usage());
assertThat(actualSpan.totalEstimatedCost())
.usingRecursiveComparison(RecursiveComparisonConfiguration.builder()
.withComparatorForType(BigDecimal::compareTo, BigDecimal.class)
Expand All @@ -3793,8 +3795,10 @@ void update__whenCostIsChanged__thenAcceptUpdate(SpanUpdate expectedSpanUpdate)
Stream<SpanUpdate> update__whenCostIsChanged__thenAcceptUpdate() {
return Stream.of(
SpanUpdate.builder().model("gpt-4o-2024-05-13").build(),
SpanUpdate.builder().usage(Map.of("completion_tokens", Math.abs(podamFactory.manufacturePojo(Integer.class)),
"prompt_tokens", Math.abs(podamFactory.manufacturePojo(Integer.class)))).build(),
SpanUpdate.builder()
.usage(Map.of("completion_tokens", Math.abs(podamFactory.manufacturePojo(Integer.class)),
"prompt_tokens", Math.abs(podamFactory.manufacturePojo(Integer.class))))
.build(),
SpanUpdate.builder().model("gpt-4o-2024-05-13")
.usage(Map.of("completion_tokens", Math.abs(podamFactory.manufacturePojo(Integer.class)),
"prompt_tokens", Math.abs(podamFactory.manufacturePojo(Integer.class))))
Expand Down
2 changes: 1 addition & 1 deletion apps/opik-documentation/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repos:
args:
- --print-width=120
files: ^apps/opik-documentation
exclude: "^(apps/opik-documentation/documentation/docs/reference)|(apps/opik-documentation/documentation/docs/cookbook/)"
exclude: "^(apps/opik-documentation/documentation/docs/reference)|(apps/opik-documentation/documentation/docs/cookbook/)|(apps/opik-documentation/documentation/rest_api/opik.yaml)"

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.9
Expand Down
Loading

0 comments on commit ec20404

Please sign in to comment.