-
Notifications
You must be signed in to change notification settings - Fork 691
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
[WB-6865] ensure captive key input even if user presses enter #2721
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2721 +/- ##
==========================================
+ Coverage 77.18% 77.19% +0.01%
==========================================
Files 178 178
Lines 26619 26622 +3
==========================================
+ Hits 20546 20551 +5
+ Misses 6073 6071 -2
Flags with carried forward coverage won't be shown. Click here to find out more.
|
I think there is a problem with the PR as the tests are failing. Also this pattern needs to be fixed (i think it came in the last PR in this area): in wandb_login.py:
recursive exception handling seems like something to avoid. |
Fixed this by explicitly handling
removed recursive exception handling and replaced with a loop |
added a test to improve coverage |
It goes through the "choices" flow again after pressing [enter] instead of the API key line. |
@vwrj I think going through the flow in this context again is fine, it's just a bit confusing given that the error message asks the user to immediately re-specify the API key. I updated the error message to not set that expectation. Aside from that I think the logic / flow of re-prompting for choices at that stage is ok |
23e4407
to
28e8896
Compare
wandb/sdk/wandb_login.py
Outdated
if not key: | ||
return None, ApiKeyStatus.OFFLINE | ||
else: | ||
return key, ApiKeyStatus.VALID |
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 think this was better the way it was... else is strange here and not needed
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.
removed else
@@ -200,7 +205,7 @@ def write_netrc(host, entity, key): | |||
|
|||
def write_key(settings, key, api=None, anonymous=False): | |||
if not key: | |||
return | |||
raise ValueError("No API key specified.") |
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.
as long as you have gone through all the paths that could call this and they make sense... raising a exception seems like a much better thing to do, im just worried there is some path that is calling this with an empty key and expects it to pass
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.
all the paths are guarded. there are 6 in the code:
configure_api_key()
in _WandbLogin()
which only is called if key is not None
,
and 5 in prompt_api_key
, which is called only in one place and in that one place has an exception handler (implemented in this PR).
https://wandb.atlassian.net/browse/WB-6865
Description
Before if someone did
wandb login --relogin
then hit enter without entering anything, the api key prompt would vanish and be a no-op:Now if you hit enter without entering anything, it will reprompt you for an API key, or tell you how to quit out and do a no-op:
Related
Testing
Manually
Release Notes
Below, please enter user-facing release notes as one or more bullet points.
If your change is not user-visible, write
NO RELEASE NOTES
instead, with no bullet points.------------- BEGIN RELEASE NOTES ------------------
Ensures API key prompt remains captive when user enters nothing
------------- END RELEASE NOTES --------------------