lamindb_setup 0.76.3__py2.py3-none-any.whl → 0.76.4__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 CHANGED
@@ -34,7 +34,7 @@ Modules & settings:
34
34
 
35
35
  """
36
36
 
37
- __version__ = "0.76.3" # denote a release candidate for 0.1.0 with 0.1rc1
37
+ __version__ = "0.76.4" # denote a release candidate for 0.1.0 with 0.1rc1
38
38
 
39
39
  import sys
40
40
  from os import name as _os_name
@@ -19,10 +19,10 @@ from ._hub_crud import (
19
19
  _delete_instance_record,
20
20
  select_account_by_handle,
21
21
  select_db_user_by_instance,
22
+ select_default_storage_by_instance_id,
22
23
  select_instance_by_id_with_storage,
23
24
  select_instance_by_name,
24
25
  select_instance_by_owner_name,
25
- select_storage,
26
26
  )
27
27
  from ._hub_crud import update_instance as _update_instance_record
28
28
  from ._hub_utils import (
@@ -338,7 +338,7 @@ def _connect_instance(
338
338
  if instance is None:
339
339
  return "instance-not-found"
340
340
  # get default storage
341
- storage = select_storage(instance["storage_id"], client)
341
+ storage = select_default_storage_by_instance_id(instance["id"], client)
342
342
  if storage is None:
343
343
  return "storage-does-not-exist-on-hub"
344
344
  else:
@@ -364,7 +364,7 @@ def _connect_instance(
364
364
  database=instance["db_database"],
365
365
  )
366
366
  instance["db"] = db_dsn
367
- return instance, storage
367
+ return instance, storage # type: ignore
368
368
 
369
369
 
370
370
  def access_aws(storage_root: str, access_token: str | None = None) -> dict[str, dict]:
@@ -17,10 +17,11 @@ def select_instance_by_owner_name(
17
17
  client.table("instance")
18
18
  .select(
19
19
  "*, account!inner!instance_account_id_28936e8f_fk_account_id(*),"
20
- " storage!instance_storage_id_87963cc8_fk_storage_id(*)"
20
+ " storage!inner!storage_instance_id_359fca71_fk_instance_id(*)"
21
21
  )
22
- .eq("account.handle", owner)
23
22
  .eq("name", name)
23
+ .eq("account.handle", owner)
24
+ .eq("storage.is_default", True)
24
25
  .execute()
25
26
  .data
26
27
  )
@@ -28,7 +29,11 @@ def select_instance_by_owner_name(
28
29
  return None
29
30
  if len(data) == 0:
30
31
  return None
31
- return data[0]
32
+ result = data[0]
33
+ # this is now a list
34
+ # assume only one default storage
35
+ result["storage"] = result["storage"][0]
36
+ return result
32
37
 
33
38
 
34
39
  # --------------- ACCOUNT ----------------------
@@ -131,8 +136,20 @@ def select_collaborator(
131
136
  # --------------- STORAGE ----------------------
132
137
 
133
138
 
134
- def select_storage(id: str, client: Client):
135
- data = client.table("storage").select("*").eq("id", id).execute().data
139
+ def select_default_storage_by_instance_id(
140
+ instance_id: str, client: Client
141
+ ) -> dict | None:
142
+ try:
143
+ data = (
144
+ client.table("storage")
145
+ .select("*")
146
+ .eq("instance_id", instance_id)
147
+ .eq("is_default", True)
148
+ .execute()
149
+ .data
150
+ )
151
+ except Exception:
152
+ return None
136
153
  if len(data) == 0:
137
154
  return None
138
155
  return data[0]
@@ -36,14 +36,9 @@ def load_instance_settings(instance_settings_file: Path | None = None):
36
36
  content = f.read()
37
37
  raise SettingsEnvFileOutdated(
38
38
  f"\n\n{error}\n\nYour instance settings file with\n\n{content}\nis invalid"
39
- f" (likely outdated), please delete {instance_settings_file} &"
40
- " re-initialize (local) or re-connect to the instance (remote)"
39
+ f" (likely outdated), see validation error. Please delete {instance_settings_file} &"
40
+ " reload (remote) or re-initialize (local) the instance with the same name & storage location."
41
41
  ) from error
42
- if settings_store.id == "null":
43
- raise ValueError(
44
- "Your instance._id is undefined, please either load your instance from the"
45
- f" hub or update {instance_settings_file} with a new id: {uuid4().hex}"
46
- )
47
42
  isettings = setup_instance_from_store(settings_store)
48
43
  return isettings
49
44
 
@@ -18,7 +18,7 @@ from upath.implementations.cloud import CloudPath, S3Path # keep CloudPath!
18
18
  from upath.implementations.local import LocalPath, PosixUPath, WindowsUPath
19
19
 
20
20
  from ._aws_credentials import HOSTED_BUCKETS, get_aws_credentials_manager
21
- from .hashing import b16_to_b64, hash_md5s_from_dir
21
+ from .hashing import HASH_LENGTH, b16_to_b64, hash_md5s_from_dir
22
22
 
23
23
  if TYPE_CHECKING:
24
24
  from .types import UPathStr
@@ -707,9 +707,9 @@ def get_stat_file_cloud(stat: dict) -> tuple[int, str, str]:
707
707
  else:
708
708
  stripped_etag, suffix = etag.split("-")
709
709
  suffix = suffix.strip('"')
710
- hash = f"{b16_to_b64(stripped_etag)}-{suffix}"
711
- hash_type = "md5-n" # this is the S3 chunk-hashing strategy
712
- return size, hash, hash_type
710
+ hash = b16_to_b64(stripped_etag)
711
+ hash_type = f"md5-{suffix}" # this is the S3 chunk-hashing strategy
712
+ return size, hash[:HASH_LENGTH], hash_type
713
713
 
714
714
 
715
715
  def get_stat_dir_cloud(path: UPath) -> tuple[int, str, str, int]:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lamindb_setup
3
- Version: 0.76.3
3
+ Version: 0.76.4
4
4
  Summary: Setup & configure LaminDB.
5
5
  Author-email: Lamin Labs <open-source@lamin.ai>
6
6
  Description-Content-Type: text/markdown
@@ -1,4 +1,4 @@
1
- lamindb_setup/__init__.py,sha256=hXWSzOTJWwpoCg2nw2RH87bEJu7oXk_jyxAbJdcrsYU,1542
1
+ lamindb_setup/__init__.py,sha256=Rx_9cNg5fupK0-Rj7m3ms6u7mrLnirEkiiMlGktz7QM,1542
2
2
  lamindb_setup/_cache.py,sha256=wA7mbysANwe8hPNbjDo9bOmXJ0xIyaS5iyxIpxSWji4,846
3
3
  lamindb_setup/_check.py,sha256=28PcG8Kp6OpjSLSi1r2boL2Ryeh6xkaCL87HFbjs6GA,129
4
4
  lamindb_setup/_check_setup.py,sha256=cNEL9Q4yPpmEkGKHH8JgullWl1VUZwALJ4RHn9wZypY,2613
@@ -22,13 +22,13 @@ lamindb_setup/core/_aws_storage.py,sha256=nEjeUv4xUVpoV0Lx-zjjmyb9w804bDyaeiM-Oq
22
22
  lamindb_setup/core/_deprecated.py,sha256=3qxUI1dnDlSeR0BYrv7ucjqRBEojbqotPgpShXs4KF8,2520
23
23
  lamindb_setup/core/_docs.py,sha256=3k-YY-oVaJd_9UIY-LfBg_u8raKOCNfkZQPA73KsUhs,276
24
24
  lamindb_setup/core/_hub_client.py,sha256=Gpt3TmxWQMVenKugCu1agUb-xGN9YFsQOKmrHuFiiDs,5605
25
- lamindb_setup/core/_hub_core.py,sha256=XqXZatJOIDXukfdwL3Buq3WXZK-VVGg5OFRm2PrzO1o,16836
26
- lamindb_setup/core/_hub_crud.py,sha256=b1XF7AJpM9Q-ttm9nPG-r3OTRWHQaGzAGIyvmb83NTo,4859
25
+ lamindb_setup/core/_hub_core.py,sha256=cyLyEQcVTC2Dd6G-M0-O1Ur0ujI5IMKq1YXVpn4faCs,16890
26
+ lamindb_setup/core/_hub_crud.py,sha256=eZErpq9t1Cp2ULBSi457ekrcqfesw4Y6IJgaqyrINMY,5276
27
27
  lamindb_setup/core/_hub_utils.py,sha256=w5IRtrxZcvxmGSJslzuZF89ewkzXV4cCUmZUVrqmAfo,3026
28
28
  lamindb_setup/core/_private_django_api.py,sha256=KIn43HOhiRjkbTbddyJqv-WNTTa1bAizbM1tWXoXPBg,2869
29
29
  lamindb_setup/core/_settings.py,sha256=46axQ5HPvI0X9YuotgdpuSOfSo7qYU1DudIx3vxpFk0,4471
30
30
  lamindb_setup/core/_settings_instance.py,sha256=rPTL_Iwv-ZVMRzu_EV_E7APFkEXLoD0TgUrz5293-vg,17586
31
- lamindb_setup/core/_settings_load.py,sha256=63PTIVLk3oH1XUmznswygcOk_8VADrJLMB6O9AOppYg,3907
31
+ lamindb_setup/core/_settings_load.py,sha256=bRkGgaEnLZmnOlU5ptDoSM-YXzC2l0Cb7RBoBY6VH9k,3717
32
32
  lamindb_setup/core/_settings_save.py,sha256=n_tYfb9EBSxwm4LHyPRHJptE5uB8lmHhcRkz1JkAmhg,2781
33
33
  lamindb_setup/core/_settings_storage.py,sha256=bvEOm2aH4M6xBTfTARcWkx6b-jtKYl_AIUbH5yQC9GI,13435
34
34
  lamindb_setup/core/_settings_store.py,sha256=VEE8Ff2A7y4j8ksOaa7g48jNaOqe1PBnBjb1PKKGUKU,2115
@@ -39,8 +39,8 @@ lamindb_setup/core/django.py,sha256=QUQm3zt5QIiD8uv6o9vbSm_bshqiSWzKSkgD3z2eJCg,
39
39
  lamindb_setup/core/exceptions.py,sha256=eoI7AXgATgDVzgArtN7CUvpaMUC067vsBg5LHCsWzDM,305
40
40
  lamindb_setup/core/hashing.py,sha256=Y2cvEaqtm3KwpHqj5ZG2f_sLaXhsQT4oDrmJdHbOQeo,3116
41
41
  lamindb_setup/core/types.py,sha256=bcYnZ0uM_2NXKJCl94Mmc-uYrQlRUUVKG3sK2N-F-N4,532
42
- lamindb_setup/core/upath.py,sha256=Bhxr1B1sFuIp13YTBOEYJSmSOwmU6owk8giBGLCKdg4,27194
43
- lamindb_setup-0.76.3.dist-info/LICENSE,sha256=UOZ1F5fFDe3XXvG4oNnkL1-Ecun7zpHzRxjp-XsMeAo,11324
44
- lamindb_setup-0.76.3.dist-info/WHEEL,sha256=Sgu64hAMa6g5FdzHxXv9Xdse9yxpGGMeagVtPMWpJQY,99
45
- lamindb_setup-0.76.3.dist-info/METADATA,sha256=29omTu3ShcauGqhxT0g_ZAAuOBZveomsA-hFBH3OGzs,1638
46
- lamindb_setup-0.76.3.dist-info/RECORD,,
42
+ lamindb_setup/core/upath.py,sha256=EPLLm62q-Y3hZzd-286cynFMttXKDNXNOKL3_QGkeug,27215
43
+ lamindb_setup-0.76.4.dist-info/LICENSE,sha256=UOZ1F5fFDe3XXvG4oNnkL1-Ecun7zpHzRxjp-XsMeAo,11324
44
+ lamindb_setup-0.76.4.dist-info/WHEEL,sha256=Sgu64hAMa6g5FdzHxXv9Xdse9yxpGGMeagVtPMWpJQY,99
45
+ lamindb_setup-0.76.4.dist-info/METADATA,sha256=7Oeyg7Uvp5hFrFw37iJcUOiyrvsI9DxWGBbRtqeZJhs,1638
46
+ lamindb_setup-0.76.4.dist-info/RECORD,,