Add utils.ops and nn.modules to tests (#4484)
This commit is contained in:
parent
1cec0185a1
commit
6da8f7f51e
14 changed files with 246 additions and 330 deletions
|
|
@ -73,8 +73,7 @@ class Auth:
|
|||
bool: True if authentication is successful, False otherwise.
|
||||
"""
|
||||
try:
|
||||
header = self.get_auth_header()
|
||||
if header:
|
||||
if header := self.get_auth_header():
|
||||
r = requests.post(f'{HUB_API_ROOT}/v1/auth', headers=header)
|
||||
if not r.json().get('success', False):
|
||||
raise ConnectionError('Unable to authenticate.')
|
||||
|
|
@ -117,23 +116,4 @@ class Auth:
|
|||
return {'authorization': f'Bearer {self.id_token}'}
|
||||
elif self.api_key:
|
||||
return {'x-api-key': self.api_key}
|
||||
else:
|
||||
return None
|
||||
|
||||
def get_state(self) -> bool:
|
||||
"""
|
||||
Get the authentication state.
|
||||
|
||||
Returns:
|
||||
bool: True if either id_token or API key is set, False otherwise.
|
||||
"""
|
||||
return self.id_token or self.api_key
|
||||
|
||||
def set_api_key(self, key: str):
|
||||
"""
|
||||
Set the API key for authentication.
|
||||
|
||||
Args:
|
||||
key (str): The API key string.
|
||||
"""
|
||||
self.api_key = key
|
||||
# else returns None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue