-
[OPIK-6383] [BE][SDK] Fix empty trials in Optimization Studio Demo Template run (#6689)
发布于
2026-05-13 11:48:06 +00:00 - [OPIK-6383] [BE][SDK] propagate optimization project_name to Studio runner
Optimization Studio runs created against a project did not carry the
project context through to the Python optimizer, so trial experiments
landed in the default "Optimization" project. The Opik 2.0 UI filters
the run's experiments by the active projectId and therefore showed an
empty Trials tab.This change resolves the optimization's projectId to a projectName on
the BE before enqueueing the studio job, threads project_name through
OptimizationJobContext, and passes it to optimizer.optimize_prompt so
trial experiments inherit the same project as the optimization itself.Also exposes TOGGLE_OPTIMIZATION_STUDIO_ENABLED through the backend's
docker-compose env block so local setups can opt in without editing
yaml.Backward compatible: optimizations without projectId fall back to the
optimizer's existing project_name resolution (OPIK_PROJECT_NAME env
or "Optimization"); old payloads stay readable by the new context
because from_job_message uses explicit field mapping.Tests:
- New backend integration test parses the RQ job payload back into
OptimizationStudioJobMessage and asserts the whole record, ticket
reference OPIK-6383. - New python-backend unit tests cover OptimizationJobContext parsing
and run_optimization forwarding.
- Revision 2: narrow catch in resolveProjectNameForJob
Address baz-reviewer feedback: only the project-deleted race-case
should degrade to null. Any other exception from projectService.get
is genuinely unexpected and is allowed to propagate so it surfaces
in logs instead of being silently swallowed. Matches the project's
error_handling rule against bare catch (Exception).下载附件