发布

  • [OPIK-4938] [BE] Add project_name support to dataset, experiment and optimization write endpoints (#5772)

    frostbyte_neo 发布于 2026-03-23 14:14:33 +00:00

    • [OPIK-4938] [BE] Add project_name support to dataset, experiment and optimization endpoints
    • Add project_name field to DatasetItemBatch and propagate it through DatasetItemService to scope dataset items to a project
    • Resolve project_name to project_id in DatasetService and ExperimentService when creating datasets/experiments
    • Add project_id column to optimizations table via Liquibase migration (000073)
    • Expose project_id (read-only) and project_name (write-only) on Optimization model
    • Fix NullPointerException in OptimizationService when project_name is null by using AbstractMap.SimpleEntry instead of Map.entry
    • Add integration tests for project-scoped dataset creation in DatasetsResourceTest, ExperimentsResourceTest, and OptimizationsResourceTest
    • Revision 2: Add ProjectOptimizationsResource for project-scoped optimization listing

    • Revision 3: Add project_id filter to OptimizationsResource and integration tests for ProjectOptimizationsResource

    • [OPIK-4938] [BE] Fix DatasetItemBatch project resolution and centralize test factory calls

    Fix Reactor empty Mono bug in DatasetItemService.getDatasetId() where batches
    without projectId/projectName caused the flatMap to never execute (data loss).
    Added switchIfEmpty to handle the null-project case properly.

    Centralize factory.manufacturePojo(DatasetItemBatch.class) and
    factory.manufacturePojo(DatasetItem.class) calls in DatasetResourceClient
    to null out server-assigned fields (projectId, projectName, datasetId, etc.),
    preventing PODAM-generated random UUIDs from causing 404 errors in tests.

    • Revision 2: Address PR review comments
    • Rename migration 000073 → 000074 to avoid prefix conflict with main
    • Add trailing blank line to migration file per guidelines
    • Remove @RequiredPermissions(EXPERIMENT_VIEW) from ProjectOptimizationsResource.find()
      to match unrestricted access pattern of the global endpoint
    • Add dataset_name query param to ProjectOptimizationsResource.find()
      for parity with global /v1/private/optimizations endpoint
    • Fix @Schema description on DatasetItemBatch.projectId (was "dataset_name must be
      provided", now "project_name must be provided")
    • Use DatasetItemBatch builder instead of positional constructor in
      DatasetExportJobSubscriberResourceTest
    • Revision 3: Fix insertInvalidDatasetItemWorkspace test failure

    Use DatasetResourceClient helpers and null out datasetId to avoid PODAM
    generating random UUIDs that cause 404s in DatasetItemService resolution.

    • Revision 4: Simplify resolveProjectId in OptimizationService

    Inline context accesses inside fromCallable lambda, consistent with
    DatasetItemService.resolveProjectId pattern.

    • Revision 5: Support projectId on Optimization write + validate on upsert

    Remove READ_ONLY from Optimization.projectId so callers can pass it
    directly. Add a resolveProjectId branch that validates the provided
    projectId exists in the workspace before using it, mirroring the
    DatasetItemBatch projectId/projectName duality.

    • Revision 6: Clarify projectName/projectId as optional in DatasetItemBatch schema

    Both fields are optional (both null = no project scoping). Update @Schema
    descriptions to remove misleading "must be provided" language and describe
    precedence rules instead.

    • Revision 7: Extract resolveProjectIdOrCreate into ProjectService

    Both OptimizationService and ExperimentService had identical inline logic
    for resolving a project from (projectId, projectName): validate the id if
    provided, getOrCreate from the name otherwise, return empty if neither.

    The shared helper lives in ProjectService.resolveProjectIdOrCreate and uses
    deferContextual so callers no longer need to extract workspaceId/userName
    themselves. ExperimentService's logic is also aligned to projectId-first
    priority, consistent with OptimizationService and DatasetItemService.

    • Revision 8: Add OpenAPI schema descriptions for Optimization project_id/project_name

    Matches the existing descriptions on Experiment, making the auto-create
    and precedence semantics visible in the generated API docs.

    • [OPIK-4938] [BE] Fix trailing blank line in migration 000074
    下载附件