Skip to content

Commit 8386cb0

Browse files
authored
OPIK-2075: Remove project level implementation for thread inactive timeout (#2758)
* OPIK-2075: Remove project level implementation for thread inactive timeout * Remove tests
1 parent 3e0bf76 commit 8386cb0

File tree

8 files changed

+8
-467
lines changed

8 files changed

+8
-467
lines changed

apps/opik-backend/src/main/java/com/comet/opik/api/Project.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import com.fasterxml.jackson.databind.annotation.JsonNaming;
88
import io.swagger.v3.oas.annotations.media.Schema;
99
import jakarta.annotation.Nullable;
10-
import jakarta.validation.Valid;
1110
import jakarta.validation.constraints.NotBlank;
1211
import lombok.Builder;
1312

@@ -50,9 +49,7 @@ public record Project(
5049
@JsonView({
5150
Project.View.Detailed.class}) @Schema(accessMode = Schema.AccessMode.READ_ONLY) @Nullable Long guardrailsFailedCount,
5251
@JsonView({
53-
Project.View.Detailed.class}) @Schema(accessMode = Schema.AccessMode.READ_ONLY) @Nullable ErrorCountWithDeviation errorCount,
54-
@JsonView({Project.View.Public.class, Project.View.Detailed.class,
55-
View.Write.class}) @Nullable @Valid Configuration configuration){
52+
Project.View.Detailed.class}) @Schema(accessMode = Schema.AccessMode.READ_ONLY) @Nullable ErrorCountWithDeviation errorCount){
5653

5754
@Builder(toBuilder = true)
5855
@JsonIgnoreProperties(ignoreUnknown = true)

apps/opik-backend/src/main/java/com/comet/opik/api/resources/v1/priv/ProjectsResource.java

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
import jakarta.ws.rs.GET;
4141
import jakarta.ws.rs.PATCH;
4242
import jakarta.ws.rs.POST;
43-
import jakarta.ws.rs.PUT;
4443
import jakarta.ws.rs.Path;
4544
import jakarta.ws.rs.PathParam;
4645
import jakarta.ws.rs.Produces;
@@ -58,7 +57,6 @@
5857
import java.util.Optional;
5958
import java.util.UUID;
6059

61-
import static com.comet.opik.api.Project.Configuration;
6260
import static com.comet.opik.api.Project.ProjectPage;
6361
import static com.comet.opik.api.Project.View;
6462
import static com.comet.opik.domain.ProjectMetricsService.ERR_START_BEFORE_END;
@@ -302,25 +300,4 @@ public Response getProjectStats(
302300
return Response.ok().entity(projectStatisticsSummary).build();
303301
}
304302

305-
@PUT
306-
@Path("/{id}/configurations")
307-
@Operation(operationId = "upsertProjectConfigurations", summary = "Upsert project configurations", description = "Upsert project configurations", responses = {
308-
@ApiResponse(responseCode = "204", description = "No Content"),
309-
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(schema = @Schema(implementation = ErrorMessage.class))),
310-
@ApiResponse(responseCode = "422", description = "Unprocessable Content", content = @Content(schema = @Schema(implementation = ErrorMessage.class))),
311-
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(schema = @Schema(implementation = ErrorMessage.class)))
312-
})
313-
public Response upsertProjectConfigurations(
314-
@PathParam("id") UUID projectId,
315-
@RequestBody(content = @Content(schema = @Schema(implementation = Configuration.class))) @Valid Configuration configuration) {
316-
String workspaceId = requestContext.get().getWorkspaceId();
317-
318-
log.info("Setting project configuration for project '{}' on workspaceId '{}'", projectId, workspaceId);
319-
320-
projectService.updateConfiguration(projectId, configuration);
321-
322-
log.info("Set project configuration for project '{}' on workspaceId '{}'", projectId, workspaceId);
323-
324-
return Response.ok().build();
325-
}
326303
}

apps/opik-backend/src/main/java/com/comet/opik/domain/ProjectConfigDAO.java

Lines changed: 0 additions & 139 deletions
This file was deleted.

apps/opik-backend/src/main/java/com/comet/opik/domain/ProjectService.java

Lines changed: 2 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import org.jdbi.v3.core.statement.UnableToExecuteStatementException;
3434
import reactor.core.publisher.Mono;
3535
import reactor.core.scheduler.Schedulers;
36-
import reactor.util.context.Context;
3736
import ru.vyarus.guicey.jdbi3.tx.TransactionTemplate;
3837

3938
import java.sql.SQLIntegrityConstraintViolationException;
@@ -127,7 +126,6 @@ record ProjectRecordSet(List<Project> content, long total) {
127126
private final @NonNull TransactionTemplateAsync transactionTemplateAsync;
128127
private final @NonNull SortingFactoryProjects sortingFactory;
129128
private final @NonNull SortingQueryBuilder sortingQueryBuilder;
130-
private final @NonNull ProjectConfigDAO projectConfigDAO;
131129

132130
private NotFoundException createNotFoundError() {
133131
String message = "Project not found";
@@ -141,19 +139,8 @@ public Project create(@NonNull Project project) {
141139
UUID projectId = idGenerator.generateId();
142140
String userName = requestContext.get().getUserName();
143141
String workspaceId = requestContext.get().getWorkspaceId();
144-
Configuration configuration = project.configuration();
145142

146-
project = createProject(project, projectId, userName, workspaceId).toBuilder()
147-
.configuration(configuration)
148-
.build();
149-
150-
if (project.configuration() != null) {
151-
projectConfigDAO.upsertConfigurations(project)
152-
.contextWrite(ctx -> setContext(ctx, workspaceId, userName))
153-
.block();
154-
}
155-
156-
return project;
143+
return createProject(project, projectId, userName, workspaceId);
157144
}
158145

159146
private Project createProject(Project project, UUID projectId, String userName, String workspaceId) {
@@ -246,13 +233,8 @@ public Project get(@NonNull UUID id, @NonNull String workspaceId) {
246233
.nonTransaction(connection -> traceDAO.getLastUpdatedTraceAt(Set.of(id), workspaceId, connection))
247234
.block();
248235

249-
Configuration configuration = projectConfigDAO.getConfigurations(id)
250-
.contextWrite(ctx -> setContext(ctx, workspaceId, "unused")) // userName is not used in this context
251-
.block();
252-
253236
return project.toBuilder()
254237
.lastUpdatedTraceAt(lastUpdatedTraceAt.get(project.id()))
255-
.configuration(configuration)
256238
.build();
257239
}
258240

@@ -283,13 +265,7 @@ public void updateConfiguration(@NonNull UUID projectId, @NonNull Configuration
283265
String workspaceId = requestContext.get().getWorkspaceId();
284266
String userName = requestContext.get().getUserName();
285267

286-
Project project = get(projectId).toBuilder()
287-
.configuration(configuration)
288-
.build();
289-
290-
projectConfigDAO.upsertConfigurations(project)
291-
.contextWrite(ctx -> setContext(ctx, workspaceId, userName))
292-
.block();
268+
Project project = get(projectId);
293269
}
294270

295271
private ProjectStatsSummaryItem getStats(UUID projectId, Map<String, Object> projectStats) {
@@ -326,11 +302,6 @@ public void delete(@NonNull UUID id) {
326302
// Void return
327303
return null;
328304
});
329-
330-
projectConfigDAO.deleteConfigurationsByProjectId(List.of(id))
331-
.contextWrite(ctx -> ctx.put(RequestContext.USER_NAME, userName)
332-
.put(RequestContext.WORKSPACE_ID, workspaceId))
333-
.block();
334305
}
335306

336307
@Override
@@ -347,14 +318,6 @@ public void delete(Set<UUID> ids) {
347318
handle.attach(ProjectDAO.class).delete(ids, workspaceId);
348319
return null;
349320
});
350-
351-
projectConfigDAO.deleteConfigurationsByProjectId(List.copyOf(ids))
352-
.contextWrite(ctx -> setContext(ctx, workspaceId, userName))
353-
.block();
354-
}
355-
356-
private static Context setContext(Context ctx, String workspaceId, String userName) {
357-
return ctx.put(RequestContext.WORKSPACE_ID, workspaceId).put(RequestContext.USER_NAME, userName);
358321
}
359322

360323
@Override
@@ -363,7 +326,6 @@ public Page<Project> find(int page, int size, @NonNull ProjectCriteria criteria,
363326

364327
String workspaceId = requestContext.get().getWorkspaceId();
365328
Visibility visibility = requestContext.get().getVisibility();
366-
String userName = requestContext.get().getUserName();
367329

368330
if (!sortingFields.isEmpty() && sortingFields.getFirst().field().equals(SortableFields.LAST_UPDATED_TRACE_AT)) {
369331
return findWithLastTraceSorting(page, size, criteria, sortingFields.getFirst());
@@ -391,19 +353,12 @@ public Page<Project> find(int page, int size, @NonNull ProjectCriteria criteria,
391353
.nonTransaction(connection -> traceDAO.getLastUpdatedTraceAt(projectIds, workspaceId, connection))
392354
.block();
393355

394-
Map<UUID, Configuration> projectsConfigurations = projectConfigDAO
395-
.getConfigurationsByIds(projectRecordSet.content().stream().map(Project::id).collect(toSet()))
396-
.contextWrite(ctx -> setContext(ctx, workspaceId, userName))
397-
.block();
398-
399356
List<Project> projects = projectRecordSet.content()
400357
.stream()
401358
.map(project -> {
402359
Instant lastUpdatedTraceAt = projectLastUpdatedTraceAtMap.get(project.id());
403-
Configuration configuration = projectsConfigurations.get(project.id());
404360
return project.toBuilder()
405361
.lastUpdatedTraceAt(lastUpdatedTraceAt)
406-
.configuration(configuration)
407362
.build();
408363
})
409364
.toList();
@@ -481,17 +436,11 @@ private Page<Project> findWithLastTraceSorting(int page, int size, @NonNull Proj
481436
return repository.findByIds(new HashSet<>(finalIds), workspaceId);
482437
}).stream().collect(Collectors.toMap(Project::id, Function.identity()));
483438

484-
Map<UUID, Configuration> projectsConfigurations = projectConfigDAO
485-
.getConfigurationsByIds(allProjectIds)
486-
.contextWrite(ctx -> setContext(ctx, workspaceId, userName))
487-
.block();
488-
489439
// compose the final projects list by the correct order and add last trace to it
490440
List<Project> projects = finalIds.stream()
491441
.map(projectsById::get)
492442
.map(project -> project.toBuilder()
493443
.lastUpdatedTraceAt(projectLastUpdatedTraceAtMap.get(project.id()))
494-
.configuration(projectsConfigurations.get(project.id()))
495444
.build())
496445
.toList();
497446

@@ -585,10 +534,6 @@ public Project retrieveByName(@NonNull String projectName) {
585534
Map<UUID, Map<String, Object>> projectStats = getProjectStats(List.of(project.id()),
586535
workspaceId);
587536

588-
Configuration configuration = projectConfigDAO.getConfigurations(project.id())
589-
.contextWrite(ctx -> setContext(ctx, workspaceId, userName))
590-
.block();
591-
592537
return project.toBuilder()
593538
.lastUpdatedTraceAt(projectLastUpdatedTraceAtMap.get(project.id()))
594539
.feedbackScores(StatsMapper.getStatsFeedbackScores(projectStats.get(project.id())))
@@ -602,7 +547,6 @@ public Project retrieveByName(@NonNull String projectName) {
602547
.guardrailsFailedCount(
603548
StatsMapper.getStatsGuardrailsFailedCount(projectStats.get(project.id())))
604549
.errorCount(StatsMapper.getStatsErrorCount(projectStats.get(project.id())))
605-
.configuration(configuration)
606550
.build();
607551
})
608552
.orElseThrow(this::createNotFoundError);

0 commit comments

Comments
 (0)