lamindb_setup 0.77.4__py2.py3-none-any.whl → 0.77.6__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- lamindb_setup/__init__.py +1 -2
- lamindb_setup/_cache.py +34 -34
- lamindb_setup/_check.py +7 -7
- lamindb_setup/_check_setup.py +92 -79
- lamindb_setup/_close.py +35 -35
- lamindb_setup/_connect_instance.py +425 -444
- lamindb_setup/_django.py +41 -41
- lamindb_setup/_entry_points.py +22 -22
- lamindb_setup/_exportdb.py +68 -68
- lamindb_setup/_importdb.py +50 -50
- lamindb_setup/_init_instance.py +411 -374
- lamindb_setup/_migrate.py +239 -239
- lamindb_setup/_register_instance.py +36 -36
- lamindb_setup/_schema.py +27 -27
- lamindb_setup/_schema_metadata.py +411 -411
- lamindb_setup/_set_managed_storage.py +55 -55
- lamindb_setup/_setup_user.py +137 -137
- lamindb_setup/_silence_loggers.py +44 -44
- lamindb_setup/core/__init__.py +21 -21
- lamindb_setup/core/_aws_credentials.py +151 -151
- lamindb_setup/core/_aws_storage.py +48 -48
- lamindb_setup/core/_deprecated.py +55 -55
- lamindb_setup/core/_docs.py +14 -14
- lamindb_setup/core/_hub_client.py +1 -1
- lamindb_setup/core/_hub_core.py +615 -590
- lamindb_setup/core/_hub_crud.py +211 -211
- lamindb_setup/core/_hub_utils.py +109 -109
- lamindb_setup/core/_private_django_api.py +88 -88
- lamindb_setup/core/_settings.py +145 -138
- lamindb_setup/core/_settings_instance.py +480 -467
- lamindb_setup/core/_settings_load.py +105 -105
- lamindb_setup/core/_settings_save.py +81 -81
- lamindb_setup/core/_settings_storage.py +412 -405
- lamindb_setup/core/_settings_store.py +75 -75
- lamindb_setup/core/_settings_user.py +55 -53
- lamindb_setup/core/_setup_bionty_sources.py +101 -101
- lamindb_setup/core/cloud_sqlite_locker.py +237 -232
- lamindb_setup/core/django.py +115 -114
- lamindb_setup/core/exceptions.py +12 -12
- lamindb_setup/core/hashing.py +114 -114
- lamindb_setup/core/types.py +19 -19
- lamindb_setup/core/upath.py +779 -779
- {lamindb_setup-0.77.4.dist-info → lamindb_setup-0.77.6.dist-info}/METADATA +3 -2
- lamindb_setup-0.77.6.dist-info/RECORD +47 -0
- {lamindb_setup-0.77.4.dist-info → lamindb_setup-0.77.6.dist-info}/WHEEL +1 -1
- lamindb_setup-0.77.4.dist-info/RECORD +0 -47
- {lamindb_setup-0.77.4.dist-info → lamindb_setup-0.77.6.dist-info}/LICENSE +0 -0
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from typing import TYPE_CHECKING
|
|
4
|
-
|
|
5
|
-
from lamin_utils import logger
|
|
6
|
-
|
|
7
|
-
from ._init_instance import register_storage_in_instance
|
|
8
|
-
from .core._hub_core import delete_storage_record
|
|
9
|
-
from .core._settings import settings
|
|
10
|
-
from .core._settings_storage import init_storage
|
|
11
|
-
|
|
12
|
-
if TYPE_CHECKING:
|
|
13
|
-
from lamindb_setup.core.types import UPathStr
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def set_managed_storage(root: UPathStr, **fs_kwargs):
|
|
17
|
-
"""Add or switch to another managed storage location.
|
|
18
|
-
|
|
19
|
-
Args:
|
|
20
|
-
root: `UPathStr` - The new storage root, e.g., an S3 bucket.
|
|
21
|
-
**fs_kwargs: Additional fsspec arguments for cloud root, e.g., profile.
|
|
22
|
-
|
|
23
|
-
"""
|
|
24
|
-
if settings.instance.dialect == "sqlite":
|
|
25
|
-
raise ValueError(
|
|
26
|
-
"Can't add additional managed storage locations for sqlite instances."
|
|
27
|
-
)
|
|
28
|
-
if not settings.instance.is_on_hub:
|
|
29
|
-
raise ValueError(
|
|
30
|
-
"Can't add additional managed storage locations for instances that aren't managed through the hub."
|
|
31
|
-
)
|
|
32
|
-
# here the storage is registered in the hub
|
|
33
|
-
# hub_record_status="hub-record-created" if a new record is created
|
|
34
|
-
# "hub-record-retireved" if the storage is in the hub already
|
|
35
|
-
ssettings, hub_record_status = init_storage(
|
|
36
|
-
root=root, instance_id=settings.instance._id, register_hub=True
|
|
37
|
-
)
|
|
38
|
-
if ssettings._instance_id is None:
|
|
39
|
-
raise ValueError(
|
|
40
|
-
f"Cannot manage storage without write access: {ssettings.root}"
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
# here the storage is saved in the instance
|
|
44
|
-
# if any error happens the record in the hub is deleted
|
|
45
|
-
# if it was created earlier and not retrieved
|
|
46
|
-
try:
|
|
47
|
-
register_storage_in_instance(ssettings)
|
|
48
|
-
except Exception as e:
|
|
49
|
-
if hub_record_status == "hub-record-created" and ssettings._uuid is not None:
|
|
50
|
-
delete_storage_record(ssettings._uuid) # type: ignore
|
|
51
|
-
raise e
|
|
52
|
-
|
|
53
|
-
settings.instance._storage = ssettings
|
|
54
|
-
settings.instance._persist() # this also updates the settings object
|
|
55
|
-
settings.storage._set_fs_kwargs(**fs_kwargs)
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
|
|
5
|
+
from lamin_utils import logger
|
|
6
|
+
|
|
7
|
+
from ._init_instance import register_storage_in_instance
|
|
8
|
+
from .core._hub_core import delete_storage_record
|
|
9
|
+
from .core._settings import settings
|
|
10
|
+
from .core._settings_storage import init_storage
|
|
11
|
+
|
|
12
|
+
if TYPE_CHECKING:
|
|
13
|
+
from lamindb_setup.core.types import UPathStr
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def set_managed_storage(root: UPathStr, **fs_kwargs):
|
|
17
|
+
"""Add or switch to another managed storage location.
|
|
18
|
+
|
|
19
|
+
Args:
|
|
20
|
+
root: `UPathStr` - The new storage root, e.g., an S3 bucket.
|
|
21
|
+
**fs_kwargs: Additional fsspec arguments for cloud root, e.g., profile.
|
|
22
|
+
|
|
23
|
+
"""
|
|
24
|
+
if settings.instance.dialect == "sqlite":
|
|
25
|
+
raise ValueError(
|
|
26
|
+
"Can't add additional managed storage locations for sqlite instances."
|
|
27
|
+
)
|
|
28
|
+
if not settings.instance.is_on_hub:
|
|
29
|
+
raise ValueError(
|
|
30
|
+
"Can't add additional managed storage locations for instances that aren't managed through the hub."
|
|
31
|
+
)
|
|
32
|
+
# here the storage is registered in the hub
|
|
33
|
+
# hub_record_status="hub-record-created" if a new record is created
|
|
34
|
+
# "hub-record-retireved" if the storage is in the hub already
|
|
35
|
+
ssettings, hub_record_status = init_storage(
|
|
36
|
+
root=root, instance_id=settings.instance._id, register_hub=True
|
|
37
|
+
)
|
|
38
|
+
if ssettings._instance_id is None:
|
|
39
|
+
raise ValueError(
|
|
40
|
+
f"Cannot manage storage without write access: {ssettings.root}"
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
# here the storage is saved in the instance
|
|
44
|
+
# if any error happens the record in the hub is deleted
|
|
45
|
+
# if it was created earlier and not retrieved
|
|
46
|
+
try:
|
|
47
|
+
register_storage_in_instance(ssettings)
|
|
48
|
+
except Exception as e:
|
|
49
|
+
if hub_record_status == "hub-record-created" and ssettings._uuid is not None:
|
|
50
|
+
delete_storage_record(ssettings._uuid) # type: ignore
|
|
51
|
+
raise e
|
|
52
|
+
|
|
53
|
+
settings.instance._storage = ssettings
|
|
54
|
+
settings.instance._persist() # this also updates the settings object
|
|
55
|
+
settings.storage._set_fs_kwargs(**fs_kwargs)
|
lamindb_setup/_setup_user.py
CHANGED
|
@@ -1,137 +1,137 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
import os
|
|
4
|
-
from typing import TYPE_CHECKING, Optional, Union
|
|
5
|
-
|
|
6
|
-
from lamin_utils import logger
|
|
7
|
-
|
|
8
|
-
from ._check_setup import _check_instance_setup
|
|
9
|
-
from ._init_instance import register_user
|
|
10
|
-
from .core._settings import settings
|
|
11
|
-
from .core._settings_load import load_or_create_user_settings, load_user_settings
|
|
12
|
-
from .core._settings_save import save_user_settings
|
|
13
|
-
from .core._settings_store import (
|
|
14
|
-
current_user_settings_file,
|
|
15
|
-
user_settings_file_email,
|
|
16
|
-
user_settings_file_handle,
|
|
17
|
-
)
|
|
18
|
-
|
|
19
|
-
if TYPE_CHECKING:
|
|
20
|
-
from lamindb_setup.core._settings_save import UserSettings
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
def load_user(email: str | None = None, handle: str | None = None) -> UserSettings:
|
|
24
|
-
if email is not None:
|
|
25
|
-
settings_file = user_settings_file_email(email)
|
|
26
|
-
if handle is not None:
|
|
27
|
-
settings_file = user_settings_file_handle(handle)
|
|
28
|
-
if settings_file.exists():
|
|
29
|
-
user_settings = load_user_settings(settings_file)
|
|
30
|
-
save_user_settings(user_settings) # needed to save to current_user.env
|
|
31
|
-
assert user_settings.email is not None or user_settings.api_key is not None
|
|
32
|
-
else:
|
|
33
|
-
user_settings = load_or_create_user_settings()
|
|
34
|
-
if email is None:
|
|
35
|
-
raise SystemExit(
|
|
36
|
-
"✗ Use your email for your first login in a compute environment. "
|
|
37
|
-
"After that, you can use your handle."
|
|
38
|
-
)
|
|
39
|
-
user_settings.email = email
|
|
40
|
-
user_settings.handle = handle
|
|
41
|
-
save_user_settings(user_settings)
|
|
42
|
-
|
|
43
|
-
from .core._settings import settings
|
|
44
|
-
|
|
45
|
-
settings._user_settings = None # this is to refresh a settings instance
|
|
46
|
-
|
|
47
|
-
return user_settings
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
def login(
|
|
51
|
-
user: str | None = None, *, key: str | None = None, api_key: str | None = None
|
|
52
|
-
) -> None:
|
|
53
|
-
"""Log in user.
|
|
54
|
-
|
|
55
|
-
Args:
|
|
56
|
-
user: handle or email
|
|
57
|
-
key: API key
|
|
58
|
-
api_key: Beta API key
|
|
59
|
-
"""
|
|
60
|
-
if user is None and api_key is None:
|
|
61
|
-
if "LAMIN_API_KEY" in os.environ:
|
|
62
|
-
api_key = os.environ["LAMIN_API_KEY"]
|
|
63
|
-
else:
|
|
64
|
-
raise ValueError("Both `user` and `api_key` should not be `None`.")
|
|
65
|
-
|
|
66
|
-
if api_key is None:
|
|
67
|
-
if "@" in user: # type: ignore
|
|
68
|
-
email, handle = user, None
|
|
69
|
-
else:
|
|
70
|
-
email, handle = None, user
|
|
71
|
-
user_settings = load_user(email, handle)
|
|
72
|
-
|
|
73
|
-
if key is not None:
|
|
74
|
-
# within UserSettings, we still call it "password" for a while
|
|
75
|
-
user_settings.password = key
|
|
76
|
-
|
|
77
|
-
if user_settings.password is None:
|
|
78
|
-
api_key = user_settings.api_key
|
|
79
|
-
if api_key is None:
|
|
80
|
-
raise SystemExit(
|
|
81
|
-
"✗ No stored API key, please call: "
|
|
82
|
-
"`lamin login` or `lamin login <your-email> --key <API-key>`"
|
|
83
|
-
)
|
|
84
|
-
elif user_settings.email is None:
|
|
85
|
-
raise SystemExit(f"✗ No stored user email, please call: lamin login {user}")
|
|
86
|
-
else:
|
|
87
|
-
user_settings = load_or_create_user_settings()
|
|
88
|
-
|
|
89
|
-
from .core._hub_core import sign_in_hub, sign_in_hub_api_key
|
|
90
|
-
|
|
91
|
-
if api_key is None:
|
|
92
|
-
response = sign_in_hub(
|
|
93
|
-
user_settings.email, # type: ignore
|
|
94
|
-
user_settings.password, # type: ignore
|
|
95
|
-
user_settings.handle,
|
|
96
|
-
)
|
|
97
|
-
else:
|
|
98
|
-
response = sign_in_hub_api_key(api_key)
|
|
99
|
-
user_settings.password = None
|
|
100
|
-
|
|
101
|
-
if isinstance(response, Exception):
|
|
102
|
-
raise response
|
|
103
|
-
elif isinstance(response, str):
|
|
104
|
-
raise SystemExit(f"✗ Unsuccessful login: {response}.")
|
|
105
|
-
else:
|
|
106
|
-
user_uuid, user_id, user_handle, user_name, access_token = response
|
|
107
|
-
if api_key is not None:
|
|
108
|
-
logger.success(
|
|
109
|
-
f"logged in with API key (handle: {user_handle}, uid: {user_id})"
|
|
110
|
-
)
|
|
111
|
-
elif handle is None:
|
|
112
|
-
logger.success(f"logged in with handle {user_handle} (uid: {user_id})")
|
|
113
|
-
else:
|
|
114
|
-
logger.success(f"logged in with email {user_settings.email} (uid: {user_id})")
|
|
115
|
-
user_settings.uid = user_id
|
|
116
|
-
user_settings.handle = user_handle
|
|
117
|
-
user_settings.name = user_name
|
|
118
|
-
user_settings._uuid = user_uuid
|
|
119
|
-
user_settings.access_token = access_token
|
|
120
|
-
user_settings.api_key = api_key
|
|
121
|
-
save_user_settings(user_settings)
|
|
122
|
-
|
|
123
|
-
if settings._instance_exists and _check_instance_setup():
|
|
124
|
-
register_user(user_settings)
|
|
125
|
-
|
|
126
|
-
settings._user_settings = None
|
|
127
|
-
return None
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
def logout():
|
|
131
|
-
if current_user_settings_file().exists():
|
|
132
|
-
current_user_settings_file().unlink()
|
|
133
|
-
# update user info
|
|
134
|
-
settings._user_settings = None
|
|
135
|
-
logger.success("logged out")
|
|
136
|
-
else:
|
|
137
|
-
logger.important("already logged out")
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
from typing import TYPE_CHECKING, Optional, Union
|
|
5
|
+
|
|
6
|
+
from lamin_utils import logger
|
|
7
|
+
|
|
8
|
+
from ._check_setup import _check_instance_setup
|
|
9
|
+
from ._init_instance import register_user
|
|
10
|
+
from .core._settings import settings
|
|
11
|
+
from .core._settings_load import load_or_create_user_settings, load_user_settings
|
|
12
|
+
from .core._settings_save import save_user_settings
|
|
13
|
+
from .core._settings_store import (
|
|
14
|
+
current_user_settings_file,
|
|
15
|
+
user_settings_file_email,
|
|
16
|
+
user_settings_file_handle,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
if TYPE_CHECKING:
|
|
20
|
+
from lamindb_setup.core._settings_save import UserSettings
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def load_user(email: str | None = None, handle: str | None = None) -> UserSettings:
|
|
24
|
+
if email is not None:
|
|
25
|
+
settings_file = user_settings_file_email(email)
|
|
26
|
+
if handle is not None:
|
|
27
|
+
settings_file = user_settings_file_handle(handle)
|
|
28
|
+
if settings_file.exists():
|
|
29
|
+
user_settings = load_user_settings(settings_file)
|
|
30
|
+
save_user_settings(user_settings) # needed to save to current_user.env
|
|
31
|
+
assert user_settings.email is not None or user_settings.api_key is not None
|
|
32
|
+
else:
|
|
33
|
+
user_settings = load_or_create_user_settings()
|
|
34
|
+
if email is None:
|
|
35
|
+
raise SystemExit(
|
|
36
|
+
"✗ Use your email for your first login in a compute environment. "
|
|
37
|
+
"After that, you can use your handle."
|
|
38
|
+
)
|
|
39
|
+
user_settings.email = email
|
|
40
|
+
user_settings.handle = handle
|
|
41
|
+
save_user_settings(user_settings)
|
|
42
|
+
|
|
43
|
+
from .core._settings import settings
|
|
44
|
+
|
|
45
|
+
settings._user_settings = None # this is to refresh a settings instance
|
|
46
|
+
|
|
47
|
+
return user_settings
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def login(
|
|
51
|
+
user: str | None = None, *, key: str | None = None, api_key: str | None = None
|
|
52
|
+
) -> None:
|
|
53
|
+
"""Log in user.
|
|
54
|
+
|
|
55
|
+
Args:
|
|
56
|
+
user: handle or email
|
|
57
|
+
key: API key
|
|
58
|
+
api_key: Beta API key
|
|
59
|
+
"""
|
|
60
|
+
if user is None and api_key is None:
|
|
61
|
+
if "LAMIN_API_KEY" in os.environ:
|
|
62
|
+
api_key = os.environ["LAMIN_API_KEY"]
|
|
63
|
+
else:
|
|
64
|
+
raise ValueError("Both `user` and `api_key` should not be `None`.")
|
|
65
|
+
|
|
66
|
+
if api_key is None:
|
|
67
|
+
if "@" in user: # type: ignore
|
|
68
|
+
email, handle = user, None
|
|
69
|
+
else:
|
|
70
|
+
email, handle = None, user
|
|
71
|
+
user_settings = load_user(email, handle)
|
|
72
|
+
|
|
73
|
+
if key is not None:
|
|
74
|
+
# within UserSettings, we still call it "password" for a while
|
|
75
|
+
user_settings.password = key
|
|
76
|
+
|
|
77
|
+
if user_settings.password is None:
|
|
78
|
+
api_key = user_settings.api_key
|
|
79
|
+
if api_key is None:
|
|
80
|
+
raise SystemExit(
|
|
81
|
+
"✗ No stored API key, please call: "
|
|
82
|
+
"`lamin login` or `lamin login <your-email> --key <API-key>`"
|
|
83
|
+
)
|
|
84
|
+
elif user_settings.email is None:
|
|
85
|
+
raise SystemExit(f"✗ No stored user email, please call: lamin login {user}")
|
|
86
|
+
else:
|
|
87
|
+
user_settings = load_or_create_user_settings()
|
|
88
|
+
|
|
89
|
+
from .core._hub_core import sign_in_hub, sign_in_hub_api_key
|
|
90
|
+
|
|
91
|
+
if api_key is None:
|
|
92
|
+
response = sign_in_hub(
|
|
93
|
+
user_settings.email, # type: ignore
|
|
94
|
+
user_settings.password, # type: ignore
|
|
95
|
+
user_settings.handle,
|
|
96
|
+
)
|
|
97
|
+
else:
|
|
98
|
+
response = sign_in_hub_api_key(api_key)
|
|
99
|
+
user_settings.password = None
|
|
100
|
+
|
|
101
|
+
if isinstance(response, Exception):
|
|
102
|
+
raise response
|
|
103
|
+
elif isinstance(response, str):
|
|
104
|
+
raise SystemExit(f"✗ Unsuccessful login: {response}.")
|
|
105
|
+
else:
|
|
106
|
+
user_uuid, user_id, user_handle, user_name, access_token = response
|
|
107
|
+
if api_key is not None:
|
|
108
|
+
logger.success(
|
|
109
|
+
f"logged in with API key (handle: {user_handle}, uid: {user_id})"
|
|
110
|
+
)
|
|
111
|
+
elif handle is None:
|
|
112
|
+
logger.success(f"logged in with handle {user_handle} (uid: {user_id})")
|
|
113
|
+
else:
|
|
114
|
+
logger.success(f"logged in with email {user_settings.email} (uid: {user_id})")
|
|
115
|
+
user_settings.uid = user_id
|
|
116
|
+
user_settings.handle = user_handle
|
|
117
|
+
user_settings.name = user_name
|
|
118
|
+
user_settings._uuid = user_uuid
|
|
119
|
+
user_settings.access_token = access_token
|
|
120
|
+
user_settings.api_key = api_key
|
|
121
|
+
save_user_settings(user_settings)
|
|
122
|
+
|
|
123
|
+
if settings._instance_exists and _check_instance_setup():
|
|
124
|
+
register_user(user_settings)
|
|
125
|
+
|
|
126
|
+
settings._user_settings = None
|
|
127
|
+
return None
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def logout():
|
|
131
|
+
if current_user_settings_file().exists():
|
|
132
|
+
current_user_settings_file().unlink()
|
|
133
|
+
# update user info
|
|
134
|
+
settings._user_settings = None
|
|
135
|
+
logger.success("logged out")
|
|
136
|
+
else:
|
|
137
|
+
logger.important("already logged out")
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
import logging
|
|
4
|
-
|
|
5
|
-
silenced = False
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
# from https://github.com/boto/boto3/blob/8c6e641bed8130a9d8cb4d97b4acbe7aa0d0657a/boto3/__init__.py#L37
|
|
9
|
-
def set_stream_logger(name, level):
|
|
10
|
-
logger = logging.getLogger(name)
|
|
11
|
-
logger.setLevel(level)
|
|
12
|
-
handler = logging.StreamHandler()
|
|
13
|
-
handler.setLevel(level)
|
|
14
|
-
logger.addHandler(handler)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
def silence_loggers():
|
|
18
|
-
global silenced
|
|
19
|
-
|
|
20
|
-
if not silenced:
|
|
21
|
-
# this gets logged 6 times
|
|
22
|
-
set_stream_logger(name="botocore.credentials", level=logging.WARNING)
|
|
23
|
-
set_stream_logger(name="botocore.hooks", level=logging.WARNING)
|
|
24
|
-
set_stream_logger(name="botocore.utils", level=logging.WARNING)
|
|
25
|
-
set_stream_logger(name="botocore.auth", level=logging.WARNING)
|
|
26
|
-
set_stream_logger(name="botocore.endpoint", level=logging.WARNING)
|
|
27
|
-
set_stream_logger(name="httpx", level=logging.WARNING)
|
|
28
|
-
try:
|
|
29
|
-
import aiobotocore
|
|
30
|
-
|
|
31
|
-
# the 7th logging message of credentials came from aiobotocore
|
|
32
|
-
set_stream_logger(name="aiobotocore.credentials", level=logging.WARNING)
|
|
33
|
-
except ImportError:
|
|
34
|
-
pass
|
|
35
|
-
try:
|
|
36
|
-
# google also aggressively logs authentication related warnings
|
|
37
|
-
# in cases where users access public data
|
|
38
|
-
set_stream_logger(name="google.auth._default", level=logging.ERROR)
|
|
39
|
-
set_stream_logger(
|
|
40
|
-
name="google.auth.compute_engine._metadata", level=logging.ERROR
|
|
41
|
-
)
|
|
42
|
-
except Exception:
|
|
43
|
-
pass
|
|
44
|
-
silenced = True
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
|
|
5
|
+
silenced = False
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
# from https://github.com/boto/boto3/blob/8c6e641bed8130a9d8cb4d97b4acbe7aa0d0657a/boto3/__init__.py#L37
|
|
9
|
+
def set_stream_logger(name, level):
|
|
10
|
+
logger = logging.getLogger(name)
|
|
11
|
+
logger.setLevel(level)
|
|
12
|
+
handler = logging.StreamHandler()
|
|
13
|
+
handler.setLevel(level)
|
|
14
|
+
logger.addHandler(handler)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def silence_loggers():
|
|
18
|
+
global silenced
|
|
19
|
+
|
|
20
|
+
if not silenced:
|
|
21
|
+
# this gets logged 6 times
|
|
22
|
+
set_stream_logger(name="botocore.credentials", level=logging.WARNING)
|
|
23
|
+
set_stream_logger(name="botocore.hooks", level=logging.WARNING)
|
|
24
|
+
set_stream_logger(name="botocore.utils", level=logging.WARNING)
|
|
25
|
+
set_stream_logger(name="botocore.auth", level=logging.WARNING)
|
|
26
|
+
set_stream_logger(name="botocore.endpoint", level=logging.WARNING)
|
|
27
|
+
set_stream_logger(name="httpx", level=logging.WARNING)
|
|
28
|
+
try:
|
|
29
|
+
import aiobotocore
|
|
30
|
+
|
|
31
|
+
# the 7th logging message of credentials came from aiobotocore
|
|
32
|
+
set_stream_logger(name="aiobotocore.credentials", level=logging.WARNING)
|
|
33
|
+
except ImportError:
|
|
34
|
+
pass
|
|
35
|
+
try:
|
|
36
|
+
# google also aggressively logs authentication related warnings
|
|
37
|
+
# in cases where users access public data
|
|
38
|
+
set_stream_logger(name="google.auth._default", level=logging.ERROR)
|
|
39
|
+
set_stream_logger(
|
|
40
|
+
name="google.auth.compute_engine._metadata", level=logging.ERROR
|
|
41
|
+
)
|
|
42
|
+
except Exception:
|
|
43
|
+
pass
|
|
44
|
+
silenced = True
|
lamindb_setup/core/__init__.py
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
"""Core setup library.
|
|
2
|
-
|
|
3
|
-
Settings:
|
|
4
|
-
|
|
5
|
-
.. autosummary::
|
|
6
|
-
:toctree:
|
|
7
|
-
|
|
8
|
-
SetupSettings
|
|
9
|
-
UserSettings
|
|
10
|
-
InstanceSettings
|
|
11
|
-
StorageSettings
|
|
12
|
-
|
|
13
|
-
"""
|
|
14
|
-
|
|
15
|
-
from . import django, types, upath
|
|
16
|
-
from ._deprecated import deprecated
|
|
17
|
-
from ._docs import doc_args
|
|
18
|
-
from ._settings import SetupSettings
|
|
19
|
-
from ._settings_instance import InstanceSettings
|
|
20
|
-
from ._settings_storage import StorageSettings
|
|
21
|
-
from ._settings_user import UserSettings
|
|
1
|
+
"""Core setup library.
|
|
2
|
+
|
|
3
|
+
Settings:
|
|
4
|
+
|
|
5
|
+
.. autosummary::
|
|
6
|
+
:toctree:
|
|
7
|
+
|
|
8
|
+
SetupSettings
|
|
9
|
+
UserSettings
|
|
10
|
+
InstanceSettings
|
|
11
|
+
StorageSettings
|
|
12
|
+
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from . import django, types, upath
|
|
16
|
+
from ._deprecated import deprecated
|
|
17
|
+
from ._docs import doc_args
|
|
18
|
+
from ._settings import SetupSettings
|
|
19
|
+
from ._settings_instance import InstanceSettings
|
|
20
|
+
from ._settings_storage import StorageSettings
|
|
21
|
+
from ._settings_user import UserSettings
|