Skip to content
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

Merged
merged 4 commits into from
Sep 10, 2024

Conversation

jwlee64
Copy link
Contributor

@jwlee64 jwlee64 commented Sep 10, 2024

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?

@jwlee64 jwlee64 requested a review from a team as a code owner September 10, 2024 17:24
@circle-job-mirror
Copy link

circle-job-mirror bot commented Sep 10, 2024

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.")
Copy link
Collaborator

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.)

Copy link
Contributor Author

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

Copy link
Collaborator

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)

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:
Copy link
Collaborator

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

@@ -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():
Copy link
Collaborator

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."
          )

@jwlee64 jwlee64 merged commit 16f377f into master Sep 10, 2024
25 checks passed
@jwlee64 jwlee64 deleted the comment-netrc branch September 10, 2024 19:59
@github-actions github-actions bot locked and limited conversation to collaborators Sep 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants