lamindb_setup 1.1.1__py3-none-any.whl → 1.3.0__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 -1
- lamindb_setup/_schema_metadata.py +13 -2
- lamindb_setup/core/_aws_options.py +7 -1
- lamindb_setup/core/django.py +25 -0
- lamindb_setup/core/upath.py +6 -1
- {lamindb_setup-1.1.1.dist-info → lamindb_setup-1.3.0.dist-info}/METADATA +2 -2
- {lamindb_setup-1.1.1.dist-info → lamindb_setup-1.3.0.dist-info}/RECORD +9 -9
- {lamindb_setup-1.1.1.dist-info → lamindb_setup-1.3.0.dist-info}/LICENSE +0 -0
- {lamindb_setup-1.1.1.dist-info → lamindb_setup-1.3.0.dist-info}/WHEEL +0 -0
lamindb_setup/__init__.py
CHANGED
|
@@ -148,6 +148,8 @@ class FieldMetadata(BaseModel):
|
|
|
148
148
|
model_name: str
|
|
149
149
|
schema_name: str
|
|
150
150
|
is_link_table: bool
|
|
151
|
+
is_primary_key: bool
|
|
152
|
+
is_editable: bool
|
|
151
153
|
relation_type: RelationType | None = None
|
|
152
154
|
related_field_name: str | None = None
|
|
153
155
|
related_model_name: str | None = None
|
|
@@ -156,6 +158,8 @@ class FieldMetadata(BaseModel):
|
|
|
156
158
|
|
|
157
159
|
class _ModelHandler:
|
|
158
160
|
def __init__(self, model, module_name: str, included_modules: list[str]) -> None:
|
|
161
|
+
from lamindb.models import LinkORM
|
|
162
|
+
|
|
159
163
|
self.model = model
|
|
160
164
|
self.class_name = model.__name__
|
|
161
165
|
self.module_name = module_name
|
|
@@ -163,12 +167,14 @@ class _ModelHandler:
|
|
|
163
167
|
self.table_name = model._meta.db_table
|
|
164
168
|
self.included_modules = included_modules
|
|
165
169
|
self.fields = self._get_fields_metadata(self.model)
|
|
170
|
+
self.is_link_table = issubclass(model, LinkORM)
|
|
166
171
|
|
|
167
172
|
def to_dict(self, include_django_objects: bool = True):
|
|
168
173
|
_dict = {
|
|
169
174
|
"fields": self.fields.copy(),
|
|
170
175
|
"class_name": self.class_name,
|
|
171
176
|
"table_name": self.table_name,
|
|
177
|
+
"is_link_table": self.is_link_table,
|
|
172
178
|
}
|
|
173
179
|
|
|
174
180
|
for field_name in self.fields.keys():
|
|
@@ -242,13 +248,16 @@ class _ModelHandler:
|
|
|
242
248
|
related_model_name = None
|
|
243
249
|
related_schema_name = None
|
|
244
250
|
related_field_name = None
|
|
245
|
-
|
|
251
|
+
is_editable = field.editable
|
|
246
252
|
else:
|
|
247
253
|
related_model_name = field.related_model._meta.model_name
|
|
248
254
|
related_schema_name = field.related_model.__get_module_name__()
|
|
249
255
|
schema_name = field.model.__get_module_name__()
|
|
250
256
|
related_field_name = field.remote_field.name
|
|
251
|
-
|
|
257
|
+
is_editable = False
|
|
258
|
+
|
|
259
|
+
field_name = field.name
|
|
260
|
+
is_primary_key = getattr(field, "primary_key", False)
|
|
252
261
|
|
|
253
262
|
if relation_type in ["one-to-many"]:
|
|
254
263
|
# For a one-to-many relation, the field belong
|
|
@@ -278,6 +287,8 @@ class _ModelHandler:
|
|
|
278
287
|
field_name=field_name,
|
|
279
288
|
type=internal_type,
|
|
280
289
|
is_link_table=issubclass(field.model, LinkORM),
|
|
290
|
+
is_primary_key=is_primary_key,
|
|
291
|
+
is_editable=is_editable,
|
|
281
292
|
column_name=column,
|
|
282
293
|
relation_type=relation_type,
|
|
283
294
|
related_schema_name=related_schema_name
|
|
@@ -125,7 +125,13 @@ class AWSOptionsManager:
|
|
|
125
125
|
|
|
126
126
|
def enrich_path(self, path: UPath, access_token: str | None = None) -> UPath:
|
|
127
127
|
# ignore paths with non-lamin-managed endpoints
|
|
128
|
-
if
|
|
128
|
+
if (
|
|
129
|
+
endpoint_url := path.storage_options.get("endpoint_url", None)
|
|
130
|
+
) not in LAMIN_ENDPOINTS:
|
|
131
|
+
if "r2.cloudflarestorage.com" in endpoint_url:
|
|
132
|
+
# fixed_upload_size should always be True for R2
|
|
133
|
+
# this option is needed for correct uploads to R2
|
|
134
|
+
path = UPath(path, fixed_upload_size=True)
|
|
129
135
|
return path
|
|
130
136
|
# trailing slash is needed to avoid returning incorrect results
|
|
131
137
|
# with .startswith
|
lamindb_setup/core/django.py
CHANGED
|
@@ -14,6 +14,31 @@ IS_MIGRATING = False
|
|
|
14
14
|
CONN_MAX_AGE = 299
|
|
15
15
|
|
|
16
16
|
|
|
17
|
+
def set_token(token: str | None, connection_name: str = "default"):
|
|
18
|
+
# None to reset
|
|
19
|
+
from django.db import connections
|
|
20
|
+
from django.db.backends.base.base import BaseDatabaseWrapper
|
|
21
|
+
|
|
22
|
+
connection = connections[connection_name]
|
|
23
|
+
assert connection.vendor == "postgresql"
|
|
24
|
+
|
|
25
|
+
if token is not None:
|
|
26
|
+
|
|
27
|
+
def connect(self):
|
|
28
|
+
BaseDatabaseWrapper.connect(self)
|
|
29
|
+
# now the connection should be set
|
|
30
|
+
# Use a psycopg cursor directly, bypassing Django's utilities.
|
|
31
|
+
with self.connection.cursor() as cursor:
|
|
32
|
+
cursor.execute("SELECT set_token(%s, false);", (token,))
|
|
33
|
+
else:
|
|
34
|
+
connect = BaseDatabaseWrapper.connect
|
|
35
|
+
|
|
36
|
+
connection.connect = connect.__get__(connection, connection.__class__)
|
|
37
|
+
# execute this to initially set or reset the token
|
|
38
|
+
connection.close()
|
|
39
|
+
connection.connect()
|
|
40
|
+
|
|
41
|
+
|
|
17
42
|
def close_if_health_check_failed(self) -> None:
|
|
18
43
|
if self.close_at is not None:
|
|
19
44
|
if time.monotonic() >= self.close_at:
|
lamindb_setup/core/upath.py
CHANGED
|
@@ -517,7 +517,7 @@ def modified(self) -> datetime | None:
|
|
|
517
517
|
|
|
518
518
|
|
|
519
519
|
def compute_file_tree(
|
|
520
|
-
path:
|
|
520
|
+
path: UPath,
|
|
521
521
|
*,
|
|
522
522
|
level: int = -1,
|
|
523
523
|
only_dirs: bool = False,
|
|
@@ -526,6 +526,11 @@ def compute_file_tree(
|
|
|
526
526
|
include_paths: set[Any] | None = None,
|
|
527
527
|
skip_suffixes: list[str] | None = None,
|
|
528
528
|
) -> tuple[str, int]:
|
|
529
|
+
# .exists() helps to separate files from folders for gcsfs
|
|
530
|
+
# otherwise sometimes it has is_dir() True and is_file() True
|
|
531
|
+
if path.protocol == "gs" and not path.exists():
|
|
532
|
+
raise FileNotFoundError
|
|
533
|
+
|
|
529
534
|
space = " "
|
|
530
535
|
branch = "│ "
|
|
531
536
|
tee = "├── "
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: lamindb_setup
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.0
|
|
4
4
|
Summary: Setup & configure LaminDB.
|
|
5
5
|
Author-email: Lamin Labs <open-source@lamin.ai>
|
|
6
6
|
Requires-Python: >=3.10
|
|
@@ -40,7 +40,7 @@ Provides-Extra: gcp
|
|
|
40
40
|
|
|
41
41
|
[](https://codecov.io/gh/laminlabs/lamindb-setup)
|
|
42
42
|
|
|
43
|
-
# lamindb-setup:
|
|
43
|
+
# lamindb-setup: Setting up `lamindb`
|
|
44
44
|
|
|
45
45
|
- User [docs](https://lamin.ai/docs)
|
|
46
46
|
- Developer [docs](https://lamindb-setup-htry.netlify.app/)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
lamindb_setup/__init__.py,sha256=
|
|
1
|
+
lamindb_setup/__init__.py,sha256=B7IVjz1M1qrpfYuPg4mQ66YiIyfAcYtmSfjLULXKpII,2692
|
|
2
2
|
lamindb_setup/_cache.py,sha256=aszT-zk3S5dTLKp5g1W-S_FPh2E5YVCALwWSGPJLWBM,1493
|
|
3
3
|
lamindb_setup/_check.py,sha256=28PcG8Kp6OpjSLSi1r2boL2Ryeh6xkaCL87HFbjs6GA,129
|
|
4
4
|
lamindb_setup/_check_setup.py,sha256=d1GS1Csy2G9AysfjoyVcNVY0lhHiWSwSLpfgdIQf35s,5477
|
|
@@ -13,12 +13,12 @@ lamindb_setup/_init_instance.py,sha256=nZkqGqJQ_sF1-oQmnbpIjP1ExWUow5I5N7lsyX9m-
|
|
|
13
13
|
lamindb_setup/_migrate.py,sha256=drf7Lsa8oDXBPBWMWMge0n5VyNPvsrCFAhcXlN91OxM,9165
|
|
14
14
|
lamindb_setup/_register_instance.py,sha256=alQuYp2f8Ct8xvRC1gt8p_HZ0tqCd3gZD3kiPBLPpsI,1269
|
|
15
15
|
lamindb_setup/_schema.py,sha256=b3uzhhWpV5mQtDwhMINc2MabGCnGLESy51ito3yl6Wc,679
|
|
16
|
-
lamindb_setup/_schema_metadata.py,sha256=
|
|
16
|
+
lamindb_setup/_schema_metadata.py,sha256=cDkNHyFTFZq879UGY6i-rJEXfeBN59AN3Wz86caKnYI,14358
|
|
17
17
|
lamindb_setup/_set_managed_storage.py,sha256=4tDxXQMt8Gw028uY3vIQxZQ7qBNXhQMc8saarNK_Z-s,2043
|
|
18
18
|
lamindb_setup/_setup_user.py,sha256=-g7Xj6510BDyM8kuqAsVBZFwehlhBa_uWBSV1rPeuM8,4586
|
|
19
19
|
lamindb_setup/_silence_loggers.py,sha256=AKF_YcHvX32eGXdsYK8MJlxEaZ-Uo2f6QDRzjKFCtws,1568
|
|
20
20
|
lamindb_setup/core/__init__.py,sha256=BxIVMX5HQq8oZ1OuY_saUEJz5Tdd7gaCPngxVu5iou4,417
|
|
21
|
-
lamindb_setup/core/_aws_options.py,sha256=
|
|
21
|
+
lamindb_setup/core/_aws_options.py,sha256=Umxu_1AYd-0LJUElZxowvE9vNA7Z8kh_63g3pp1gfd8,7243
|
|
22
22
|
lamindb_setup/core/_aws_storage.py,sha256=nEjeUv4xUVpoV0Lx-zjjmyb9w804bDyaeiM-OqbfwM0,1799
|
|
23
23
|
lamindb_setup/core/_deprecated.py,sha256=HN7iUBdEgahw5e4NHCd1VJooUfieNb6GRzS5x8jU-q8,2549
|
|
24
24
|
lamindb_setup/core/_docs.py,sha256=3k-YY-oVaJd_9UIY-LfBg_u8raKOCNfkZQPA73KsUhs,276
|
|
@@ -36,12 +36,12 @@ lamindb_setup/core/_settings_store.py,sha256=WcsgOmgnu9gztcrhp-N4OONNZyxICHV8M0H
|
|
|
36
36
|
lamindb_setup/core/_settings_user.py,sha256=lWqV3HmZCsEq2UsU_iVNW0p9ddsNg7-B6xOaMNH1aw0,1475
|
|
37
37
|
lamindb_setup/core/_setup_bionty_sources.py,sha256=qTPMV5TEbNiTB81QqG2rSs6W8j8kQ7kVQMLOXRzAxBI,4004
|
|
38
38
|
lamindb_setup/core/cloud_sqlite_locker.py,sha256=i6TrT7HG0lqliPvZTlsZ_uplPaqhPBbabyfeR32SkA8,7107
|
|
39
|
-
lamindb_setup/core/django.py,sha256=
|
|
39
|
+
lamindb_setup/core/django.py,sha256=vmrGDiqX2FSmMII_YLcQtwO8SRzm6zKayjeNJLGhuiU,4697
|
|
40
40
|
lamindb_setup/core/exceptions.py,sha256=4NpLUNUIfXYVTFX2FvLZF8RW34exk2Vn2X3G4YhnTRg,276
|
|
41
41
|
lamindb_setup/core/hashing.py,sha256=M3Q1-ywnqh4Uy5zojbQfLju19HU0ySp8Oi7FGIJXfFI,3667
|
|
42
42
|
lamindb_setup/core/types.py,sha256=zJii2le38BJUmsNVvzDrbzGYr0yaeb-9Rw9IKmsBr3k,523
|
|
43
|
-
lamindb_setup/core/upath.py,sha256=
|
|
44
|
-
lamindb_setup-1.
|
|
45
|
-
lamindb_setup-1.
|
|
46
|
-
lamindb_setup-1.
|
|
47
|
-
lamindb_setup-1.
|
|
43
|
+
lamindb_setup/core/upath.py,sha256=AvRmICPBxQx-2iQYsXDFsrJS-AAUNuw6IymLcVmkWvo,33550
|
|
44
|
+
lamindb_setup-1.3.0.dist-info/LICENSE,sha256=UOZ1F5fFDe3XXvG4oNnkL1-Ecun7zpHzRxjp-XsMeAo,11324
|
|
45
|
+
lamindb_setup-1.3.0.dist-info/WHEEL,sha256=CpUCUxeHQbRN5UGRQHYRJorO5Af-Qy_fHMctcQ8DSGI,82
|
|
46
|
+
lamindb_setup-1.3.0.dist-info/METADATA,sha256=jGAuIu11oaJ-YYGXR4iXnh99vurdfu1vaJuEPL756gc,1777
|
|
47
|
+
lamindb_setup-1.3.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|