lamindb_setup 1.19.0__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.
Files changed (49) hide show
  1. lamindb_setup/__init__.py +1 -1
  2. lamindb_setup/_cache.py +87 -87
  3. lamindb_setup/_check.py +7 -7
  4. lamindb_setup/_check_setup.py +131 -131
  5. lamindb_setup/_connect_instance.py +443 -441
  6. lamindb_setup/_delete.py +155 -155
  7. lamindb_setup/_disconnect.py +38 -38
  8. lamindb_setup/_django.py +39 -39
  9. lamindb_setup/_entry_points.py +19 -19
  10. lamindb_setup/_init_instance.py +423 -423
  11. lamindb_setup/_migrate.py +331 -331
  12. lamindb_setup/_register_instance.py +32 -32
  13. lamindb_setup/_schema.py +27 -27
  14. lamindb_setup/_schema_metadata.py +451 -451
  15. lamindb_setup/_set_managed_storage.py +81 -81
  16. lamindb_setup/_setup_user.py +198 -198
  17. lamindb_setup/_silence_loggers.py +46 -46
  18. lamindb_setup/core/__init__.py +25 -34
  19. lamindb_setup/core/_aws_options.py +276 -276
  20. lamindb_setup/core/_aws_storage.py +57 -57
  21. lamindb_setup/core/_clone.py +50 -50
  22. lamindb_setup/core/_deprecated.py +62 -62
  23. lamindb_setup/core/_docs.py +14 -14
  24. lamindb_setup/core/_hub_client.py +288 -288
  25. lamindb_setup/core/_hub_crud.py +247 -247
  26. lamindb_setup/core/_hub_utils.py +100 -100
  27. lamindb_setup/core/_private_django_api.py +80 -80
  28. lamindb_setup/core/_settings.py +440 -434
  29. lamindb_setup/core/_settings_instance.py +22 -1
  30. lamindb_setup/core/_settings_load.py +162 -162
  31. lamindb_setup/core/_settings_save.py +108 -108
  32. lamindb_setup/core/_settings_storage.py +433 -433
  33. lamindb_setup/core/_settings_store.py +162 -162
  34. lamindb_setup/core/_settings_user.py +55 -55
  35. lamindb_setup/core/_setup_bionty_sources.py +44 -44
  36. lamindb_setup/core/cloud_sqlite_locker.py +240 -240
  37. lamindb_setup/core/django.py +414 -413
  38. lamindb_setup/core/exceptions.py +1 -1
  39. lamindb_setup/core/hashing.py +134 -134
  40. lamindb_setup/core/types.py +1 -1
  41. lamindb_setup/core/upath.py +1031 -1028
  42. lamindb_setup/errors.py +72 -72
  43. lamindb_setup/io.py +423 -423
  44. lamindb_setup/types.py +17 -17
  45. {lamindb_setup-1.19.0.dist-info → lamindb_setup-1.19.1.dist-info}/METADATA +3 -2
  46. lamindb_setup-1.19.1.dist-info/RECORD +51 -0
  47. {lamindb_setup-1.19.0.dist-info → lamindb_setup-1.19.1.dist-info}/WHEEL +1 -1
  48. {lamindb_setup-1.19.0.dist-info → lamindb_setup-1.19.1.dist-info/licenses}/LICENSE +201 -201
  49. lamindb_setup-1.19.0.dist-info/RECORD +0 -51
@@ -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)