ENG-3771: add lab project commands#677
Conversation
ac843d0 to
dbe9200
Compare
|
@mrmoxon thoughts on folding this into the setup flow? ie default = single project that shares name with workspace folder, overridable + switchable. a bit worried about abstraction creep, feels like we can have these coupled until users explicitly want to decouple |
Defo agree, am making the |
|
Addressed the setup-flow point: |
530dca9 to
38348e9
Compare
|
Rebased onto latest |
38348e9 to
db89b50
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit db89b50. Configure here.
| ) -> Optional[str]: | ||
| env_project_id = os.getenv(PROJECT_CONTEXT_ENV) | ||
| if env_project_id and env_project_id.strip(): | ||
| return env_project_id.strip() |
There was a problem hiding this comment.
Env override skips scope checks
Medium Severity
When PRIME_PROJECT_ID is set, get_active_project_id returns it immediately and never applies the same base_url and team_id checks used for .prime/lab/context.json. Training and eval commands can therefore attach to a project outside the current CLI account/team context.
Reviewed by Cursor Bugbot for commit db89b50. Configure here.
| if clear_project_context(): | ||
| console.print("[green]✓ Active project cleared[/green]") | ||
| else: | ||
| console.print("[yellow]No active project was set.[/yellow]") |
There was a problem hiding this comment.
Project clear ignores env override
Medium Severity
prime project clear only deletes the workspace context.json file. If PRIME_PROJECT_ID is set in the environment, get_active_project_id still resolves an active project, so runs and evals keep attaching by default after a “clear”.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit db89b50. Configure here.
| emit(f"Created Lab project {project.name} ({project.slug})\n") | ||
| except APIError as exc: | ||
| emit(f"Skipped Lab project setup because the Projects API request failed: {exc}\n") | ||
| emit("Run prime project create later to attach new Lab runs and evals by default.\n") |
There was a problem hiding this comment.
Re-setup recreates default project
Medium Severity
After prime project clear, a later prime lab setup with no --project always calls project create with the workspace default name instead of re-binding the existing project. A duplicate-name API error is caught and setup finishes with no active project and no recovery hint.
Reviewed by Cursor Bugbot for commit db89b50. Configure here.


Linear: ENG-3771
Summary
Adds Lab Project support to the Prime CLI and eval client so users can set up a projectized Lab workspace, create/select/clear/inspect/update projects, and attach artifacts to projects from the terminal.
UX
prime lab setupnow folds projects into the normal setup flow. When the user is authenticated and no active workspace project exists, setup creates a default project named after the workspace folder and makes it active in.prime/lab/context.json. Users can bind an existing project withprime lab setup --project <project-id-or-slug>, choose the generated project name withprime lab setup --project-name "Alphabet Sort Baselines", or keep setup local-only withprime lab setup --no-project. If the user is not authenticated or the Projects API is unavailable, local setup still succeeds and prints the follow-upprime project createpath.Projects remain compatible with existing Lab flows. Users who do not create or select a project can keep running
prime train,prime eval push, andprime eval runas they do today; without an active project, those commands run without project attachment. Once a workspace has an active project, new training runs and evaluations attach to it by default. Users can override that per command with--project <project-id-or-slug>or opt out explicitly with--no-project. Active project context is local to the workspace and ignored when the CLI team or API base URL does not match the current config.Active project context follows the active CLI account context. A personal CLI context can only set a personal project as active; a team CLI context can only set a project from that same team as active.
--team-idis still supported for explicit one-off team operations such as listing, showing, creating with--no-use, assigning, or removing, but it does not switch futureprime train/prime evalcommands into that team. Users should runprime switch <team-slug-or-id>or setPRIME_TEAM_ID=<team-id>before making a team project active.Active project lookup is anchored to the nearest Lab workspace marker, so nested paths such as
outputs/evals/...still resolve the workspace project, but nested Lab workspaces do not accidentally inherit a parent workspace's active project.A typical projectized workspace flow looks like:
For team-owned projects, switch to the team first so setup creates the default project in that team context:
Users can still switch projects with
prime project use <project-id>, stop default attachment withprime project clear, and organize existing artifacts withprime project assign/prime project removefor runs, evals, and adapters.Details
prime projectcommands for creating/listing/showing/using/checking current/clearing/updating/assigning/removing a project.prime lab setup, with--project,--project-name, and--no-projectcontrols.project current --output jsonstable if API detail fetch fails by returningproject: nulland separate cachedcontextmetadata.assign, and clear-or-specific removal viaremove.prime-evalsREADME.Not in this PR
prime project environments, is left for a follow-up backend-backed endpoint.Validation
uv run pytest packages/prime/tests/test_lab_setup.py -quv run pytest packages/prime/tests/test_lab_setup.py packages/prime/tests/test_projects_cli.py packages/prime/tests/test_eval_push.py packages/prime/tests/test_hosted_eval.py packages/prime/tests/test_rl_api.py -quv run pytest packages/prime/tests packages/prime-evals/tests -q(797 passed, 4 skipped)uv run ruff check packages/prime/src/prime_cli/lab_setup.py packages/prime/src/prime_cli/utils/projects.py packages/prime/src/prime_cli/commands/projects.py packages/prime/tests/test_lab_setup.pyuv run ruff format --check packages/prime/src/prime_cli/lab_setup.py packages/prime/src/prime_cli/utils/projects.py packages/prime/src/prime_cli/commands/projects.py packages/prime/tests/test_lab_setup.pyuv run ty check packages/prime/src packages/prime-evals/srcgit diff --check--team-id <team-id> --no-use, confirmed no context file was written, confirmed personal context rejectsproject use <team-project> --team-id <team-id>, then confirmed matchingPRIME_TEAM_ID=<team-id>allowsproject useand writes a team-scoped.prime/lab/context.json.Note
Medium Risk
Touches cross-cutting Lab flows (train, eval, setup) and remote project membership APIs; behavior changes when an active project exists, though
--no-projectpreserves prior opt-out.Overview
Introduces Lab Projects end-to-end: a new
prime projectcommand group, workspace-scoped active project context (.prime/lab/context.json+PRIME_PROJECT_ID), and default project creation/binding during authenticatedprime lab setup.Training & evals now attach to the active project by default.
prime train,prime eval push,prime eval run, and post-run hub upload accept--project/--no-project. The prime-evals client gainsproject_idon create/update (includingclear_projectvia nullproject_id).Artifact membership is wired through new API helpers: run and adapter project PATCH with add/remove/clear operations (optional adapter moves on runs), plus eval assign/clear via
prime project assign/remove. Team scope is enforced so only projects matching the current CLI account can become active.Docs and CI are updated (checkout/uv pins on test jobs; README project flows). Large test coverage for setup, CLI, eval push, hosted eval, and RL/adapter payloads.
Reviewed by Cursor Bugbot for commit db89b50. Bugbot is set up for automated code reviews on this repo. Configure here.