[OPIK-4931] [BE] Add project_name resolution for Dataset, Dashboard, and Prompt#5683
Conversation
Add nullable project_id column with FK constraint to datasets, prompts, and dashboards tables. Wire project_id through all layers (DAO, Service, Resource) for create, findByName with fallback, and list/find filtering. Include integration tests for project-scoped CRUD and filtering. Resolves: OPIK-4931, OPIK-4934, OPIK-4935, OPIK-4936
Extract buildDataset/buildDatasetList/buildPrompt into DatasetResourceClient and PromptResourceClient to eliminate duplicated manufacturePojo patterns across 19 test files.
- Merge duplicate DAO findByName methods using ST templates - Simplify service findByName with fallback logic - Remove FK constraints, add service-level project validation via ProjectService - Add composite indexes (workspace_id, project_id) on datasets, prompts, dashboards - Fix leftover 2-param findByName call in DatasetService.getOrCreate
Use buildDataset() helper which nulls out projectId to avoid 409 Conflict from validateProjectIdExists on random UUIDs.
…and Prompt Allow users to provide project_name as an alternative to project_id when creating datasets, dashboards, and prompts. If project_name is provided but the project doesn't exist, it is automatically created via getOrCreate.
Backend Tests - Integration Group 15191 tests +3 189 ✅ +1 2m 15s ⏱️ -14s Results for commit f93505c. ± Comparison against base commit c76a15d. This pull request removes 63 and adds 66 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
Backend Tests - Integration Group 11166 tests +6 164 ✅ +6 2m 15s ⏱️ -10s Results for commit f93505c. ± Comparison against base commit c76a15d. This pull request removes 31 and adds 37 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
Backend Tests - Integration Group 7240 tests - 4 239 ✅ - 5 2m 16s ⏱️ +9s Results for commit f93505c. ± Comparison against base commit c76a15d. This pull request removes 10 and adds 6 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
Backend Tests - Integration Group 8287 tests +16 287 ✅ +17 4m 40s ⏱️ +4s Results for commit f93505c. ± Comparison against base commit c76a15d. This pull request removes 3 and adds 19 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
Backend Tests - Integration Group 16 28 files ±0 28 suites ±0 3m 16s ⏱️ -22s Results for commit f93505c. ± Comparison against base commit c76a15d. This pull request removes 2 and adds 2 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
Backend Tests - Integration Group 61 135 tests +3 1 135 ✅ +3 6m 3s ⏱️ +23s Results for commit f93505c. ± Comparison against base commit c76a15d. This pull request removes 13 and adds 16 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
Backend Tests - Integration Group 12159 tests - 31 159 ✅ - 31 6m 29s ⏱️ + 3m 5s Results for commit f93505c. ± Comparison against base commit c76a15d. This pull request removes 44 and adds 13 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
Backend Tests - Integration Group 10 25 files + 3 25 suites +3 3m 57s ⏱️ - 5m 38s Results for commit f93505c. ± Comparison against base commit c76a15d. This pull request removes 79 and adds 90 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
Adds Swagger documentation to the projectName field on Dataset, Dashboard, and Prompt API models so users understand the project resolution behavior.
apps/opik-backend/src/main/java/com/comet/opik/domain/PromptService.java
Show resolved
Hide resolved
apps/opik-backend/src/main/java/com/comet/opik/domain/DatasetService.java
Outdated
Show resolved
Hide resolved
apps/opik-backend/src/main/java/com/comet/opik/domain/DashboardService.java
Show resolved
Hide resolved
.../opik-backend/src/test/java/com/comet/opik/api/resources/v1/priv/DashboardsResourceTest.java
Show resolved
Hide resolved
Python SDK E2E Tests Results (Python 3.12)244 tests ±0 242 ✅ ±0 8m 25s ⏱️ -44s Results for commit f93505c. ± Comparison against base commit c76a15d. This pull request removes 1 and adds 1 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
Python SDK E2E Tests Results (Python 3.11)244 tests ±0 242 ✅ ±0 8m 45s ⏱️ -12s Results for commit f93505c. ± Comparison against base commit c76a15d. This pull request removes 1 and adds 1 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
Python SDK E2E Tests Results (Python 3.13)244 tests ±0 242 ✅ ±0 8m 28s ⏱️ - 1m 3s Results for commit f93505c. ± Comparison against base commit c76a15d. This pull request removes 1 and adds 1 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
Python SDK E2E Tests Results (Python 3.14)244 tests ±0 242 ✅ ±0 8m 28s ⏱️ -48s Results for commit f93505c. ± Comparison against base commit c76a15d. This pull request removes 1 and adds 1 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
000056 is already taken by drop_dashboard_name_uniqueness on main.
Python SDK E2E Tests Results (Python 3.10)244 tests ±0 242 ✅ ±0 8m 40s ⏱️ -27s Results for commit f93505c. ± Comparison against base commit c76a15d. This pull request removes 1 and adds 1 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
…to thiaghora/OPIK-4931-add-project-name-resolution
Ensures projectName is nulled out when building test datasets, preventing unintended project creation via project name resolution.
…ps://github.com/comet-ml/opik into thiaghora/OPIK-4931-add-project-name-resolution
apps/opik-backend/src/main/java/com/comet/opik/domain/ProjectService.java
Outdated
Show resolved
Hide resolved
andrescrz
left a comment
There was a problem hiding this comment.
This is fine to go, but I highly recommend following up to avoid unnecessary reactive blockers on next PRs.
apps/opik-backend/src/main/java/com/comet/opik/domain/DashboardService.java
Outdated
Show resolved
Hide resolved
apps/opik-backend/src/main/java/com/comet/opik/domain/DashboardService.java
Show resolved
Hide resolved
apps/opik-backend/src/main/java/com/comet/opik/api/Dashboard.java
Outdated
Show resolved
Hide resolved
… project, consolidate test builders
Details
Add
project_nameas an optional write-only field on Dataset, Dashboard, and Prompt APIs.When
project_nameis provided andproject_idis null, the service layer resolves it viaProjectService.getOrCreate()— finding the existing project or creating a new one. This lets users reference projects by name without needing to know the UUID.Change checklist
Issues
Testing
Commands run:
mvn test -Dtest="DashboardsResourceTest$ProjectScopedDashboards"— 5 tests passmvn test -Dtest="DatasetsResourceTest$ProjectScopedDatasets"— 5 tests passmvn test -Dtest="PromptResourceTest$ProjectScopedPrompts"— 5 tests passScenarios validated:
project_nameof an existing project → resolves to correctproject_idproject_nameof a non-existing project → project auto-created,project_idsetproject_idstill pass unchangedEnvironment: local process mode, macOS
Documentation