lamindb_setup 0.77.5__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 CHANGED
@@ -21,7 +21,6 @@ Instance operations:
21
21
  :toctree:
22
22
 
23
23
  migrate
24
- register
25
24
 
26
25
  Modules & settings:
27
26
 
@@ -34,7 +33,7 @@ Modules & settings:
34
33
 
35
34
  """
36
35
 
37
- __version__ = "0.77.5" # denote a release candidate for 0.1.0 with 0.1rc1
36
+ __version__ = "0.77.6" # denote a release candidate for 0.1.0 with 0.1rc1
38
37
 
39
38
  import os as _os
40
39
  import sys as _sys
@@ -1,5 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
+ import importlib as il
3
4
  import os
4
5
  from typing import TYPE_CHECKING, Optional
5
6
 
@@ -52,9 +53,18 @@ def _get_current_instance_settings() -> InstanceSettings | None:
52
53
 
53
54
 
54
55
  # we make this a private function because in all the places it's used,
55
- # users should see it
56
- def _check_instance_setup(from_lamindb: bool = False) -> bool:
56
+ # users should not see it
57
+ def _check_instance_setup(
58
+ from_lamindb: bool = False, from_module: str | None = None
59
+ ) -> bool:
60
+ reload_module = from_lamindb or from_module is not None
61
+ from ._init_instance import get_schema_module_name, reload_schema_modules
62
+
57
63
  if django.IS_SETUP:
64
+ # reload logic here because module might not yet have been imported
65
+ # upon first setup
66
+ if from_module is not None:
67
+ il.reload(il.import_module(from_module))
58
68
  return True
59
69
  silence_loggers()
60
70
  if os.environ.get("LAMINDB_MULTI_INSTANCE") == "true":
@@ -65,15 +75,18 @@ def _check_instance_setup(from_lamindb: bool = False) -> bool:
65
75
  return True
66
76
  isettings = _get_current_instance_settings()
67
77
  if isettings is not None:
68
- if from_lamindb and settings.auto_connect:
78
+ if reload_module and settings.auto_connect:
69
79
  if not django.IS_SETUP:
70
- from ._init_instance import reload_schema_modules
71
-
72
80
  django.setup_django(isettings)
73
- reload_schema_modules(isettings)
81
+ if from_module is not None:
82
+ # this only reloads `from_module`
83
+ il.reload(il.import_module(from_module))
84
+ else:
85
+ # this bulk reloads all schema modules
86
+ reload_schema_modules(isettings)
74
87
  logger.important(f"connected lamindb: {isettings.slug}")
75
88
  return django.IS_SETUP
76
89
  else:
77
- if from_lamindb and settings.auto_connect:
90
+ if reload_module and settings.auto_connect:
78
91
  logger.warning(InstanceNotSetupError.default_message)
79
92
  return False
@@ -1,6 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import os
4
+ import sys
4
5
  from typing import TYPE_CHECKING
5
6
  from uuid import UUID
6
7
 
@@ -9,10 +10,8 @@ from lamin_utils import logger
9
10
  from ._check_setup import _check_instance_setup
10
11
  from ._close import close as close_instance
11
12
  from ._init_instance import MESSAGE_NO_MULTIPLE_INSTANCE, load_from_isettings
12
- from ._migrate import check_whether_migrations_in_sync
13
13
  from ._silence_loggers import silence_loggers
14
- from .core._hub_core import connect_instance as load_instance_from_hub
15
- from .core._hub_core import connect_instance_new as load_instance_from_hub_edge
14
+ from .core._hub_core import connect_instance as connect_instance_from_hub
16
15
  from .core._hub_utils import (
17
16
  LaminDsn,
18
17
  LaminDsnModel,
@@ -129,14 +128,9 @@ def _connect_instance(
129
128
  # on the hub
130
129
  # do not call hub if the user is anonymous
131
130
  if owner != "anonymous":
132
- if settings.user.handle in {"Koncopd", "sunnyosun", "falexwolf"}:
133
- hub_result = load_instance_from_hub_edge(
134
- owner=owner, name=name, access_token=access_token
135
- )
136
- else:
137
- hub_result = load_instance_from_hub(
138
- owner=owner, name=name, access_token=access_token
139
- )
131
+ hub_result = connect_instance_from_hub(
132
+ owner=owner, name=name, access_token=access_token
133
+ )
140
134
  else:
141
135
  hub_result = "anonymous-user"
142
136
  # if hub_result is not a string, it means it made a request
@@ -167,7 +161,6 @@ def _connect_instance(
167
161
  keep_artifacts_local=bool(instance_result["keep_artifacts_local"]),
168
162
  is_on_hub=True,
169
163
  )
170
- check_whether_migrations_in_sync(instance_result["lamindb_version"])
171
164
  else:
172
165
  if hub_result != "anonymous-user":
173
166
  message = INSTANCE_NOT_FOUND_MESSAGE.format(
@@ -313,6 +306,7 @@ def load(slug: str) -> str | tuple | None:
313
306
  This is exactly the same as ``ln.connect()`` except for that
314
307
  ``ln.connect()`` doesn't change the state of ``auto-connect``.
315
308
  """
309
+ print("Warning: This is deprecated and will be removed.")
316
310
  result = connect(slug)
317
311
  settings.auto_connect = True
318
312
  return result
@@ -97,8 +97,9 @@ def register_user_and_storage_in_instance(isettings: InstanceSettings, usettings
97
97
  logger.warning(f"instance seems not set up ({error})")
98
98
 
99
99
 
100
- def reload_schema_modules(isettings: InstanceSettings):
101
- schema_names = ["core"] + list(isettings.schema)
100
+ def reload_schema_modules(isettings: InstanceSettings, include_core: bool = True):
101
+ schema_names = ["core"] if include_core else []
102
+ # schema_names += list(isettings.schema)
102
103
  schema_module_names = [get_schema_module_name(n) for n in schema_names]
103
104
 
104
105
  for schema_module_name in schema_module_names:
@@ -114,16 +115,10 @@ def reload_lamindb_itself(isettings) -> bool:
114
115
 
115
116
  importlib.reload(lamindb)
116
117
  reloaded = True
117
- if "bionty" in isettings.schema and "bionty" in sys.modules:
118
- schema_module = importlib.import_module("bionty")
119
- importlib.reload(schema_module)
120
- reloaded = True
121
118
  return reloaded
122
119
 
123
120
 
124
121
  def reload_lamindb(isettings: InstanceSettings):
125
- # only touch lamindb if we're operating from lamindb
126
- reload_schema_modules(isettings)
127
122
  log_message = settings.auto_connect
128
123
  if not reload_lamindb_itself(isettings):
129
124
  log_message = True
@@ -214,7 +209,7 @@ def validate_init_args(
214
209
  MESSAGE_NO_MULTIPLE_INSTANCE = """
215
210
  Currently don't support subsequent connection to different databases in the same
216
211
  Python session.\n
217
- Try running on the CLI: lamin set auto-connect false
212
+ Try running on the CLI: lamin settings set auto-connect false
218
213
  """
219
214
 
220
215
 
@@ -352,7 +347,7 @@ def load_from_isettings(
352
347
  user: UserSettings | None = None,
353
348
  write_settings: bool = True,
354
349
  ) -> None:
355
- from .core._setup_bionty_sources import load_bionty_sources, write_bionty_sources
350
+ from .core._setup_bionty_sources import write_bionty_sources
356
351
 
357
352
  user = settings.user if user is None else user
358
353
 
@@ -370,7 +365,6 @@ def load_from_isettings(
370
365
  # yet be registered
371
366
  if not isettings._get_settings_file().exists():
372
367
  register_user(user)
373
- load_bionty_sources(isettings)
374
368
  isettings._persist(write_to_disk=write_settings)
375
369
  reload_lamindb(isettings)
376
370
 
lamindb_setup/_migrate.py CHANGED
@@ -30,7 +30,7 @@ def check_whether_migrations_in_sync(db_version_str: str):
30
30
  db_version_lower = f"{db_version.major}.{db_version.minor}"
31
31
  db_version_upper = f"{db_version.major}.{db_version.minor + 1}"
32
32
  logger.warning(
33
- f"your database ({db_version_str}) is ahead of your installed lamindb"
33
+ f"the database ({db_version_str}) is ahead of your installed lamindb"
34
34
  f" package ({installed_version_str})"
35
35
  )
36
36
  logger.important(
@@ -42,10 +42,10 @@ def check_whether_migrations_in_sync(db_version_str: str):
42
42
  or installed_version.minor > db_version.minor
43
43
  ):
44
44
  logger.warning(
45
- f"your database ({db_version_str}) is behind your installed lamindb package"
45
+ f"the database ({db_version_str}) is behind your installed lamindb package"
46
46
  f" ({installed_version_str})"
47
47
  )
48
- logger.important("please migrate your database: lamin migrate deploy")
48
+ logger.important("consider migrating your database: lamin migrate deploy")
49
49
 
50
50
 
51
51
  # for tests, see lamin-cli
@@ -95,7 +95,7 @@ def get_access_token(
95
95
  try:
96
96
  if api_key is not None:
97
97
  auth_response = hub.functions.invoke(
98
- "create-jwt",
98
+ "get-jwt-v1",
99
99
  invoke_options={"body": {"api_key": api_key}},
100
100
  )
101
101
  return json.loads(auth_response)["accessToken"]
@@ -10,6 +10,8 @@ from uuid import UUID
10
10
  from lamin_utils import logger
11
11
  from postgrest.exceptions import APIError
12
12
 
13
+ from lamindb_setup._migrate import check_whether_migrations_in_sync
14
+
13
15
  from ._hub_client import (
14
16
  call_with_fallback,
15
17
  call_with_fallback_auth,
@@ -381,6 +383,7 @@ def _connect_instance(
381
383
  database=instance["db_database"],
382
384
  )
383
385
  instance["db"] = db_dsn
386
+ check_whether_migrations_in_sync(instance["lamindb_version"])
384
387
  return instance, storage # type: ignore
385
388
 
386
389
 
@@ -390,7 +393,8 @@ def _connect_instance_new(
390
393
  client: Client,
391
394
  ) -> tuple[dict, dict] | str:
392
395
  response = client.functions.invoke(
393
- "get-instance-settings", invoke_options={"body": {"owner": owner, "name": name}}
396
+ "get-instance-settings-v1",
397
+ invoke_options={"body": {"owner": owner, "name": name}},
394
398
  )
395
399
  # no instance found, check why is that
396
400
  if response == b"{}":
@@ -471,7 +475,7 @@ def _access_aws(*, storage_root: str, client: Client) -> dict[str, dict]:
471
475
 
472
476
  storage_root_info: dict[str, dict] = {"credentials": {}, "accessibility": {}}
473
477
  response = client.functions.invoke(
474
- "access-aws",
478
+ "get-cloud-access-v1",
475
479
  invoke_options={"body": {"storage_root": storage_root}},
476
480
  )
477
481
  if response is not None and response != b"{}":
@@ -563,7 +567,7 @@ def sign_in_hub(
563
567
 
564
568
  def _sign_in_hub_api_key(api_key: str, client: Client):
565
569
  response = client.functions.invoke(
566
- "create-jwt",
570
+ "get-jwt-v1",
567
571
  invoke_options={"body": {"api_key": api_key}},
568
572
  )
569
573
  access_token = json.loads(response)["accessToken"]
@@ -599,7 +603,7 @@ def sign_in_hub_api_key(
599
603
 
600
604
  def _create_api_key(body: dict, client: Client) -> str:
601
605
  response = client.functions.invoke(
602
- "create-api-key",
606
+ "create-api-key-v1",
603
607
  invoke_options={"body": body},
604
608
  )
605
609
  api_key = json.loads(response)["apiKey"]
@@ -40,11 +40,18 @@ class SetupSettings:
40
40
 
41
41
  @property
42
42
  def auto_connect(self) -> bool:
43
- """Auto-connect to loaded instance upon lamindb import.
43
+ """Auto-connect to current instance upon `import lamindb`.
44
44
 
45
- `lamin init` and `lamin load` switch this to `True`.
45
+ Upon installing `lamindb`, this setting is `False`.
46
+
47
+ Upon calling `lamin init` or `lamin connect` on the CLI, this setting is switched to `True`.
46
48
 
47
49
  `ln.connect()` doesn't change the value of this setting.
50
+
51
+ You can manually change this setting
52
+
53
+ - in Python: `ln.setup.settings.auto_connect = True/False`
54
+ - via the CLI: `lamin settings set auto-connect true/false`
48
55
  """
49
56
  return self._auto_connect_path.exists()
50
57
 
@@ -50,4 +50,6 @@ class UserSettings:
50
50
  """Integer id valid in current intance."""
51
51
  from lnschema_core.users import current_user_id
52
52
 
53
+ # there is no cache needed here because current_user_id()
54
+ # has its own cache
53
55
  return current_user_id()
@@ -8,6 +8,7 @@ import time
8
8
  from lamin_utils import logger
9
9
  from ._settings_store import current_instance_settings_file
10
10
  from ._settings_instance import InstanceSettings
11
+ import sys
11
12
 
12
13
  IS_RUN_FROM_IPYTHON = getattr(builtins, "__IPYTHON__", False)
13
14
  IS_SETUP = False
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lamindb_setup
3
- Version: 0.77.5
3
+ Version: 0.77.6
4
4
  Summary: Setup & configure LaminDB.
5
5
  Author-email: Lamin Labs <open-source@lamin.ai>
6
6
  Description-Content-Type: text/markdown
@@ -13,12 +13,13 @@ Requires-Dist: appdirs<2.0.0
13
13
  Requires-Dist: requests
14
14
  Requires-Dist: universal_pathlib==0.2.2
15
15
  Requires-Dist: botocore<2.0.0
16
- Requires-Dist: gotrue>=2.1.0
16
+ Requires-Dist: gotrue>=2.1.0,<2.9.0
17
17
  Requires-Dist: supabase==2.2.1
18
18
  Requires-Dist: psutil
19
19
  Requires-Dist: urllib3<2 ; extra == "aws"
20
20
  Requires-Dist: aiobotocore[boto3]>=2.5.4,<3.0.0 ; extra == "aws"
21
21
  Requires-Dist: s3fs>=2023.12.2,<=2024.6.1 ; extra == "aws"
22
+ Requires-Dist: line_profiler ; extra == "dev"
22
23
  Requires-Dist: pyjwt<3.0.0 ; extra == "dev"
23
24
  Requires-Dist: psycopg2-binary ; extra == "dev"
24
25
  Requires-Dist: python-dotenv ; extra == "dev"
@@ -1,16 +1,16 @@
1
- lamindb_setup/__init__.py,sha256=xFULHTbMc-3W9v672Rp_JMtYQWsnvCt07pg_D3cmYE8,1726
1
+ lamindb_setup/__init__.py,sha256=3qptBEx3XgP2xGXW0donxKwq7KWLy6-w5OKUD1ni-Cw,1714
2
2
  lamindb_setup/_cache.py,sha256=wA7mbysANwe8hPNbjDo9bOmXJ0xIyaS5iyxIpxSWji4,846
3
3
  lamindb_setup/_check.py,sha256=28PcG8Kp6OpjSLSi1r2boL2Ryeh6xkaCL87HFbjs6GA,129
4
- lamindb_setup/_check_setup.py,sha256=CnAl5-SoYgv5iyv07fG4dfGWRTyhE_ljxtMVFc8Ef5k,2622
4
+ lamindb_setup/_check_setup.py,sha256=gGKLVBdVAii3C12AUzAKSRu_WtNsMNo2n-bMpT5MwMk,3197
5
5
  lamindb_setup/_close.py,sha256=cXNwK7QTTyNFt2XTpLnO3KHljJ7ShOcISk95np_dltE,1239
6
- lamindb_setup/_connect_instance.py,sha256=jS5P4TNQxNiwP-bGWUPCAKzajpJ3folQSwmMzxq3PJc,16183
6
+ lamindb_setup/_connect_instance.py,sha256=uxZ6yLA4h1d6Ooan3MkZWqfgNbsy-DLaCtSq7IUCFLc,15792
7
7
  lamindb_setup/_delete.py,sha256=4QlV7xEyWuHrjNqRXbqZVY99hm7EngzpWkV1a5FMITs,5685
8
8
  lamindb_setup/_django.py,sha256=EoyWvFzH0i9wxjy4JZhcoXCTckztP_Mrl6FbYQnMmLE,1534
9
9
  lamindb_setup/_entry_points.py,sha256=Hs2oJQOCTaGUdWn-1mufM6qUZr9W_EJ_Oc3f0_Vc0Yw,616
10
10
  lamindb_setup/_exportdb.py,sha256=43g77-tH-vAlTn8ig1mMD9-KXLKvxUeDLaq0gVu3l-c,2114
11
11
  lamindb_setup/_importdb.py,sha256=yYYShzUajTsR-cTW4CZ-UNDWZY2uE5PAgNbp-wn8Ogc,1874
12
- lamindb_setup/_init_instance.py,sha256=VJicXerxZaOZVKDvFhHvZb1lBA6VC6JSLU7Ttp478Xw,14149
13
- lamindb_setup/_migrate.py,sha256=tbpZVDwWivd2BZomx_D-3XyvMFMSehgoIs4LpqS2w9A,8915
12
+ lamindb_setup/_init_instance.py,sha256=K2jTSkIbcZgDr9S2ZFJHvMzuhTlacccAX3qSp3s9oqU,13888
13
+ lamindb_setup/_migrate.py,sha256=x_b4k4XRfLSD-EEFMc324yK6DIK7goW33wUytbIWlNs,8917
14
14
  lamindb_setup/_register_instance.py,sha256=alQuYp2f8Ct8xvRC1gt8p_HZ0tqCd3gZD3kiPBLPpsI,1269
15
15
  lamindb_setup/_schema.py,sha256=b3uzhhWpV5mQtDwhMINc2MabGCnGLESy51ito3yl6Wc,679
16
16
  lamindb_setup/_schema_metadata.py,sha256=49wDLbhRhatDeADjHOPfQURt65lf_OZ7lob1ZiAT_ac,13773
@@ -22,26 +22,26 @@ lamindb_setup/core/_aws_credentials.py,sha256=uKMQO9q42Hnepz8aj3RxwLKDWUJx8pNOYr
22
22
  lamindb_setup/core/_aws_storage.py,sha256=nEjeUv4xUVpoV0Lx-zjjmyb9w804bDyaeiM-OqbfwM0,1799
23
23
  lamindb_setup/core/_deprecated.py,sha256=3qxUI1dnDlSeR0BYrv7ucjqRBEojbqotPgpShXs4KF8,2520
24
24
  lamindb_setup/core/_docs.py,sha256=3k-YY-oVaJd_9UIY-LfBg_u8raKOCNfkZQPA73KsUhs,276
25
- lamindb_setup/core/_hub_client.py,sha256=8sD_AbH_Iaw87Vdcoe3Va0I-_kT2jfYjfWM2zbuQETg,6117
26
- lamindb_setup/core/_hub_core.py,sha256=ojE7BU02XBL3S31b7sZvWgGBxfABJeQkc-lEMGtsk_4,22016
25
+ lamindb_setup/core/_hub_client.py,sha256=P11Ma0nDsBHlKcnyOmq75dHDzYYJfmfpTePJ-0348Wo,6117
26
+ lamindb_setup/core/_hub_core.py,sha256=FNurUyQMn_b5ROQvA1GxJabrXGKNI1aY_gB83Y4Ox7s,22175
27
27
  lamindb_setup/core/_hub_crud.py,sha256=eZErpq9t1Cp2ULBSi457ekrcqfesw4Y6IJgaqyrINMY,5276
28
28
  lamindb_setup/core/_hub_utils.py,sha256=w5IRtrxZcvxmGSJslzuZF89ewkzXV4cCUmZUVrqmAfo,3026
29
29
  lamindb_setup/core/_private_django_api.py,sha256=KIn43HOhiRjkbTbddyJqv-WNTTa1bAizbM1tWXoXPBg,2869
30
- lamindb_setup/core/_settings.py,sha256=46axQ5HPvI0X9YuotgdpuSOfSo7qYU1DudIx3vxpFk0,4471
30
+ lamindb_setup/core/_settings.py,sha256=tICfPkGVJz9SDmIJu9MvERTt9vx1evvsoOxZ9Rummhs,4757
31
31
  lamindb_setup/core/_settings_instance.py,sha256=F5r4T3ahOsx-T_agO-JDsAddQ6ANfgzjcduRttaE6Yc,18605
32
32
  lamindb_setup/core/_settings_load.py,sha256=n7-_vg7YfuoMo4wdwwL2hdBjorywTq0GiprsfILWCko,3720
33
33
  lamindb_setup/core/_settings_save.py,sha256=2sd8o-5MHazfDFO13iRIuCDpmzztn2b5J3fmfw4MGxY,2787
34
34
  lamindb_setup/core/_settings_storage.py,sha256=7laDJWqyWhsbCZXQhcpgPaZTGBKPdv_zSDWPbLOypTc,14839
35
35
  lamindb_setup/core/_settings_store.py,sha256=WcsgOmgnu9gztcrhp-N4OONNZyxICHV8M0HdJllTaEo,2219
36
- lamindb_setup/core/_settings_user.py,sha256=N3a3CjZSCs0TW5Q0A_HVUaKBCpb0_82wZMoa5C_YsbA,1390
36
+ lamindb_setup/core/_settings_user.py,sha256=GzDSHu-KCxXcNs8RwBNr6hg3MjQ_fYmb3aIAiaTNiS8,1484
37
37
  lamindb_setup/core/_setup_bionty_sources.py,sha256=o2L5Ww8TKgSqJtL4cGUcpJwLNYxA9BZgddhCMCu_E2g,3428
38
38
  lamindb_setup/core/cloud_sqlite_locker.py,sha256=qZdzQNguhsogNKMurZdjQVQ1Sl1iWg8JbpyHJchw0Z4,7124
39
- lamindb_setup/core/django.py,sha256=3pVbUWDSU2mkMLCFRGAWpIHdFUinnDI9zga5WrcM47g,3589
39
+ lamindb_setup/core/django.py,sha256=GTWF0yV2tp7EnvPtOzIWbLuhTxmqaZAxq1xnwd54hho,3600
40
40
  lamindb_setup/core/exceptions.py,sha256=eoI7AXgATgDVzgArtN7CUvpaMUC067vsBg5LHCsWzDM,305
41
41
  lamindb_setup/core/hashing.py,sha256=Y2cvEaqtm3KwpHqj5ZG2f_sLaXhsQT4oDrmJdHbOQeo,3116
42
42
  lamindb_setup/core/types.py,sha256=bcYnZ0uM_2NXKJCl94Mmc-uYrQlRUUVKG3sK2N-F-N4,532
43
43
  lamindb_setup/core/upath.py,sha256=EPLLm62q-Y3hZzd-286cynFMttXKDNXNOKL3_QGkeug,27215
44
- lamindb_setup-0.77.5.dist-info/LICENSE,sha256=UOZ1F5fFDe3XXvG4oNnkL1-Ecun7zpHzRxjp-XsMeAo,11324
45
- lamindb_setup-0.77.5.dist-info/WHEEL,sha256=Sgu64hAMa6g5FdzHxXv9Xdse9yxpGGMeagVtPMWpJQY,99
46
- lamindb_setup-0.77.5.dist-info/METADATA,sha256=BXXOiGVOVa53hZzWInCa2M2wfNcJG_kQNUlM2K58ObM,1667
47
- lamindb_setup-0.77.5.dist-info/RECORD,,
44
+ lamindb_setup-0.77.6.dist-info/LICENSE,sha256=UOZ1F5fFDe3XXvG4oNnkL1-Ecun7zpHzRxjp-XsMeAo,11324
45
+ lamindb_setup-0.77.6.dist-info/WHEEL,sha256=Sgu64hAMa6g5FdzHxXv9Xdse9yxpGGMeagVtPMWpJQY,99
46
+ lamindb_setup-0.77.6.dist-info/METADATA,sha256=TBuZyQCZHvwsUyttACupkTVW2YawJSiZigfu7e9BJCw,1720
47
+ lamindb_setup-0.77.6.dist-info/RECORD,,