function wandb.login()
Log into W&B. You generally don’t have to use this because most W&B methods that need authentication can log in implicitly. This is the programmatic counterpart to thewandb login CLI.
This updates global credentials for the session (affecting all wandb usage
in the current Python process after this call) and possibly the .netrc file.
If an identity token file is configured, like through the
WANDB_IDENTITY_TOKEN_FILE environment variable, then it is used for the
session (federated identity) and no API key is read or saved.
Otherwise, if an explicit API key is provided, it is used and written to
the system .netrc file. If no key is provided, but the session is already
authenticated, then the session key is used for verification (if verify
is True) and the .netrc file is not updated.
If none of the above is true, then this gets the API key from the first of:
- The WANDB_API_KEY environment variable
- The api_key setting in a system or workspace settings file
- The .netrc file (either ~/.netrc, ~/_netrc or the path specified by the NETRC environment variable)
- An interactive prompt (if available)
Args
str | None
The API key to use.
bool | None
If true, get the API key from an interactive prompt, skipping reading .netrc, environment variables, etc.
str | None
The W&B server URL to connect to.
bool | None
If true, disallows selecting offline mode in the interactive prompt.
int | None
Number of seconds to wait for user input in the interactive prompt. This can be used as a failsafe if an interactive prompt is incorrectly shown in a non-interactive environment.
bool
Verify the credentials with the W&B server and raise an AuthenticationError on failure. This works for API keys as well as identity tokens.
str | None
The referrer to use in the URL login request for analytics.
DoNotSet
No description provided.
Returns
bool: If key is configured.
Raises
AuthenticationError: If the credentials fail verification with the server.UsageError: Ifapi_keycannot be configured and no tty.