lamindb_setup 0.81.3__py3-none-any.whl → 1.0a1__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
@@ -33,7 +33,7 @@ Modules & settings:
33
33
 
34
34
  """
35
35
 
36
- __version__ = "0.81.3" # denote a release candidate for 0.1.0 with 0.1rc1
36
+ __version__ = "1.0a1" # denote a release candidate for 0.1.0 with 0.1rc1
37
37
 
38
38
  import os as _os
39
39
  import sys as _sys
@@ -51,7 +51,36 @@ from ._register_instance import register
51
51
  from ._setup_user import login, logout
52
52
  from .core._settings import settings
53
53
 
54
- _TESTING = _os.getenv("LAMIN_TESTING") is not None
54
+
55
+ def _is_CI_environment() -> bool:
56
+ ci_env_vars = [
57
+ "LAMIN_TESTING", # Set by our nox configurations
58
+ "CI", # Commonly set by many CI systems
59
+ "TRAVIS", # Travis CI
60
+ "GITHUB_ACTIONS", # GitHub Actions
61
+ "GITLAB_CI", # GitLab CI/CD
62
+ "CIRCLECI", # CircleCI
63
+ "JENKINS_URL", # Jenkins
64
+ "TEAMCITY_VERSION", # TeamCity
65
+ "BUILDKITE", # Buildkite
66
+ "BITBUCKET_BUILD_NUMBER", # Bitbucket Pipelines
67
+ "APPVEYOR", # AppVeyor
68
+ "AZURE_HTTP_USER_AGENT", # Azure Pipelines
69
+ "BUDDY", # Buddy
70
+ "DRONE", # Drone CI
71
+ "HUDSON_URL", # Hudson
72
+ "CF_BUILD_ID", # Codefresh
73
+ "WERCKER", # Wercker
74
+ "NOW_BUILDER", # ZEIT Now
75
+ "TASKCLUSTER_ROOT_URL", # TaskCluster
76
+ "SEMAPHORE", # Semaphore CI
77
+ "BUILD_ID", # Generic build environments
78
+ ]
79
+ return any(env_var in _os.environ for env_var in ci_env_vars)
80
+
81
+
82
+ _TESTING = _is_CI_environment()
83
+
55
84
 
56
85
  # hide the supabase error in a thread on windows
57
86
  if _os.name == "nt":
@@ -27,6 +27,7 @@ If you used the CLI to set up lamindb in a notebook, restart the Python session.
27
27
 
28
28
 
29
29
  CURRENT_ISETTINGS: InstanceSettings | None = None
30
+ IS_LOADING: bool = False
30
31
 
31
32
 
32
33
  def _get_current_instance_settings() -> InstanceSettings | None:
@@ -54,16 +55,11 @@ def _get_current_instance_settings() -> InstanceSettings | None:
54
55
 
55
56
  # we make this a private function because in all the places it's used,
56
57
  # 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
-
58
+ def _check_instance_setup(from_module: str | None = None) -> bool:
63
59
  if django.IS_SETUP:
64
60
  # reload logic here because module might not yet have been imported
65
61
  # upon first setup
66
- if from_module is not None:
62
+ if from_module is not None and from_module != "lamindb":
67
63
  il.reload(il.import_module(from_module))
68
64
  return True
69
65
  silence_loggers()
@@ -75,18 +71,21 @@ def _check_instance_setup(
75
71
  return True
76
72
  isettings = _get_current_instance_settings()
77
73
  if isettings is not None:
78
- if reload_module and settings.auto_connect:
79
- if not django.IS_SETUP:
74
+ if (
75
+ from_module is not None
76
+ and settings.auto_connect
77
+ and not django.IS_SETUP
78
+ and not IS_LOADING
79
+ ):
80
+ if not from_module == "lamindb":
81
+ import lamindb
82
+
83
+ il.reload(il.import_module(from_module))
84
+ else:
80
85
  django.setup_django(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)
87
86
  logger.important(f"connected lamindb: {isettings.slug}")
88
87
  return django.IS_SETUP
89
88
  else:
90
- if reload_module and settings.auto_connect:
89
+ if from_module is not None and settings.auto_connect:
91
90
  logger.warning(InstanceNotSetupError.default_message)
92
91
  return False
@@ -1,7 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
+ import importlib
3
4
  import os
4
- import sys
5
5
  from typing import TYPE_CHECKING
6
6
  from uuid import UUID
7
7
 
@@ -198,6 +198,7 @@ def connect(slug: str, **kwargs) -> str | tuple | None:
198
198
  "_db",
199
199
  "_write_settings",
200
200
  "_raise_not_found_error",
201
+ "_reload_lamindb",
201
202
  "_test",
202
203
  "_user",
203
204
  }
@@ -210,6 +211,7 @@ def connect(slug: str, **kwargs) -> str | tuple | None:
210
211
  _db: str | None = kwargs.get("_db", None)
211
212
  _write_settings: bool = kwargs.get("_write_settings", True)
212
213
  _raise_not_found_error: bool = kwargs.get("_raise_not_found_error", True)
214
+ _reload_lamindb: bool = kwargs.get("_reload_lamindb", True)
213
215
  _test: bool = kwargs.get("_test", False)
214
216
 
215
217
  access_token: str | None = None
@@ -257,6 +259,14 @@ def connect(slug: str, **kwargs) -> str | tuple | None:
257
259
  if _test:
258
260
  return None
259
261
  silence_loggers()
262
+ # migrate away from lnschema-core
263
+ no_lnschema_core_file = (
264
+ settings_dir / f"no_lnschema_core-{isettings.slug.replace('/', '--')}"
265
+ )
266
+ if not no_lnschema_core_file.exists():
267
+ migrate_lnschema_core(
268
+ isettings, no_lnschema_core_file, write_file=_write_settings
269
+ )
260
270
  check, msg = isettings._load_db()
261
271
  if not check:
262
272
  local_db = (
@@ -292,21 +302,14 @@ def connect(slug: str, **kwargs) -> str | tuple | None:
292
302
  # except ProgrammingError:
293
303
  # pass
294
304
  load_from_isettings(isettings, user=_user, write_settings=_write_settings)
305
+ if _reload_lamindb:
306
+ importlib.reload(importlib.import_module("lamindb"))
295
307
  except Exception as e:
296
308
  if isettings is not None:
297
309
  if _write_settings:
298
310
  isettings._get_settings_file().unlink(missing_ok=True) # type: ignore
299
311
  settings._instance_settings = None
300
312
  raise e
301
- # rename lnschema_bionty to bionty for sql tables
302
- if "bionty" in isettings.schema:
303
- no_lnschema_bionty_file = (
304
- settings_dir / f"no_lnschema_bionty-{isettings.slug.replace('/', '')}"
305
- )
306
- if not no_lnschema_bionty_file.exists():
307
- migrate_lnschema_bionty(
308
- isettings, no_lnschema_bionty_file, write_file=_write_settings
309
- )
310
313
  return None
311
314
 
312
315
 
@@ -322,13 +325,10 @@ def load(slug: str) -> str | tuple | None:
322
325
  return result
323
326
 
324
327
 
325
- def migrate_lnschema_bionty(
326
- isettings: InstanceSettings, no_lnschema_bionty_file: Path, write_file: bool = True
328
+ def migrate_lnschema_core(
329
+ isettings: InstanceSettings, no_lnschema_core_file: Path, write_file: bool = True
327
330
  ):
328
- """Migrate lnschema_bionty tables to bionty tables if bionty_source doesn't exist.
329
-
330
- :param db_uri: str, database URI (e.g., 'sqlite:///path/to/db.sqlite' or 'postgresql://user:password@host:port/dbname')
331
- """
331
+ """Migrate lnschema_core tables to lamindb tables."""
332
332
  from urllib.parse import urlparse
333
333
 
334
334
  parsed_uri = urlparse(isettings.db)
@@ -348,60 +348,62 @@ def migrate_lnschema_bionty(
348
348
  cur = conn.cursor()
349
349
 
350
350
  try:
351
- # check if bionty_source table exists
352
351
  if db_type == "sqlite":
353
352
  cur.execute(
354
- "SELECT name FROM sqlite_master WHERE type='table' AND name='bionty_source'"
353
+ "SELECT name FROM sqlite_master WHERE type='table' AND name='lamindb_user'"
355
354
  )
356
355
  migrated = cur.fetchone() is not None
357
356
 
358
357
  # tables that need to be renamed
359
358
  cur.execute(
360
- "SELECT name FROM sqlite_master WHERE type='table' AND name LIKE 'lnschema_bionty_%'"
359
+ "SELECT name FROM sqlite_master WHERE type='table' AND name LIKE 'lnschema_core_%'"
361
360
  )
362
361
  tables_to_rename = [
363
- row[0][len("lnschema_bionty_") :] for row in cur.fetchall()
362
+ row[0][len("lnschema_core_") :] for row in cur.fetchall()
364
363
  ]
365
364
  else: # postgres
366
365
  cur.execute(
367
- "SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_name = 'bionty_source')"
366
+ "SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_name = 'lamindb_user')"
368
367
  )
369
368
  migrated = cur.fetchone()[0]
370
369
 
371
370
  # tables that need to be renamed
372
371
  cur.execute(
373
- "SELECT table_name FROM information_schema.tables WHERE table_name LIKE 'lnschema_bionty_%'"
372
+ "SELECT table_name FROM information_schema.tables WHERE table_name LIKE 'lnschema_core_%'"
374
373
  )
375
374
  tables_to_rename = [
376
- row[0][len("lnschema_bionty_") :] for row in cur.fetchall()
375
+ row[0][len("lnschema_core_") :] for row in cur.fetchall()
377
376
  ]
378
377
 
379
378
  if migrated:
380
379
  if write_file:
381
- no_lnschema_bionty_file.touch(exist_ok=True)
380
+ no_lnschema_core_file.touch(exist_ok=True)
382
381
  else:
383
382
  try:
384
- # rename tables only if bionty_source doesn't exist and there are tables to rename
383
+ response = input(
384
+ f"Do you want to migrate to lamindb 0.78 (integrate lnschema_core into lamindb)? (y/n) -- Will rename {tables_to_rename}"
385
+ )
386
+ if response != "y":
387
+ print("Aborted.")
388
+ quit()
385
389
  for table in tables_to_rename:
386
390
  if db_type == "sqlite":
387
391
  cur.execute(
388
- f"ALTER TABLE lnschema_bionty_{table} RENAME TO bionty_{table}"
392
+ f"ALTER TABLE lnschema_core_{table} RENAME TO lamindb_{table}"
389
393
  )
390
394
  else: # postgres
391
395
  cur.execute(
392
- f"ALTER TABLE lnschema_bionty_{table} RENAME TO bionty_{table};"
396
+ f"ALTER TABLE lnschema_core_{table} RENAME TO lamindb_{table};"
393
397
  )
394
398
 
395
- # update django_migrations table
396
399
  cur.execute(
397
- "UPDATE django_migrations SET app = 'bionty' WHERE app = 'lnschema_bionty'"
400
+ "UPDATE django_migrations SET app = 'lamindb' WHERE app = 'lnschema_core'"
398
401
  )
399
-
400
- logger.warning(
401
- "Please uninstall lnschema-bionty via `pip uninstall lnschema-bionty`!"
402
+ print(
403
+ "Renaming tables finished.\nNow, *please* call: lamin migrate deploy"
402
404
  )
403
405
  if write_file:
404
- no_lnschema_bionty_file.touch(exist_ok=True)
406
+ no_lnschema_core_file.touch(exist_ok=True)
405
407
  except Exception:
406
408
  # read-only users can't rename tables
407
409
  pass
lamindb_setup/_delete.py CHANGED
@@ -99,7 +99,7 @@ def delete(slug: str, force: bool = False, require_empty: bool = True) -> int |
99
99
  )
100
100
  require_empty = True
101
101
  # first the default storage
102
- n_objects = check_storage_is_empty(
102
+ n_files = check_storage_is_empty(
103
103
  isettings.storage.root,
104
104
  raise_error=require_empty,
105
105
  account_for_sqlite_file=isettings.dialect == "sqlite",
@@ -132,7 +132,7 @@ def delete(slug: str, force: bool = False, require_empty: bool = True) -> int |
132
132
  delete_instance_on_hub(isettings._id, require_empty=False)
133
133
  delete_by_isettings(isettings)
134
134
  # if .lndb file was delete, then we might count -1
135
- if n_objects <= 0 and isettings.storage.type == "local":
135
+ if n_files <= 0 and isettings.storage.type == "local":
136
136
  # dir is only empty after sqlite file was delete via delete_by_isettings
137
137
  if (isettings.storage.root / ".lamindb").exists():
138
138
  (isettings.storage.root / ".lamindb").rmdir()
lamindb_setup/_django.py CHANGED
@@ -5,24 +5,24 @@ from .core.django import setup_django
5
5
 
6
6
 
7
7
  def django(command: str, package_name: str | None = None, **kwargs):
8
- r"""Manage migrations.
8
+ r"""Call Django commands.
9
9
 
10
10
  Examples:
11
11
 
12
12
  Reset auto-incrementing primary integer ids after a database import:
13
13
 
14
14
  >>> import lamindb as ln
15
- >>> ln.setup.django("sqlsequencereset", "lnschema_core")
15
+ >>> ln.setup.django("sqlsequencereset", "lamindb")
16
16
  BEGIN;
17
- SELECT setval(pg_get_serial_sequence('"lnschema_core_user"','id'), coalesce(max("id"), 1), max("id") IS NOT null) FROM "lnschema_core_user"; # noqa
18
- SELECT setval(pg_get_serial_sequence('"lnschema_core_storage"','id'), coalesce(max("id"), 1), max("id") IS NOT null) FROM "lnschema_core_storage"; # noqa
17
+ SELECT setval(pg_get_serial_sequence('"lamindb_user"','id'), coalesce(max("id"), 1), max("id") IS NOT null) FROM "lamindb_user"; # noqa
18
+ SELECT setval(pg_get_serial_sequence('"lamindb_storage"','id'), coalesce(max("id"), 1), max("id") IS NOT null) FROM "lamindb_storage"; # noqa
19
19
  COMMIT;
20
20
 
21
21
  You can then run the SQL output that you'll see like so:
22
22
 
23
23
  >>> sql = \"\"\"BEGIN;
24
- SELECT setval(pg_get_serial_sequence('"lnschema_core_user"','id'), coalesce(max("id"), 1), max("id") IS NOT null) FROM "lnschema_core_user"; # noqa
25
- SELECT setval(pg_get_serial_sequence('"lnschema_core_storage"','id'), coalesce(max("id"), 1), max("id") IS NOT null) FROM "lnschema_core_storage"; # noqa
24
+ SELECT setval(pg_get_serial_sequence('"lamindb_user"','id'), coalesce(max("id"), 1), max("id") IS NOT null) FROM "lamindb_user"; # noqa
25
+ SELECT setval(pg_get_serial_sequence('"lamindb_storage"','id'), coalesce(max("id"), 1), max("id") IS NOT null) FROM "lamindb_storage"; # noqa
26
26
  COMMIT;\"\"\"
27
27
  >>> from django.db import connection
28
28
  >>> with connection.cursor() as cursor:
@@ -4,7 +4,7 @@ from importlib import import_module
4
4
  from pathlib import Path
5
5
 
6
6
  MODELS = {
7
- "core": {
7
+ "lamindb": {
8
8
  "Collection": False,
9
9
  "Artifact": False,
10
10
  "Transform": False,
@@ -2,7 +2,6 @@ from __future__ import annotations
2
2
 
3
3
  import importlib
4
4
  import os
5
- import sys
6
5
  import uuid
7
6
  from typing import TYPE_CHECKING, Literal
8
7
  from uuid import UUID
@@ -29,6 +28,8 @@ if TYPE_CHECKING:
29
28
  def get_schema_module_name(schema_name, raise_import_error: bool = True) -> str | None:
30
29
  import importlib.util
31
30
 
31
+ if schema_name == "core":
32
+ return "lamindb"
32
33
  name_attempts = [f"lnschema_{schema_name.replace('-', '_')}", schema_name]
33
34
  for name in name_attempts:
34
35
  module_spec = importlib.util.find_spec(name)
@@ -42,8 +43,8 @@ def get_schema_module_name(schema_name, raise_import_error: bool = True) -> str
42
43
 
43
44
 
44
45
  def register_storage_in_instance(ssettings: StorageSettings):
45
- from lnschema_core.models import Storage
46
- from lnschema_core.users import current_user_id
46
+ from lamindb.base.users import current_user_id
47
+ from lamindb.models import Storage
47
48
 
48
49
  from .core.hashing import hash_and_encode_as_b62
49
50
 
@@ -71,7 +72,7 @@ def register_storage_in_instance(ssettings: StorageSettings):
71
72
 
72
73
 
73
74
  def register_user(usettings):
74
- from lnschema_core.models import User
75
+ from lamindb.models import User
75
76
 
76
77
  try:
77
78
  # need to have try except because of integer primary key migration
@@ -99,35 +100,6 @@ def register_user_and_storage_in_instance(isettings: InstanceSettings, usettings
99
100
  logger.warning(f"instance seems not set up ({error})")
100
101
 
101
102
 
102
- def reload_schema_modules(isettings: InstanceSettings, include_core: bool = True):
103
- schema_names = ["core"] if include_core else []
104
- # schema_names += list(isettings.schema)
105
- schema_module_names = [get_schema_module_name(n) for n in schema_names]
106
-
107
- for schema_module_name in schema_module_names:
108
- if schema_module_name in sys.modules:
109
- schema_module = importlib.import_module(schema_module_name)
110
- importlib.reload(schema_module)
111
-
112
-
113
- def reload_lamindb_itself(isettings) -> bool:
114
- reloaded = False
115
- if "lamindb" in sys.modules:
116
- import lamindb
117
-
118
- importlib.reload(lamindb)
119
- reloaded = True
120
- return reloaded
121
-
122
-
123
- def reload_lamindb(isettings: InstanceSettings):
124
- log_message = settings.auto_connect
125
- if not reload_lamindb_itself(isettings):
126
- log_message = True
127
- if log_message:
128
- logger.important(f"connected lamindb: {isettings.slug}")
129
-
130
-
131
103
  ERROR_SQLITE_CACHE = """
132
104
  Your cached local SQLite file exists, while your cloud SQLite file ({}) doesn't.
133
105
  Either delete your cache ({}) or add it back to the cloud (if delete was accidental).
@@ -329,6 +301,8 @@ def init(
329
301
  update_schema_in_hub(access_token=access_token)
330
302
  if _write_settings:
331
303
  settings.auto_connect = True
304
+ importlib.reload(importlib.import_module("lamindb"))
305
+ logger.important(f"initialized lamindb: {isettings.slug}")
332
306
  except Exception as e:
333
307
  from ._delete import delete_by_isettings
334
308
  from .core._hub_core import delete_instance_record, delete_storage_record
@@ -338,16 +312,17 @@ def init(
338
312
  delete_by_isettings(isettings)
339
313
  else:
340
314
  settings._instance_settings = None
341
- if (
342
- user_handle != "anonymous" or access_token is not None
343
- ) and isettings.is_on_hub:
344
- delete_instance_record(isettings._id, access_token=access_token)
345
315
  if (
346
316
  ssettings is not None
347
317
  and (user_handle != "anonymous" or access_token is not None)
348
318
  and ssettings.is_on_hub
349
319
  ):
350
320
  delete_storage_record(ssettings._uuid, access_token=access_token) # type: ignore
321
+ if isettings is not None:
322
+ if (
323
+ user_handle != "anonymous" or access_token is not None
324
+ ) and isettings.is_on_hub:
325
+ delete_instance_record(isettings._id, access_token=access_token)
351
326
  raise e
352
327
  return None
353
328
 
@@ -378,7 +353,6 @@ def load_from_isettings(
378
353
  if not isettings._get_settings_file().exists():
379
354
  register_user(user)
380
355
  isettings._persist(write_to_disk=write_settings)
381
- reload_lamindb(isettings)
382
356
 
383
357
 
384
358
  def validate_sqlite_state(isettings: InstanceSettings) -> None:
@@ -414,7 +388,7 @@ def infer_instance_name(
414
388
  return str(db).split("/")[-1]
415
389
  if storage == "create-s3":
416
390
  raise ValueError("pass name to init if storage = 'create-s3'")
417
- storage_path = UPath(storage)
391
+ storage_path = UPath(storage).resolve()
418
392
  # not sure if name is ever ""
419
393
  if storage_path.name != "":
420
394
  name = storage_path.name
lamindb_setup/_migrate.py CHANGED
@@ -5,7 +5,7 @@ from django.db.migrations.loader import MigrationLoader
5
5
  from lamin_utils import logger
6
6
  from packaging import version
7
7
 
8
- from ._check_setup import _check_instance_setup
8
+ from . import _check_setup
9
9
  from .core._settings import settings
10
10
  from .core.django import setup_django
11
11
 
@@ -64,16 +64,18 @@ class migrate:
64
64
  @classmethod
65
65
  def create(cls) -> None:
66
66
  """Create a migration."""
67
- if _check_instance_setup():
67
+ if _check_setup._check_instance_setup():
68
68
  raise RuntimeError("Restart Python session to create migration or use CLI!")
69
+ _check_setup.IS_LOADING = True
69
70
  setup_django(settings.instance, create_migrations=True)
71
+ _check_setup.IS_LOADING = False
70
72
 
71
73
  @classmethod
72
74
  def deploy(cls) -> None:
73
75
  """Deploy a migration."""
74
76
  from ._schema_metadata import update_schema_in_hub
75
77
 
76
- if _check_instance_setup():
78
+ if _check_setup._check_instance_setup():
77
79
  raise RuntimeError("Restart Python session to migrate or use CLI!")
78
80
  from lamindb_setup.core._hub_client import call_with_fallback_auth
79
81
  from lamindb_setup.core._hub_crud import (
@@ -232,7 +232,7 @@ class _ModelHandler:
232
232
  return related_fields
233
233
 
234
234
  def _get_field_metadata(self, model, field: Field):
235
- from lnschema_core.models import LinkORM
235
+ from lamindb.models import LinkORM
236
236
 
237
237
  internal_type = field.get_internal_type()
238
238
  model_name = field.model._meta.model_name
@@ -273,14 +273,16 @@ class _ModelHandler:
273
273
  through = self._get_through(field)
274
274
 
275
275
  return FieldMetadata(
276
- schema_name=schema_name,
276
+ schema_name=schema_name if schema_name != "lamindb" else "core",
277
277
  model_name=model_name,
278
278
  field_name=field_name,
279
279
  type=internal_type,
280
280
  is_link_table=issubclass(field.model, LinkORM),
281
281
  column_name=column,
282
282
  relation_type=relation_type,
283
- related_schema_name=related_schema_name,
283
+ related_schema_name=related_schema_name
284
+ if related_schema_name != "lamindb"
285
+ else "core",
284
286
  related_model_name=related_model_name,
285
287
  related_field_name=related_field_name,
286
288
  through=through,
@@ -288,7 +290,7 @@ class _ModelHandler:
288
290
 
289
291
  @staticmethod
290
292
  def _get_through_many_to_many(field_or_rel: ManyToManyField | ManyToManyRel):
291
- from lnschema_core.models import Registry
293
+ from lamindb.models import Registry
292
294
 
293
295
  if isinstance(field_or_rel, ManyToManyField):
294
296
  if field_or_rel.model != Registry:
@@ -365,7 +367,7 @@ class _SchemaHandler:
365
367
 
366
368
  def to_dict(self, include_django_objects: bool = True):
367
369
  return {
368
- module_name: {
370
+ module_name if module_name != "lamindb" else "core": {
369
371
  model_name: model.to_dict(include_django_objects)
370
372
  for model_name, model in module.items()
371
373
  }
@@ -376,7 +378,7 @@ class _SchemaHandler:
376
378
  return self.to_dict(include_django_objects=False)
377
379
 
378
380
  def _get_modules_metadata(self):
379
- from lnschema_core.models import Record, Registry
381
+ from lamindb.models import Record, Registry
380
382
 
381
383
  all_models = {
382
384
  module_name: {
@@ -401,6 +403,8 @@ class _SchemaHandler:
401
403
  module_set_info = []
402
404
  for module_name in self.included_modules:
403
405
  module = self._get_schema_module(module_name)
406
+ if module_name == "lamindb":
407
+ module_name = "core"
404
408
  module_set_info.append(
405
409
  {"id": 0, "name": module_name, "version": module.__version__}
406
410
  )
@@ -3,6 +3,7 @@ from __future__ import annotations
3
3
  import os
4
4
  import time
5
5
 
6
+ from lamin_utils import logger
6
7
  from upath.implementations.cloud import S3Path
7
8
 
8
9
  HOSTED_REGIONS = [
@@ -40,8 +41,15 @@ class AWSCredentialsManager:
40
41
 
41
42
  # this is cached so will be resued with the connection initialized
42
43
  fs = S3FileSystem(cache_regions=True)
43
- fs.connect()
44
- self.anon: bool = fs.session._credentials is None
44
+ try:
45
+ fs.connect()
46
+ self.anon: bool = fs.session._credentials is None
47
+ except Exception as e:
48
+ logger.warning(
49
+ f"There is a problem with your default AWS Credentials: {e}\n"
50
+ "`anon` mode will be used for all non-managed buckets."
51
+ )
52
+ self.anon = True
45
53
  self.anon_public: bool | None = None
46
54
  if not self.anon:
47
55
  try:
@@ -233,12 +233,16 @@ def _delete_instance(
233
233
  )
234
234
  if require_empty:
235
235
  for storage_record in storage_records:
236
+ root_string: str = storage_record["root"] # type: ignore
236
237
  account_for_sqlite_file = (
237
238
  instance_with_storage["db_scheme"] is None
238
- and instance_with_storage["storage"]["root"] == storage_record["root"]
239
+ and instance_with_storage["storage"]["root"] == root_string
239
240
  )
240
- root_string = storage_record["root"]
241
241
  # gate storage and instance deletion on empty storage location for
242
+ # normally auth.get_session() doesn't have access_token
243
+ # so this block is useless i think (Sergei)
244
+ # the token is received from user settings inside create_path
245
+ # might be needed in the hub though
242
246
  if client.auth.get_session() is not None:
243
247
  access_token = client.auth.get_session().access_token
244
248
  else:
@@ -251,7 +255,6 @@ def _delete_instance(
251
255
  check_storage_is_empty(
252
256
  root_path, account_for_sqlite_file=account_for_sqlite_file
253
257
  )
254
- _update_instance_record(instance_with_storage["id"], {"storage_id": None}, client)
255
258
  # first delete the storage records because we will turn instance_id on
256
259
  # storage into a FK soon
257
260
  for storage_record in storage_records: