Repository navigation
[ML-70351] [l] Resolve one profile across CLI and local agent - #694
elainewang-db wants to merge 24 commits into
Conversation
19b4d91 to
13efa11
Compare
ae65708 to
4e5e859
Compare
shivam5
left a comment
There was a problem hiding this comment.
agentbricks profile login --profile - this might sound weird
We could do what databricks cli does:
agentbricks auth describe/login/logout/profiles/switch
Can we quickly ask others for opinion on the rename in the channel?
1b635b8 to
6d359c2
Compare
Co-authored-by: Isaac <no-reply@databricks.com>
…lution # Conflicts: # integrations/agentbricks/src/databricks_agentbricks/cli/deploy.py # integrations/agentbricks/src/databricks_agentbricks/clients/apps_client.py # integrations/agentbricks/src/databricks_agentbricks/presentation/deploy.py # integrations/agentbricks/src/databricks_agentbricks/services/dev_service.py
…lution # Conflicts: # integrations/agentbricks/tests/unit_tests/models_cli_test.py
…as unreachable, and rewrite interpolated profiles on switch Co-authored-by: Isaac <no-reply@databricks.com>
…lution # Conflicts: # integrations/agentbricks/src/databricks_agentbricks/cli/app.py # integrations/agentbricks/src/databricks_agentbricks/cli/deploy.py
Resolve conflicts with databricks#785, databricks#809, databricks#812 and databricks#818: - cli/dev.py: announce the agent's profile, then databricks#812's "starting" line; the success panel still waits for the agent (on_ready). - clients/databricks_cli.py, presentation/dev.py: keep both sides (run_databricks_login and _run_until_ready; announce_agent_profile and announce_starting). - cli/endpoint.py: keep the workspace notice under databricks#785's renamed build_endpoint_service, and give `endpoint loadtest <app>` the same notice. - cli/app.py, cli.md: take databricks#818's --profile help. - cli/auth.py, presentation/help.py, cli.md: keep this branch's `auth login`/`auth switch`; drop databricks#818's edits to the removed `login`/`logout`. - tests/functional: accept databricks#809's deletion. - tests/unit_tests/cli_test.py: keep both assertions. Co-authored-by: Isaac <no-reply@databricks.com>
|
Automatic push review attempt 3/3 reserved. Failed attempts count toward this limit. After the limit, comment |
AgentBricksReviewerReview score: 61/100 · reviewers: 2/2 · Change risk: HIGH · SummaryBlocking issues
Non-blocking notes
Uncertain findings
Approach: The single resolved profile and lazy client provider are sound, but the implementation duplicates authentication and dotenv semantics at boundaries where consistency matters most. More in Details. RiskThis changes workspace targeting, credential resolution, authentication subprocesses, and persistent project AI approvalReview checks not passed; not eligible for auto-approval. To unblock:
Or ask a maintainer to approve. DetailsApproach: The single resolved profile and lazy client provider are sound, but the implementation duplicates authentication and dotenv semantics at boundaries where consistency matters most. Use one classification-to-error mapping for preflight and login, dotenv binding-aware updates for persistence, and a shared noninteractive-auth policy that also covers telemetry. These changes address the identified failures without expanding the command-wrapper machinery. Review rules: Diff size (computed): 44 files; +2730 / -487 lines (3217 changed text lines); 0 binary files.
ChangesThe intended outcome is consistent workspace selection across project commands and the local agent, with early authentication failures instead of unexpected consent flows. The diff includes profile resolution, dotenv persistence, authentication services and commands, local-runtime propagation, presentation changes, a declared dotenv dependency, documentation, and extensive test updates. There are no changed lockfile pins or generated assets. Most of the size supports that outcome. It could be reduced by retaining compatibility shims instead of removing established commands, consolidating duplicated authentication-error handling, and keeping detailed dotenv cases in the focused writer tests. The unchanged bundled workflow guidance was inspected and no obsolete login invocation was found. Please add the AGENTBRICKS-001 explanation for why its guidance needs no update. The generated-project TestsTest-by-test assessmentBoth reviewers performed static head-commit review. One also ran an isolated third-party dotenv parser experiment, without executing repository code. No head test suite, lint, typecheck, SDK authentication, or live workspace journey was executed; the PR’s reported pass counts remain author-provided evidence. “Component” below means local CLI/filesystem composition with external boundaries mocked.
Existing tests are useful but insufficient for the failures above. Each verified defect can be guarded at a local unit or component layer without live credentials. ScopeNo clearly unrelated change was found. Implementation, dependency, documentation, and test changes generally support the stated profile-consistency outcome. Removing legacy commands and abandoning saved selections are not necessary to achieve that outcome and introduce the compatibility breaks identified above. Automated review by AgentBricksReviewer for |
AgentBricksReviewerReview score: 75/100 · reviewers: 2/2 · Change risk: HIGH · SummaryBlocking issues
Non-blocking notes
Approach: The module separation is sound, but initialization should reuse the shared resolution policy and local startup should retain its credential-free path. More in Details. RiskThis changes credential/profile selection across CLI commands, local-agent startup, and deployment. It also persists workspace choices in project AI approvalReview checks not passed; not eligible for auto-approval. To unblock:
Or ask a maintainer to approve. DetailsApproach: The module separation is sound, but initialization should reuse the shared resolution policy and local startup should retain its credential-free path. Separating dotenv persistence, profile lookup, authentication, and presentation is reasonable. The main avoidable complexity is reconstructing profile fallback inside initialization and retaining duplicate authentication after introducing preflight validation. Review rules: Diff size (computed): 45 files; +2926 / -471 lines (3397 changed text lines); 0 binary files.
ChangesThe intended outcome is consistent workspace selection between project commands and the local agent, with actionable authentication failures before development or deployment starts. The diff includes profile resolution, atomic dotenv rewriting, authentication services and commands, runtime/client wiring, notices, documentation, dependency declarations, and unit-test adaptations. Most breadth is justified because the shared CLI context affects many commands. The change could be smaller by deferring the separate initialization-rerun behavior and consolidating duplicated resolution logic rather than maintaining two fallback policies. TestsTest-by-test assessmentBoth reviewers performed static review only. No tests, lint, type checks, or live-workspace operations were executed during this review; the PR description's reported results are not independently verified.
Existing tests provide substantial coverage, but do not suffice for the reported edge cases. In particular, the offline-development test's authentication stub hides a regression, and initialization needs tests for both fallback selection and its changed collision behavior. ScopeNo clearly unrelated changes were found. Authentication commands, dotenv persistence, client/runtime wiring, notices, documentation, and test adaptations support the stated outcome under BRIDGE-009. The initialization no-op behavior is adjacent but separable, and could be deferred to reduce compatibility impact. Automated review by AgentBricksReviewer for |
AgentBricksReviewerReview score: 74/100 · reviewers: 3/3 · Change risk: HIGH · SummaryBlocking issues
Non-blocking notes
Uncertain findings
Approach: Centralizing profile resolution and reusing validated clients is sound, but authentication gates need to preserve working cached and offline flows. More in Details. RiskThis changes credential selection and workspace targeting across CLI commands, adds authentication gates to local development and deployment, and persists profile choices in project AI approvalReview checks not passed; not eligible for auto-approval. To unblock:
Or ask a maintainer to approve. DetailsApproach: Centralizing profile resolution and reusing validated clients is sound, but authentication gates need to preserve working cached and offline flows. The shared dotenv parser and separated resolution, persistence, authentication, and presentation responsibilities are reasonable; no materially simpler existing repository pattern was identified. Review rules: Diff size (computed): 45 files; +2977 / -488 lines (3465 changed text lines); 0 binary files.
ChangesThe intended outcome is one consistent profile across project commands and the local agent, with actionable authentication failures before workspace-dependent work starts. The diff includes profile/config resolution, atomic dotenv rewriting, authentication services, CLI commands and wiring, client reuse, local-agent environment propagation, documentation, a python-dotenv dependency declaration, and updates to 18 test/support files. There are no lockfile changes. The breadth is largely justified by the cross-command behavior; no clearly unrelated feature was found. Shared notice/auth fixtures can keep mechanical test updates smaller, but resolution, persistence, and authentication should remain separately testable. Three reviewers delivered reports: one Claude reviewer and two Codex reviewers. Every lens was considered. Findings were checked against head source; review was otherwise static, except for the standalone dotenv-parser reproduction. TestsTest-by-test assessment
Existing tests cover substantial offline composition, but do not suffice for cached-browser compatibility, local-only development with unrelated ambient authentication, or child-CLI behavior. No tests, lint, or type checking were run during this review. Earlier results in the PR description are not independently verified evidence for this head. ScopeAll reviewed changes support profile alignment, authentication behavior, or their documentation and tests. No clearly unrelated changes were found. The bundled workflow guidance was inspected, and the description explains why no workflow-skill update is needed under AGENTBRICKS-001. Automated review by AgentBricksReviewer for |
Agent Bricks commands and the local agent could use different Databricks profiles, and unauthenticated workspace commands could hang on browser consent. This PR resolves one profile per project command, passes it to the local agent, and checks authentication before
devordeploystarts work. Addresses ML-70351.Behavior
-p, then the project's.env(the--sourceproject's when given), then a savedagentbricks logindefault, thenDATABRICKS_CONFIG_PROFILE, then SDK default authentication. Exported SDK credential variables keep their SDK precedence..envwith python-dotenv, the same parser the agent uses, so both see the same profile.initpins a profile in.envunless environment authentication is in use.auth switchchanges the project's profile,auth describereports it, andauth loginsigns in. With no profile,auth loginhands off todatabricks auth login's picker. The existingloginandlogoutcommands continue to save and clear the default profile.deployfails fast on invalid authentication.devdoes the same for scaffolded agents or explicitly selected project profiles, while local-only projects can run offline despite unrelated ambient workspace settings. Project.envcredentials take precedence over a stale child CLI profile.devanddeploydo not start browser consent for a rejectedexternal-browserprofile; legacylogincontinues to accept valid cached browser credentials.Code layout
projects/profiles.py: profile resolution and~/.databrickscfglookups.projects/env_file.py: reads.envwith dotenv and rewrites actual profile bindings atomically, preserving unrelated multiline values and rejecting names that change on readback.services/workspace_auth.py: auth checks with a time limit, and error classification.clients/databricks_cli.py: runsdatabricks auth login.cli/auth.py: theauthand compatiblelogin/logoutcommands.cli/app.py: chooses the profile per command.presentation/profile.py: workspace notices and profile warnings.Reading order
projects/profiles.py, thenprojects/env_file.py,services/workspace_auth.py,cli/app.py(CliContext.select_profile) andcli/auth.py, thencli/init.py,cli/dev.pyandcli/deploy.py. Docs last.Testing
54d5f4e, focused auth, dotenv, workspace auth, dev, deploy, CLI and telemetry tests passed: 466 passed. Ruff lint and format, and type checking of edited Python files passed. A real CLI journey confirmed that an interpolated profile name is rejected without changing.env. The full local suite stopped at a sandboxPermissionErrorwhen an unrelated test attempted to bind a loopback socket. Current-head CI passed 57/57 checks, including Agent Bricks unit tests on Python 3.10 and fake-workspace end-to-end suites on Ubuntu and macOS.3786c31:tests/functional/dev_runtime_test.pypassed 6/6. Fresh LangGraph and OpenAI projects booted and answered an invocation across the built-in server (with and without chat UI) and custom server, using a fake model-serving endpoint.initpinned an explicit or SDK-default profile; environment credentials left.envabsent;auth describereported the selected workspace; trailing-poverrode it;auth switchpersisted the new profile; anddevrejected anexternal-browserprofile before agent startup with a login hint.b359398, a CLI journey confirmed saved-profile selection,logout, and environment fallback. On6ed67d9, another CLI journey confirmed nestedinituses the saved profile and a secondinitfails without changing it. Live workspace deployment and invocation were not rerun without a test profile or App URL.mlande2-dogfoodbefore the latest changes:devserved HTTP 200.initsign-in worked.initwith token-only environment auth wrote no.env.The bundled agent workflow skill needs no change: it does not specify profile priority or legacy command behavior.
Legacy
loginretains cached external-browser credentials. Extending browser-cache probing to the noninteractivedevanddeploypreflight remains a separate follow-up.This pull request and its description were written by Isaac.