-
Notifications
You must be signed in to change notification settings - Fork 631
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure username is stored for use in commit messages (#2772)
Ensure username is stored for use in commit messages and other places, even if token was passed as an argument to deeplake
- Loading branch information
1 parent
914d802
commit d2e3f00
Showing
7 changed files
with
90 additions
and
10 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
import os | ||
|
||
import deeplake | ||
import jwt | ||
import pathlib | ||
import posixpath | ||
import warnings | ||
|
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 |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import os | ||
|
||
from deeplake.client.config import DEEPLAKE_AUTH_TOKEN | ||
from deeplake.core import LRUCache | ||
from deeplake.core.storage.memory import MemoryProvider | ||
|
||
from deeplake.core.dataset import Dataset | ||
|
||
|
||
def test_token_and_username(hub_cloud_dev_token): | ||
assert DEEPLAKE_AUTH_TOKEN not in os.environ | ||
|
||
ds = Dataset( | ||
storage=LRUCache( | ||
cache_storage=MemoryProvider(), cache_size=0, next_storage=MemoryProvider() | ||
) | ||
) | ||
assert ds.token is None | ||
assert ds.username == "public" | ||
|
||
# invalid tokens come through as "public" | ||
ds = Dataset( | ||
token="invalid_value", | ||
storage=LRUCache( | ||
cache_storage=MemoryProvider(), cache_size=0, next_storage=MemoryProvider() | ||
), | ||
) | ||
assert ds.token == "invalid_value" | ||
assert ds.username == "public" | ||
|
||
# valid tokens come through correctly | ||
ds = Dataset( | ||
token=hub_cloud_dev_token, | ||
storage=LRUCache( | ||
cache_storage=MemoryProvider(), cache_size=0, next_storage=MemoryProvider() | ||
), | ||
) | ||
assert ds.token == hub_cloud_dev_token | ||
assert ds.username == "testingacc2" | ||
|
||
# When env is set, it takes precedence over None for the token but not over a set token | ||
try: | ||
os.environ[DEEPLAKE_AUTH_TOKEN] = hub_cloud_dev_token | ||
ds = Dataset( | ||
storage=LRUCache( | ||
cache_storage=MemoryProvider(), | ||
cache_size=0, | ||
next_storage=MemoryProvider(), | ||
) | ||
) | ||
assert ds.token == hub_cloud_dev_token | ||
assert ds.username == "testingacc2" | ||
|
||
ds = Dataset( | ||
token="invalid_value", | ||
storage=LRUCache( | ||
cache_storage=MemoryProvider(), | ||
cache_size=0, | ||
next_storage=MemoryProvider(), | ||
), | ||
) | ||
assert ds.token == "invalid_value" | ||
assert ds.username == "public" | ||
|
||
finally: | ||
os.environ.pop(DEEPLAKE_AUTH_TOKEN) | ||
|
||
assert DEEPLAKE_AUTH_TOKEN not in os.environ |
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