lamindb_setup 1.18.2__py3-none-any.whl → 1.19.1__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 +4 -19
- lamindb_setup/_cache.py +87 -87
- lamindb_setup/_check.py +7 -7
- lamindb_setup/_check_setup.py +131 -131
- lamindb_setup/_connect_instance.py +443 -438
- lamindb_setup/_delete.py +155 -151
- lamindb_setup/_disconnect.py +38 -38
- lamindb_setup/_django.py +39 -39
- lamindb_setup/_entry_points.py +19 -19
- lamindb_setup/_init_instance.py +423 -429
- lamindb_setup/_migrate.py +331 -327
- lamindb_setup/_register_instance.py +32 -32
- lamindb_setup/_schema.py +27 -27
- lamindb_setup/_schema_metadata.py +451 -451
- lamindb_setup/_set_managed_storage.py +81 -80
- lamindb_setup/_setup_user.py +198 -198
- lamindb_setup/_silence_loggers.py +46 -46
- lamindb_setup/core/__init__.py +25 -34
- lamindb_setup/core/_aws_options.py +276 -266
- lamindb_setup/core/_aws_storage.py +57 -55
- lamindb_setup/core/_clone.py +50 -50
- lamindb_setup/core/_deprecated.py +62 -62
- lamindb_setup/core/_docs.py +14 -14
- lamindb_setup/core/_hub_client.py +288 -294
- lamindb_setup/core/_hub_core.py +0 -2
- lamindb_setup/core/_hub_crud.py +247 -247
- lamindb_setup/core/_hub_utils.py +100 -100
- lamindb_setup/core/_private_django_api.py +80 -80
- lamindb_setup/core/_settings.py +440 -434
- lamindb_setup/core/_settings_instance.py +32 -7
- lamindb_setup/core/_settings_load.py +162 -159
- lamindb_setup/core/_settings_save.py +108 -96
- lamindb_setup/core/_settings_storage.py +433 -433
- lamindb_setup/core/_settings_store.py +162 -92
- lamindb_setup/core/_settings_user.py +55 -55
- lamindb_setup/core/_setup_bionty_sources.py +44 -44
- lamindb_setup/core/cloud_sqlite_locker.py +240 -240
- lamindb_setup/core/django.py +414 -413
- lamindb_setup/core/exceptions.py +1 -1
- lamindb_setup/core/hashing.py +134 -134
- lamindb_setup/core/types.py +1 -1
- lamindb_setup/core/upath.py +1031 -1028
- lamindb_setup/errors.py +72 -70
- lamindb_setup/io.py +423 -416
- lamindb_setup/types.py +17 -17
- {lamindb_setup-1.18.2.dist-info → lamindb_setup-1.19.1.dist-info}/METADATA +4 -2
- lamindb_setup-1.19.1.dist-info/RECORD +51 -0
- {lamindb_setup-1.18.2.dist-info → lamindb_setup-1.19.1.dist-info}/WHEEL +1 -1
- {lamindb_setup-1.18.2.dist-info → lamindb_setup-1.19.1.dist-info/licenses}/LICENSE +201 -201
- lamindb_setup-1.18.2.dist-info/RECORD +0 -51
lamindb_setup/core/_hub_utils.py
CHANGED
|
@@ -1,100 +1,100 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from typing import Any, ClassVar
|
|
4
|
-
from urllib.parse import urlparse, urlunparse
|
|
5
|
-
|
|
6
|
-
from pydantic import BaseModel, Field, GetCoreSchemaHandler
|
|
7
|
-
from pydantic_core import CoreSchema, core_schema
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def validate_db_arg(db: str | None) -> None:
|
|
11
|
-
if db is not None:
|
|
12
|
-
LaminDsnModel(db=db)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class LaminDsn(str):
|
|
16
|
-
allowed_schemes: ClassVar[set[str]] = {
|
|
17
|
-
"postgresql",
|
|
18
|
-
# future enabled schemes
|
|
19
|
-
# "snowflake",
|
|
20
|
-
# "bigquery"
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
@classmethod
|
|
24
|
-
def __get_pydantic_core_schema__(
|
|
25
|
-
cls, source_type: Any, handler: GetCoreSchemaHandler
|
|
26
|
-
) -> CoreSchema:
|
|
27
|
-
return core_schema.no_info_after_validator_function(
|
|
28
|
-
cls.validate,
|
|
29
|
-
core_schema.str_schema(),
|
|
30
|
-
serialization=core_schema.plain_serializer_function_ser_schema(str),
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
@classmethod
|
|
34
|
-
def validate(cls, v: Any) -> LaminDsn:
|
|
35
|
-
if isinstance(v, str):
|
|
36
|
-
parsed = urlparse(v)
|
|
37
|
-
if parsed.scheme not in cls.allowed_schemes:
|
|
38
|
-
raise ValueError(f"Invalid scheme: {parsed.scheme}")
|
|
39
|
-
return cls(v)
|
|
40
|
-
elif isinstance(v, cls):
|
|
41
|
-
return v
|
|
42
|
-
else:
|
|
43
|
-
raise ValueError(f"Invalid value for LaminDsn: {v}")
|
|
44
|
-
|
|
45
|
-
@property
|
|
46
|
-
def user(self) -> str | None:
|
|
47
|
-
return urlparse(self).username
|
|
48
|
-
|
|
49
|
-
@property
|
|
50
|
-
def password(self) -> str | None:
|
|
51
|
-
return urlparse(self).password
|
|
52
|
-
|
|
53
|
-
@property
|
|
54
|
-
def host(self) -> str | None:
|
|
55
|
-
return urlparse(self).hostname
|
|
56
|
-
|
|
57
|
-
@property
|
|
58
|
-
def port(self) -> int | None:
|
|
59
|
-
return urlparse(self).port
|
|
60
|
-
|
|
61
|
-
@property
|
|
62
|
-
def database(self) -> str:
|
|
63
|
-
return urlparse(self).path.lstrip("/")
|
|
64
|
-
|
|
65
|
-
@property
|
|
66
|
-
def scheme(self) -> str:
|
|
67
|
-
return urlparse(self).scheme
|
|
68
|
-
|
|
69
|
-
@classmethod
|
|
70
|
-
def build(
|
|
71
|
-
cls,
|
|
72
|
-
*,
|
|
73
|
-
scheme: str,
|
|
74
|
-
user: str | None = None,
|
|
75
|
-
password: str | None = None,
|
|
76
|
-
host: str,
|
|
77
|
-
port: int | None = None,
|
|
78
|
-
database: str | None = None,
|
|
79
|
-
query: str | None = None,
|
|
80
|
-
fragment: str | None = None,
|
|
81
|
-
) -> LaminDsn:
|
|
82
|
-
netloc = host
|
|
83
|
-
if port is not None:
|
|
84
|
-
netloc = f"{netloc}:{port}"
|
|
85
|
-
if user is not None:
|
|
86
|
-
auth = user
|
|
87
|
-
if password is not None:
|
|
88
|
-
auth = f"{auth}:{password}"
|
|
89
|
-
netloc = f"{auth}@{netloc}"
|
|
90
|
-
|
|
91
|
-
path = f"/{database}" if database else ""
|
|
92
|
-
|
|
93
|
-
url = urlunparse((scheme, netloc, path, "", query or "", fragment or ""))
|
|
94
|
-
return cls(url)
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
class LaminDsnModel(BaseModel):
|
|
98
|
-
db: LaminDsn = Field(..., description="The database DSN")
|
|
99
|
-
|
|
100
|
-
model_config = {"arbitrary_types_allowed": True}
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Any, ClassVar
|
|
4
|
+
from urllib.parse import urlparse, urlunparse
|
|
5
|
+
|
|
6
|
+
from pydantic import BaseModel, Field, GetCoreSchemaHandler
|
|
7
|
+
from pydantic_core import CoreSchema, core_schema
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def validate_db_arg(db: str | None) -> None:
|
|
11
|
+
if db is not None:
|
|
12
|
+
LaminDsnModel(db=db)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class LaminDsn(str):
|
|
16
|
+
allowed_schemes: ClassVar[set[str]] = {
|
|
17
|
+
"postgresql",
|
|
18
|
+
# future enabled schemes
|
|
19
|
+
# "snowflake",
|
|
20
|
+
# "bigquery"
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@classmethod
|
|
24
|
+
def __get_pydantic_core_schema__(
|
|
25
|
+
cls, source_type: Any, handler: GetCoreSchemaHandler
|
|
26
|
+
) -> CoreSchema:
|
|
27
|
+
return core_schema.no_info_after_validator_function(
|
|
28
|
+
cls.validate,
|
|
29
|
+
core_schema.str_schema(),
|
|
30
|
+
serialization=core_schema.plain_serializer_function_ser_schema(str),
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
@classmethod
|
|
34
|
+
def validate(cls, v: Any) -> LaminDsn:
|
|
35
|
+
if isinstance(v, str):
|
|
36
|
+
parsed = urlparse(v)
|
|
37
|
+
if parsed.scheme not in cls.allowed_schemes:
|
|
38
|
+
raise ValueError(f"Invalid scheme: {parsed.scheme}")
|
|
39
|
+
return cls(v)
|
|
40
|
+
elif isinstance(v, cls):
|
|
41
|
+
return v
|
|
42
|
+
else:
|
|
43
|
+
raise ValueError(f"Invalid value for LaminDsn: {v}")
|
|
44
|
+
|
|
45
|
+
@property
|
|
46
|
+
def user(self) -> str | None:
|
|
47
|
+
return urlparse(self).username
|
|
48
|
+
|
|
49
|
+
@property
|
|
50
|
+
def password(self) -> str | None:
|
|
51
|
+
return urlparse(self).password
|
|
52
|
+
|
|
53
|
+
@property
|
|
54
|
+
def host(self) -> str | None:
|
|
55
|
+
return urlparse(self).hostname
|
|
56
|
+
|
|
57
|
+
@property
|
|
58
|
+
def port(self) -> int | None:
|
|
59
|
+
return urlparse(self).port
|
|
60
|
+
|
|
61
|
+
@property
|
|
62
|
+
def database(self) -> str:
|
|
63
|
+
return urlparse(self).path.lstrip("/")
|
|
64
|
+
|
|
65
|
+
@property
|
|
66
|
+
def scheme(self) -> str:
|
|
67
|
+
return urlparse(self).scheme
|
|
68
|
+
|
|
69
|
+
@classmethod
|
|
70
|
+
def build(
|
|
71
|
+
cls,
|
|
72
|
+
*,
|
|
73
|
+
scheme: str,
|
|
74
|
+
user: str | None = None,
|
|
75
|
+
password: str | None = None,
|
|
76
|
+
host: str,
|
|
77
|
+
port: int | None = None,
|
|
78
|
+
database: str | None = None,
|
|
79
|
+
query: str | None = None,
|
|
80
|
+
fragment: str | None = None,
|
|
81
|
+
) -> LaminDsn:
|
|
82
|
+
netloc = host
|
|
83
|
+
if port is not None:
|
|
84
|
+
netloc = f"{netloc}:{port}"
|
|
85
|
+
if user is not None:
|
|
86
|
+
auth = user
|
|
87
|
+
if password is not None:
|
|
88
|
+
auth = f"{auth}:{password}"
|
|
89
|
+
netloc = f"{auth}@{netloc}"
|
|
90
|
+
|
|
91
|
+
path = f"/{database}" if database else ""
|
|
92
|
+
|
|
93
|
+
url = urlunparse((scheme, netloc, path, "", query or "", fragment or ""))
|
|
94
|
+
return cls(url)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
class LaminDsnModel(BaseModel):
|
|
98
|
+
db: LaminDsn = Field(..., description="The database DSN")
|
|
99
|
+
|
|
100
|
+
model_config = {"arbitrary_types_allowed": True}
|
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
import os
|
|
4
|
-
from pathlib import Path
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def find_vscode_stubs_folder() -> Path | None:
|
|
8
|
-
# Possible locations of VSCode extensions
|
|
9
|
-
possible_locations = [
|
|
10
|
-
Path.home() / ".vscode" / "extensions", # Linux and macOS
|
|
11
|
-
Path.home() / ".vscode-server" / "extensions", # Remote development
|
|
12
|
-
Path(os.environ.get("APPDATA", "")) / "Code" / "User" / "extensions", # Windows
|
|
13
|
-
Path("/usr/share/code/resources/app/extensions"), # Some Linux distributions
|
|
14
|
-
]
|
|
15
|
-
for location in possible_locations:
|
|
16
|
-
if location.exists():
|
|
17
|
-
# Look for Pylance extension folder
|
|
18
|
-
pylance_folders = list(location.glob("ms-python.vscode-pylance-*"))
|
|
19
|
-
if pylance_folders:
|
|
20
|
-
# Sort to get the latest version
|
|
21
|
-
latest_pylance = sorted(pylance_folders)[-1]
|
|
22
|
-
stubs_folder = (
|
|
23
|
-
latest_pylance / "dist" / "bundled" / "stubs" / "django-stubs"
|
|
24
|
-
)
|
|
25
|
-
if stubs_folder.exists():
|
|
26
|
-
return stubs_folder
|
|
27
|
-
|
|
28
|
-
return None
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
def private_django_api(reverse=False):
|
|
32
|
-
from django import db
|
|
33
|
-
|
|
34
|
-
# the order here matters
|
|
35
|
-
# changing it might break the tests
|
|
36
|
-
attributes = [
|
|
37
|
-
"add_to_class",
|
|
38
|
-
"arefresh_from_db",
|
|
39
|
-
"adelete",
|
|
40
|
-
"asave",
|
|
41
|
-
"clean",
|
|
42
|
-
"clean_fields",
|
|
43
|
-
"date_error_message",
|
|
44
|
-
"get_constraints",
|
|
45
|
-
"get_deferred_fields",
|
|
46
|
-
"prepare_database_save",
|
|
47
|
-
"save_base",
|
|
48
|
-
"serializable_value",
|
|
49
|
-
"unique_error_message",
|
|
50
|
-
"validate_constraints",
|
|
51
|
-
"validate_unique",
|
|
52
|
-
]
|
|
53
|
-
if reverse:
|
|
54
|
-
attributes.append("full_clean")
|
|
55
|
-
else:
|
|
56
|
-
attributes.append("full__clean")
|
|
57
|
-
|
|
58
|
-
django_path = Path(db.__file__).parent.parent
|
|
59
|
-
|
|
60
|
-
encoding = "utf8" if os.name == "nt" else None
|
|
61
|
-
|
|
62
|
-
def prune_file(file_path):
|
|
63
|
-
content = file_path.read_text(encoding=encoding)
|
|
64
|
-
original_content = content
|
|
65
|
-
|
|
66
|
-
for attr in attributes:
|
|
67
|
-
old_name = f"_{attr}" if reverse else attr
|
|
68
|
-
new_name = attr if reverse else f"_{attr}"
|
|
69
|
-
content = content.replace(old_name, new_name)
|
|
70
|
-
|
|
71
|
-
if content != original_content:
|
|
72
|
-
file_path.write_text(content, encoding=encoding)
|
|
73
|
-
|
|
74
|
-
for file_path in django_path.rglob("*.py"):
|
|
75
|
-
prune_file(file_path)
|
|
76
|
-
|
|
77
|
-
pylance_path = find_vscode_stubs_folder()
|
|
78
|
-
if pylance_path is not None:
|
|
79
|
-
for file_path in pylance_path.rglob("*.pyi"):
|
|
80
|
-
prune_file(file_path)
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def find_vscode_stubs_folder() -> Path | None:
|
|
8
|
+
# Possible locations of VSCode extensions
|
|
9
|
+
possible_locations = [
|
|
10
|
+
Path.home() / ".vscode" / "extensions", # Linux and macOS
|
|
11
|
+
Path.home() / ".vscode-server" / "extensions", # Remote development
|
|
12
|
+
Path(os.environ.get("APPDATA", "")) / "Code" / "User" / "extensions", # Windows
|
|
13
|
+
Path("/usr/share/code/resources/app/extensions"), # Some Linux distributions
|
|
14
|
+
]
|
|
15
|
+
for location in possible_locations:
|
|
16
|
+
if location.exists():
|
|
17
|
+
# Look for Pylance extension folder
|
|
18
|
+
pylance_folders = list(location.glob("ms-python.vscode-pylance-*"))
|
|
19
|
+
if pylance_folders:
|
|
20
|
+
# Sort to get the latest version
|
|
21
|
+
latest_pylance = sorted(pylance_folders)[-1]
|
|
22
|
+
stubs_folder = (
|
|
23
|
+
latest_pylance / "dist" / "bundled" / "stubs" / "django-stubs"
|
|
24
|
+
)
|
|
25
|
+
if stubs_folder.exists():
|
|
26
|
+
return stubs_folder
|
|
27
|
+
|
|
28
|
+
return None
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def private_django_api(reverse=False):
|
|
32
|
+
from django import db
|
|
33
|
+
|
|
34
|
+
# the order here matters
|
|
35
|
+
# changing it might break the tests
|
|
36
|
+
attributes = [
|
|
37
|
+
"add_to_class",
|
|
38
|
+
"arefresh_from_db",
|
|
39
|
+
"adelete",
|
|
40
|
+
"asave",
|
|
41
|
+
"clean",
|
|
42
|
+
"clean_fields",
|
|
43
|
+
"date_error_message",
|
|
44
|
+
"get_constraints",
|
|
45
|
+
"get_deferred_fields",
|
|
46
|
+
"prepare_database_save",
|
|
47
|
+
"save_base",
|
|
48
|
+
"serializable_value",
|
|
49
|
+
"unique_error_message",
|
|
50
|
+
"validate_constraints",
|
|
51
|
+
"validate_unique",
|
|
52
|
+
]
|
|
53
|
+
if reverse:
|
|
54
|
+
attributes.append("full_clean")
|
|
55
|
+
else:
|
|
56
|
+
attributes.append("full__clean")
|
|
57
|
+
|
|
58
|
+
django_path = Path(db.__file__).parent.parent
|
|
59
|
+
|
|
60
|
+
encoding = "utf8" if os.name == "nt" else None
|
|
61
|
+
|
|
62
|
+
def prune_file(file_path):
|
|
63
|
+
content = file_path.read_text(encoding=encoding)
|
|
64
|
+
original_content = content
|
|
65
|
+
|
|
66
|
+
for attr in attributes:
|
|
67
|
+
old_name = f"_{attr}" if reverse else attr
|
|
68
|
+
new_name = attr if reverse else f"_{attr}"
|
|
69
|
+
content = content.replace(old_name, new_name)
|
|
70
|
+
|
|
71
|
+
if content != original_content:
|
|
72
|
+
file_path.write_text(content, encoding=encoding)
|
|
73
|
+
|
|
74
|
+
for file_path in django_path.rglob("*.py"):
|
|
75
|
+
prune_file(file_path)
|
|
76
|
+
|
|
77
|
+
pylance_path = find_vscode_stubs_folder()
|
|
78
|
+
if pylance_path is not None:
|
|
79
|
+
for file_path in pylance_path.rglob("*.pyi"):
|
|
80
|
+
prune_file(file_path)
|