Skip to content

[ML-70351] [l] Resolve one profile across CLI and local agent - #694

Open
elainewang-db wants to merge 19 commits into
databricks:mainfrom
elainewang-db:ml-70351-profile-resolution
Open

elainewang-db wants to merge 19 commits into
databricks:mainfrom
elainewang-db:ml-70351-profile-resolution

Conversation

@elainewang-db

@elainewang-db elainewang-db commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

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 dev or deploy starts work. Addresses ML-70351.

Behavior

  • Profile order inside a project: -p, then the project's .env (the --source project's when given), then DATABRICKS_CONFIG_PROFILE, then SDK default authentication. Exported SDK credential variables keep their SDK precedence.
  • The profile is chosen once per command, before it runs, and the API client is built from that choice.
  • The CLI reads .env with python-dotenv, the same parser the agent uses, so both see the same profile.
  • init pins a profile in .env unless environment authentication is in use.
  • auth switch changes the project's profile, auth describe reports it, and auth login signs in. With no profile, auth login hands off to databricks auth login's picker. The old login and logout commands point to these.
  • dev and deploy fail fast with an auth login hint when the profile is unknown, signed out, or set to external-browser. They never open a browser.
  • Text output shows one workspace notice with the profile and the host actually used.

Code layout

  • projects/profiles.py: profile resolution and ~/.databrickscfg lookups.
  • projects/env_file.py: reads .env with dotenv and rewrites the profile line atomically.
  • services/workspace_auth.py: auth checks with a time limit, and error classification.
  • clients/databricks_cli.py: runs databricks auth login.
  • cli/auth.py: the auth commands. cli/app.py: chooses the profile per command, and the removed-command pointers.
  • presentation/profile.py: workspace notices and profile warnings.

Reading order
projects/profiles.py, then projects/env_file.py, services/workspace_auth.py, cli/app.py (CliContext.select_profile) and cli/auth.py, then cli/init.py, cli/dev.py and cli/deploy.py. Docs last.

Testing

  • Unit tests cover profile order, .env parsing and rewriting, auth-check classification, and the auth commands. Unit suite: 2331 passed. Functional smoke tests: 53 passed.
  • Local end-to-end tests on commit 3786c31: tests/functional/dev_runtime_test.py passed 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.
  • Isolated CLI journeys on the same commit passed: init pinned an explicit or SDK-default profile; environment credentials left .env absent; auth describe reported the selected workspace; trailing -p overrode it; auth switch persisted the new profile; and dev rejected an external-browser profile before agent startup with a login hint.
  • These current-head end-to-end runs were local. Live workspace deployment and invocation were not rerun without a test profile or App URL.
  • Live checks on ml and e2-dogfood before the latest changes:
    • Unknown or rejected profiles failed in about 1 second with the login hint.
    • dev served HTTP 200.
    • init sign-in worked.
    • init with token-only environment auth wrote no .env.

Reusing cached external-browser credentials (by @jamesbxwu) moves to a follow-up PR after this merges.

This pull request and its description were written by Isaac.

@elainewang-db
elainewang-db force-pushed the ml-70351-profile-resolution branch 21 times, most recently from 19b4d91 to 13efa11 Compare October 13, 2026 00:31
@elainewang-db
elainewang-db force-pushed the ml-70351-profile-resolution branch 2 times, most recently from ae65708 to 4e5e859 Compare October 13, 2026 17:02
@elainewang-db
elainewang-db requested a review from shivam5 October 13, 2026 17:10

@shivam5 shivam5 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@elainewang-db
elainewang-db force-pushed the ml-70351-profile-resolution branch 4 times, most recently from 1b635b8 to 6d359c2 Compare October 13, 2026 20:48
@elainewang-db
elainewang-db force-pushed the ml-70351-profile-resolution branch from d4ad79e to 664bac7 Compare October 15, 2026 17:33
@jamesbxwu jamesbxwu changed the title [ML-70351] Resolve one profile across CLI and local agent [ML-70351] [l] Resolve one profile across CLI and local agent Oct 15, 2026
elainewang-db and others added 11 commits October 20, 2026 19:05
…ce per command

Co-authored-by: Isaac <no-reply@databricks.com>
…lution

# Conflicts:
#	integrations/agentbricks/src/databricks_agentbricks/cli/app.py
#	integrations/agentbricks/src/databricks_agentbricks/services/dev_service.py
#	integrations/agentbricks/tests/functional/cli_smoke_test.py
#	integrations/agentbricks/tests/unit_tests/dev_test.py
…lution

# Conflicts:
#	integrations/agentbricks/src/databricks_agentbricks/cli/dev.py
#	integrations/agentbricks/src/databricks_agentbricks/cli/init.py
#	integrations/agentbricks/src/databricks_agentbricks/cli/tracing.py
#	integrations/agentbricks/src/databricks_agentbricks/services/dev_service.py
#	integrations/agentbricks/tests/unit_tests/dev_test.py
…change

Co-authored-by: Isaac <no-reply@databricks.com>
…i/auth.py

Co-authored-by: Isaac <no-reply@databricks.com>
…lution

# Conflicts:
#	integrations/agentbricks/cli.md
#	integrations/agentbricks/src/databricks_agentbricks/cli/deploy.py
#	integrations/agentbricks/src/databricks_agentbricks/cli/init.py
#	integrations/agentbricks/src/databricks_agentbricks/clients/apps_client.py
#	integrations/agentbricks/src/databricks_agentbricks/clients/databricks_cli.py
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
elainewang-db and others added 2 commits October 26, 2026 17:31
…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>
@elainewang-db
elainewang-db requested a review from shivam5 October 26, 2026 20:32
…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>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants