Skip to content

Commit

Permalink
Merge branch 'main' into revert_public_token_handling
Browse files Browse the repository at this point in the history
  • Loading branch information
nvoxland-al authored Jan 31, 2024
2 parents 38beab1 + 6d27f1b commit 9eedfd7
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 102 deletions.
6 changes: 5 additions & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ sphinx:
configuration: docs/source/conf.py

python:
install:
install:
- requirements: deeplake/requirements/docs.txt
- method: pip
path: .

formats:
- epub
- pdf
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ If you use Deep Lake in your research, please cite Activeloop using:
}
```


## Acknowledgment

This technology was inspired by our research work at Princeton University. We would like to thank William Silversmith @SeungLab for his awesome [cloud-volume](https://github.com/seung-lab/cloud-volume) tool.
39 changes: 14 additions & 25 deletions deeplake/api/tests/test_agreement.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import pytest
from io import StringIO
from contextlib import contextmanager
from click.testing import CliRunner
from deeplake.cli.auth import login, logout
from deeplake.client.client import DeepLakeBackendClient
from deeplake.util.exceptions import (
Expand All @@ -20,59 +19,49 @@ def replace_stdin(target):
sys.stdin = orig


def dont_agree(path):
def dont_agree(path, token: str):
"""Load the Deep Lake cloud dataset at path and simulate disagreeing to the terms of access."""

with pytest.raises(AgreementNotAcceptedError):
# this text can be anything except expected
with replace_stdin(StringIO("no, i don't agree!")):
deeplake.load(path)
deeplake.load(path, token=token)


def agree(path):
def agree(path, token: str):
"""Load the Deep Lake cloud dataset at path and simulate agreeing to the terms of access."""
dataset_name = path.split("/")[-1]
with replace_stdin(StringIO(dataset_name)):
ds = deeplake.load(path)
ds = deeplake.load(path, token=token)
ds.images[0].numpy()

# next load should work without agreeing
ds = deeplake.load(path)
ds = deeplake.load(path, token=token)
ds.images[0].numpy()


def reject(path):
client = DeepLakeBackendClient()
def reject(path, token: str):
client = DeepLakeBackendClient(token=token)
org_id, ds_name = path.split("/")[-2:]
client.reject_agreements(org_id, ds_name)


def test_agreement_logged_out(hub_cloud_dev_credentials):
runner = CliRunner()
runner.invoke(logout)
def test_agreement_logged_out():
path = "hub://activeloop/imagenet-test"
with pytest.raises(NotLoggedInAgreementError):
agree(path)
agree(path, token=None)


@pytest.mark.slow
@pytest.mark.flaky(reruns=3)
def test_agreement_logged_in(hub_cloud_dev_credentials):
runner = CliRunner()
username, password = hub_cloud_dev_credentials
runner.invoke(login, f"-u {username} -p {password}")
def test_agreement_logged_in(hub_cloud_dev_token):
path = "hub://activeloop/imagenet-test"
agree(path)
reject(path)
runner.invoke(logout)
agree(path, hub_cloud_dev_token)
reject(path, hub_cloud_dev_token)


@pytest.mark.flaky(reruns=3)
@pytest.mark.slow
def test_not_agreement_logged_in(hub_cloud_dev_credentials):
runner = CliRunner()
username, password = hub_cloud_dev_credentials
runner.invoke(login, f"-u {username} -p {password}")
def test_not_agreement_logged_in(hub_cloud_dev_token):
path = "hub://activeloop/imagenet-test"
dont_agree(path)
runner.invoke(logout)
dont_agree(path, hub_cloud_dev_token)
31 changes: 0 additions & 31 deletions deeplake/api/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2333,20 +2333,6 @@ def test_uneven_iteration(memory_ds):
np.testing.assert_equal(y, target_y)


def token_permission_error_check(
username,
password,
runner,
):
result = runner.invoke(login, f"-u {username} -p {password}")
with pytest.raises(TokenPermissionError):
deeplake.empty("hub://activeloop-test/sohas-weapons-train")

with pytest.raises(TokenPermissionError):
ds = deeplake.load("hub://activeloop/fake-path")
runner.invoke(logout)


def invalid_token_exception_check():
with pytest.raises(InvalidTokenException):
ds = deeplake.empty("hub://adilkhan/demo", token="invalid_token")
Expand All @@ -2371,23 +2357,6 @@ def dataset_handler_error_check(runner, username, password):
runner.invoke(logout)


@pytest.mark.slow
def test_hub_related_permission_exceptions(
hub_cloud_dev_credentials,
):
username, password = hub_cloud_dev_credentials
runner = CliRunner()

token_permission_error_check(
username,
password,
runner,
)
invalid_token_exception_check()
user_not_logged_in_exception_check(runner)
dataset_handler_error_check(runner, username, password)


def test_incompat_dtype_msg(local_ds, capsys):
local_ds.create_tensor("abc", dtype="uint32")
with pytest.raises(SampleAppendError):
Expand Down
20 changes: 0 additions & 20 deletions deeplake/api/tests/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,26 +62,6 @@ def test_dataset_empty_load():
assert len(ds_overwrite_empty.tensors) == 0


@pytest.mark.slow
def test_update_privacy(hub_cloud_ds):
assert not hub_cloud_ds.public
hub_cloud_ds.make_public()
assert hub_cloud_ds.public
hub_cloud_ds.make_private()
assert not hub_cloud_ds.public

runner = CliRunner()
runner.invoke(logout)
with pytest.raises(UserNotLoggedInException):
deeplake.dataset(hub_cloud_ds.path)

with pytest.raises(UserNotLoggedInException):
deeplake.load(hub_cloud_ds.path)

with pytest.raises(UserNotLoggedInException):
deeplake.empty(hub_cloud_ds.path)


def test_persistence_bug(local_ds_generator):
for tensor_name in ["abc", "abcd/defg"]:
ds = local_ds_generator()
Expand Down
25 changes: 0 additions & 25 deletions deeplake/client/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,6 @@ def test_client_utils():
assert read_token() is None


@pytest.mark.slow
@pytest.mark.parametrize("method", ["creds", "token"])
def test_client_workspace_organizations(
method, hub_cloud_dev_credentials, hub_cloud_dev_token
):
username, password = hub_cloud_dev_credentials
deeplake_client = DeepLakeBackendClient()

runner = CliRunner()
result = runner.invoke(logout)
assert result.exit_code == 0

assert deeplake_client.get_user_organizations() == ["public"]

if method == "creds":
runner.invoke(login, f"-u {username} -p {password}")
elif method == "token":
runner.invoke(login, f"-t {hub_cloud_dev_token}")

deeplake_client = DeepLakeBackendClient()
assert username in deeplake_client.get_user_organizations()

runner.invoke(logout)


def create_response(
job_id="6508464cd80cab681bfcfff3",
dataset_id="some_dataset_id",
Expand Down

0 comments on commit 9eedfd7

Please sign in to comment.