forked from activeloopai/deeplake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conftest.py
95 lines (78 loc) · 2.93 KB
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import os
import logging
# Disable crash reporting before running tests
# This MUST come before hub imports to bypass import publication.
os.environ["BUGGER_OFF"] = "true"
os.environ["DEEPLAKE_DOWNLOAD_PATH"] = "./testing/local_storage"
os.environ["DEEPLAKE_PYTEST_ENABLED"] = "true"
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "2"
logging.disable(logging.INFO)
from deeplake.core.lock import _LOCKS, _REFS
# Use staging environment for tests.
import deeplake.client.config
deeplake.client.config.USE_STAGING_ENVIRONMENT = True
from deeplake.constants import *
from deeplake.tests.common import SESSION_ID
# import * so all fixtures can be used accross the project
from deeplake.tests.path_fixtures import *
from deeplake.tests.dataset_fixtures import *
from deeplake.tests.storage_fixtures import *
from deeplake.tests.cache_fixtures import *
from deeplake.tests.client_fixtures import *
import pytest
def pytest_addoption(parser):
parser.addoption(
MEMORY_OPT, action="store_true", help="Memory tests will be SKIPPED if enabled."
)
parser.addoption(
LOCAL_OPT, action="store_true", help="Local tests will run if enabled."
)
parser.addoption(S3_OPT, action="store_true", help="S3 tests will run if enabled.")
parser.addoption(
GCS_OPT, action="store_true", help="GCS tests will run if enabled."
)
parser.addoption(
AZURE_OPT, action="store_true", help="Azure tests will run if enabled."
)
parser.addoption(
GDRIVE_OPT, action="store_true", help="Google Drive tests will run if enabled."
)
parser.addoption(
HUB_CLOUD_OPT,
action="store_true",
help="Deep Lake cloud tests will run if enabled.",
)
parser.addoption(
S3_PATH_OPT,
type=str,
help="Url to s3 bucket with optional key. Example: s3://bucket_name/key/to/tests/",
default=PYTEST_S3_PROVIDER_BASE_ROOT,
)
parser.addoption(
GDRIVE_PATH_OPT,
type=str,
help="Google drive folder id. Example: gdrive://folder_name/folder_name",
default=PYTEST_GDRIVE_PROVIDER_BASE_ROOT,
)
parser.addoption(
KEEP_STORAGE_OPT,
action="store_true",
help="All storage providers/datasets will have their pytest data wiped. \
Use this option to keep the data after the test run. Note: does not keep memory tests storage.",
)
parser.addoption(
KAGGLE_OPT, action="store_true", help="Kaggle tests will run if enabled."
)
def print_session_id():
print("\n\n----------------------------------------------------------")
print(f"Testing session ID: {SESSION_ID}")
print("----------------------------------------------------------")
print_session_id()
@pytest.fixture(scope="function", autouse=True)
def gc_lock_threads():
start_keys = set(_LOCKS.keys())
yield
end_keys = set(_LOCKS.keys())
for k in end_keys - start_keys:
_LOCKS.pop(k).release()
del _REFS[k]