-
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
Merged
Merged
Changes from 13 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
ba7b5d6
raise ValueError on empty API key in write_key
dannygoldstein 289d0c3
add ctrl+c message
dannygoldstein 9b64506
Merge branch 'master' into api-key-hotfix
dannygoldstein 63aefc0
Merge branch 'master' into api-key-hotfix
dannygoldstein f10807b
remove anti-pattern: recursive exception handling
dannygoldstein b3d0afa
ensure correct behavior when we choose to run w&b in offline mode
dannygoldstein f65e94a
add test
dannygoldstein 967ab32
remove ipdb from requirements
dannygoldstein 9a5a940
rename test
dannygoldstein ff9ec91
run black
dannygoldstein c0bed2c
Merge branch 'master' into api-key-hotfix
dannygoldstein 0aeb43b
Merge branch 'master' into api-key-hotfix
dannygoldstein 28e8896
don't ask for another api key yet
dannygoldstein 019a057
remove else
dannygoldstein 28e2e93
Merge branch 'master' into api-key-hotfix
dannygoldstein File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -177,26 +177,27 @@ def update_session( | |
def _prompt_api_key(self) -> Tuple[Optional[str], ApiKeyStatus]: | ||
|
||
api = Api(self._settings) | ||
try: | ||
key = apikey.prompt_api_key( | ||
self._settings, | ||
api=api, | ||
no_offline=self._settings.force if self._settings else None, | ||
no_create=self._settings.force if self._settings else None, | ||
) | ||
except ValueError as e: | ||
# invalid key provided, try again | ||
wandb.termerror(e.args[0]) | ||
return self._prompt_api_key() | ||
|
||
except TimeoutError: | ||
wandb.termlog("W&B disabled due to login timeout.") | ||
return None, ApiKeyStatus.DISABLED | ||
if key is False: | ||
return None, ApiKeyStatus.NOTTY | ||
if not key: | ||
return None, ApiKeyStatus.OFFLINE | ||
return key, ApiKeyStatus.VALID | ||
while True: | ||
try: | ||
key = apikey.prompt_api_key( | ||
self._settings, | ||
api=api, | ||
no_offline=self._settings.force if self._settings else None, | ||
no_create=self._settings.force if self._settings else None, | ||
) | ||
except ValueError as e: | ||
# invalid key provided, try again | ||
wandb.termerror(e.args[0]) | ||
continue | ||
except TimeoutError: | ||
wandb.termlog("W&B disabled due to login timeout.") | ||
return None, ApiKeyStatus.DISABLED | ||
if key is False: | ||
return None, ApiKeyStatus.NOTTY | ||
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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. removed else |
||
|
||
def prompt_api_key(self): | ||
key, status = self._prompt_api_key() | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 ifkey 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).