Skip to content

refactor: simplify Api._load_api_key#10927

Merged
timoffex merged 1 commit intomainfrom
timoffex/11-18-improved_api_login
Nov 19, 2025
Merged

refactor: simplify Api._load_api_key#10927
timoffex merged 1 commit intomainfrom
timoffex/11-18-improved_api_login

Conversation

@timoffex
Copy link
Copy Markdown
Contributor

@timoffex timoffex commented Nov 19, 2025

Updates _login to make it usable in Api._load_api_key and fixes a bug in _load_api_key.

Pulls out the _noop, _offline and wandb.run checks into the higher level wandb.login() (which is also called by the wandb login CLI). The _noop and _offline checks are already present in wandb.init() and the wandb.run check is not relevant there. The fact that Api._load_api_key doesn't work if the identity_token_file setting is set is the same as it was before.

_login is called by login() (which is called by the wandb login CLI), wandb.init(), Sweeps, and now Api._load_api_key(). The changes above shouldn't matter for Sweeps.

I recently refactored _load_api_key() to use the new auth methods in PR #10893 but in doing so introduced a subtle bug: if Api._load_api_key prompts for a key, that key is not saved in the session, and later calls to Api() will prompt again. I will add an auth method for this soon, but due to other obstacles, using _login is the cleaner refactoring path.

@timoffex timoffex changed the title improved api login refactor: simplify Api._load_api_key and InternalApi.api_key Nov 19, 2025
@codecov
Copy link
Copy Markdown

codecov bot commented Nov 19, 2025

Codecov Report

❌ Patch coverage is 66.66667% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
wandb/sdk/wandb_login.py 54.54% 5 Missing ⚠️
wandb/apis/public/api.py 85.71% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@timoffex timoffex changed the base branch from timoffex/11-17-anonymous_mode to graphite-base/10927 November 19, 2025 19:24
@timoffex timoffex force-pushed the timoffex/11-18-improved_api_login branch from 02d97d0 to dc72ae3 Compare November 19, 2025 19:33
@timoffex timoffex force-pushed the graphite-base/10927 branch from 12e2d50 to 9af185d Compare November 19, 2025 19:33
@graphite-app graphite-app bot changed the base branch from graphite-base/10927 to main November 19, 2025 19:34
@timoffex timoffex force-pushed the timoffex/11-18-improved_api_login branch 2 times, most recently from 0f0c7c4 to 9bc395e Compare November 19, 2025 21:30
@timoffex timoffex changed the title refactor: simplify Api._load_api_key and InternalApi.api_key refactor: simplify Api._load_api_key Nov 19, 2025
@timoffex timoffex force-pushed the timoffex/11-18-improved_api_login branch from 9bc395e to 0bdcc5f Compare November 19, 2025 21:42
@timoffex timoffex marked this pull request as ready for review November 19, 2025 22:01
@timoffex timoffex requested review from a team as code owners November 19, 2025 22:01
@timoffex timoffex force-pushed the timoffex/11-18-improved_api_login branch 2 times, most recently from 432af45 to 9523d09 Compare November 19, 2025 23:27
Copy link
Copy Markdown
Contributor Author

timoffex commented Nov 19, 2025

Merge activity

  • Nov 19, 11:28 PM UTC: Graphite rebased this pull request as part of a merge.
  • Nov 19, 11:36 PM UTC: Graphite rebased this pull request as part of a merge.
  • Nov 19, 11:40 PM UTC: Graphite rebased this pull request as part of a merge.
  • Nov 19, 11:46 PM UTC: Graphite rebased this pull request as part of a merge.
  • Nov 19, 11:53 PM UTC: @timoffex merged this pull request with Graphite.

@timoffex timoffex force-pushed the timoffex/11-18-improved_api_login branch from 9523d09 to 12d4a7d Compare November 19, 2025 23:28
@timoffex timoffex force-pushed the timoffex/11-18-improved_api_login branch 4 times, most recently from 8444cac to 12d4a7d Compare November 19, 2025 23:44
@timoffex timoffex force-pushed the timoffex/11-18-improved_api_login branch from 12d4a7d to b4d545e Compare November 19, 2025 23:45
@timoffex timoffex merged commit 826243c into main Nov 19, 2025
25 checks passed
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.

2 participants