-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(weave): change raise to print for netrc existing with api key #2341
Conversation
Preview this PR with FeatureBee: https://beta.wandb.ai/?betaVersion=1344f32c46dad0e96277e35566c7c003cfad1c8c |
weave/legacy/weave/environment.py
Outdated
raise errors.WeaveConfigurationError( | ||
"WANDB_API_KEY should not be set in both ~/.netrc and the environment." | ||
) | ||
print("WANDB_API_KEY should not be set in both ~/.netrc and the environment.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- If the contents are identical I think we could be silent.
- I'd change the message to explain a bit better. Maybe something like:
"There are different credentials in the netrc file and the environment. Using the environment value." - Not worth fixing but just noting that NETRC file might not be located at ~/.netrc (Windows, I think we might support the NETRC env var for alternate path, etc.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense
_wandb_api_key_via_netrc() -> i believe checks the windows location as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, just meant that on windows this message would have an incorrect path (~/.netrc
vs. ~/_netrc
)
weave/legacy/weave/environment.py
Outdated
if env_api_key and netrc_api_key: | ||
raise errors.WeaveConfigurationError( | ||
"WANDB_API_KEY should not be set in both ~/.netrc and the environment." | ||
if env_api_key and netrc_api_key and env_api_key != netrc_api_key: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would still raise in production
weave/legacy/weave/environment.py
Outdated
@@ -250,10 +250,14 @@ def _wandb_api_key_via_netrc_file(filepath: str) -> typing.Optional[str]: | |||
def weave_wandb_api_key() -> typing.Optional[str]: | |||
env_api_key = _wandb_api_key_via_env() | |||
netrc_api_key = _wandb_api_key_via_netrc() | |||
if env_api_key and netrc_api_key: | |||
if env_api_key and netrc_api_key and wandb_production(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
if env_api_key and netrc_api_key:
if wandb_production():
raise errors.WeaveConfigurationError(
"WANDB_API_KEY should not be set in both ~/.netrc and the environment."
)
elif env_api_key != netrc_api_key:
print(
"There are different credentials in the netrc file and the environment. Using the environment value."
)
Description
Changes the reaction to netrc and apikey existing to a print and not a raise when not in prod
Testing
How was this PR tested?