From 15604754ebd77fad08a68e423d575761cd040167 Mon Sep 17 00:00:00 2001 From: Alex Wolf Date: Tue, 31 Dec 2024 14:50:00 +0100 Subject: [PATCH 01/32] =?UTF-8?q?=F0=9F=9A=9A=20Prepare=20migration=20away?= =?UTF-8?q?=20from=20lnschema-core?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lamindb_setup/_connect_instance.py | 63 +++++++++++++++--------------- 1 file changed, 31 insertions(+), 32 deletions(-) diff --git a/lamindb_setup/_connect_instance.py b/lamindb_setup/_connect_instance.py index a414d4c3..2e0084a2 100644 --- a/lamindb_setup/_connect_instance.py +++ b/lamindb_setup/_connect_instance.py @@ -1,7 +1,7 @@ from __future__ import annotations import os -import sys +import subprocess from typing import TYPE_CHECKING from uuid import UUID @@ -205,6 +205,15 @@ def connect(slug: str, **kwargs) -> str | tuple | None: if kwarg not in valid_kwargs: raise TypeError(f"connect() got unexpected keyword argument '{kwarg}'") + # migrate away from lnschema_core + try: + import lnschema_core + + logger.important("found legacy lnschema_core, uninstalling it") + subprocess.run("pip uninstall -y lnschema-core", shell=True) + except ImportError: + pass + isettings: InstanceSettings = None # type: ignore # _db is still needed because it is called in init _db: str | None = kwargs.get("_db", None) @@ -298,15 +307,14 @@ def connect(slug: str, **kwargs) -> str | tuple | None: isettings._get_settings_file().unlink(missing_ok=True) # type: ignore settings._instance_settings = None raise e - # rename lnschema_bionty to bionty for sql tables - if "bionty" in isettings.schema: - no_lnschema_bionty_file = ( - settings_dir / f"no_lnschema_bionty-{isettings.slug.replace('/', '')}" + # migrate away from lnschema-core + no_lnschema_core_file = ( + settings_dir / f"no_lnschema_core-{isettings.slug.replace('/', '')}" + ) + if not no_lnschema_core_file.exists(): + migrate_lnschema_core( + isettings, no_lnschema_core_file, write_file=_write_settings ) - if not no_lnschema_bionty_file.exists(): - migrate_lnschema_bionty( - isettings, no_lnschema_bionty_file, write_file=_write_settings - ) return None @@ -322,13 +330,10 @@ def load(slug: str) -> str | tuple | None: return result -def migrate_lnschema_bionty( - isettings: InstanceSettings, no_lnschema_bionty_file: Path, write_file: bool = True +def migrate_lnschema_core( + isettings: InstanceSettings, no_lnschema_core_file: Path, write_file: bool = True ): - """Migrate lnschema_bionty tables to bionty tables if bionty_source doesn't exist. - - :param db_uri: str, database URI (e.g., 'sqlite:///path/to/db.sqlite' or 'postgresql://user:password@host:port/dbname') - """ + """Migrate lnschema_core tables to lamindb tables.""" from urllib.parse import urlparse parsed_uri = urlparse(isettings.db) @@ -351,57 +356,51 @@ def migrate_lnschema_bionty( # check if bionty_source table exists if db_type == "sqlite": cur.execute( - "SELECT name FROM sqlite_master WHERE type='table' AND name='bionty_source'" + "SELECT name FROM sqlite_master WHERE type='table' AND name='lnschema_core_user'" ) migrated = cur.fetchone() is not None # tables that need to be renamed cur.execute( - "SELECT name FROM sqlite_master WHERE type='table' AND name LIKE 'lnschema_bionty_%'" + "SELECT name FROM sqlite_master WHERE type='table' AND name LIKE 'lnschema_core_%'" ) tables_to_rename = [ - row[0][len("lnschema_bionty_") :] for row in cur.fetchall() + row[0][len("lnschema_core_") :] for row in cur.fetchall() ] else: # postgres cur.execute( - "SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_name = 'bionty_source')" + "SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_name = 'lnschema_core_user')" ) migrated = cur.fetchone()[0] # tables that need to be renamed cur.execute( - "SELECT table_name FROM information_schema.tables WHERE table_name LIKE 'lnschema_bionty_%'" + "SELECT table_name FROM information_schema.tables WHERE table_name LIKE 'lnschema_core_%'" ) tables_to_rename = [ - row[0][len("lnschema_bionty_") :] for row in cur.fetchall() + row[0][len("lnschema_core_") :] for row in cur.fetchall() ] if migrated: if write_file: - no_lnschema_bionty_file.touch(exist_ok=True) + no_lnschema_core_file.touch(exist_ok=True) else: try: - # rename tables only if bionty_source doesn't exist and there are tables to rename for table in tables_to_rename: if db_type == "sqlite": cur.execute( - f"ALTER TABLE lnschema_bionty_{table} RENAME TO bionty_{table}" + f"ALTER TABLE lnschema_core_{table} RENAME TO lamindb_{table}" ) else: # postgres cur.execute( - f"ALTER TABLE lnschema_bionty_{table} RENAME TO bionty_{table};" + f"ALTER TABLE lnschema_core_{table} RENAME TO lamindb_{table};" ) - # update django_migrations table cur.execute( - "UPDATE django_migrations SET app = 'bionty' WHERE app = 'lnschema_bionty'" - ) - - logger.warning( - "Please uninstall lnschema-bionty via `pip uninstall lnschema-bionty`!" + "UPDATE django_migrations SET app = 'lamindb' WHERE app = 'lnschema_core'" ) if write_file: - no_lnschema_bionty_file.touch(exist_ok=True) + no_lnschema_core_file.touch(exist_ok=True) except Exception: # read-only users can't rename tables pass From 25c4f7100f03b71da44f28414f3e7dc67da496af Mon Sep 17 00:00:00 2001 From: Alex Wolf Date: Tue, 31 Dec 2024 15:03:10 +0100 Subject: [PATCH 02/32] =?UTF-8?q?=F0=9F=9A=9A=20Rename=20lnschema=5Fcore?= =?UTF-8?q?=20to=20lamindb?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/hub-cloud/01-init-local-instance.ipynb | 2 +- docs/hub-cloud/03-add-managed-storage.ipynb | 2 +- docs/hub-cloud/08-test-multi-session.ipynb | 2 +- lamindb_setup/_connect_instance.py | 12 +++++------- lamindb_setup/_exportdb.py | 2 +- lamindb_setup/_init_instance.py | 8 ++++---- lamindb_setup/_schema_metadata.py | 8 ++++---- lamindb_setup/core/_settings_instance.py | 2 +- lamindb_setup/core/_settings_storage.py | 2 +- lamindb_setup/core/_settings_user.py | 2 +- lamindb_setup/core/django.py | 2 +- 11 files changed, 21 insertions(+), 23 deletions(-) diff --git a/docs/hub-cloud/01-init-local-instance.ipynb b/docs/hub-cloud/01-init-local-instance.ipynb index 7d995b60..d06e4ccc 100644 --- a/docs/hub-cloud/01-init-local-instance.ipynb +++ b/docs/hub-cloud/01-init-local-instance.ipynb @@ -48,7 +48,7 @@ "outputs": [], "source": [ "from pathlib import Path\n", - "from lnschema_core.models import Storage\n", + "from lamindb.models import Storage\n", "\n", "assert ln_setup.settings.instance.storage.type_is_cloud == False\n", "assert ln_setup.settings.instance.owner == ln_setup.settings.user.handle\n", diff --git a/docs/hub-cloud/03-add-managed-storage.ipynb b/docs/hub-cloud/03-add-managed-storage.ipynb index 863895ba..4d10929e 100644 --- a/docs/hub-cloud/03-add-managed-storage.ipynb +++ b/docs/hub-cloud/03-add-managed-storage.ipynb @@ -326,7 +326,7 @@ "from laminhub_rest.core.instance.collaborator import InstanceCollaboratorHandler\n", "from laminhub_rest.core.account.user import UserAccountHandler\n", "from lamindb_setup.core._hub_client import connect_hub_with_auth\n", - "from lnschema_core.models import User\n", + "from lamindb.models import User\n", "\n", "admin_hub = connect_hub_with_auth()\n", "testuser2 = UserAccountHandler(admin_hub).get_by_handle(\"testuser2\")\n", diff --git a/docs/hub-cloud/08-test-multi-session.ipynb b/docs/hub-cloud/08-test-multi-session.ipynb index 9801bdc7..bf98c7b7 100644 --- a/docs/hub-cloud/08-test-multi-session.ipynb +++ b/docs/hub-cloud/08-test-multi-session.ipynb @@ -52,7 +52,7 @@ "metadata": {}, "outputs": [], "source": [ - "from lnschema_core.models import User" + "from lamindb.models import User" ] }, { diff --git a/lamindb_setup/_connect_instance.py b/lamindb_setup/_connect_instance.py index 2e0084a2..5163052a 100644 --- a/lamindb_setup/_connect_instance.py +++ b/lamindb_setup/_connect_instance.py @@ -308,13 +308,11 @@ def connect(slug: str, **kwargs) -> str | tuple | None: settings._instance_settings = None raise e # migrate away from lnschema-core - no_lnschema_core_file = ( - settings_dir / f"no_lnschema_core-{isettings.slug.replace('/', '')}" - ) - if not no_lnschema_core_file.exists(): - migrate_lnschema_core( - isettings, no_lnschema_core_file, write_file=_write_settings - ) + (settings_dir / f"no_lnschema_core-{isettings.slug.replace('/', '')}") + # if not no_lnschema_core_file.exists(): + # migrate_lnschema_core( + # isettings, no_lnschema_core_file, write_file=_write_settings + # ) return None diff --git a/lamindb_setup/_exportdb.py b/lamindb_setup/_exportdb.py index aaf41182..39f2c3fd 100644 --- a/lamindb_setup/_exportdb.py +++ b/lamindb_setup/_exportdb.py @@ -4,7 +4,7 @@ from pathlib import Path MODELS = { - "core": { + "lamindb": { "Collection": False, "Artifact": False, "Transform": False, diff --git a/lamindb_setup/_init_instance.py b/lamindb_setup/_init_instance.py index 1eda955b..577e0684 100644 --- a/lamindb_setup/_init_instance.py +++ b/lamindb_setup/_init_instance.py @@ -42,8 +42,8 @@ def get_schema_module_name(schema_name, raise_import_error: bool = True) -> str def register_storage_in_instance(ssettings: StorageSettings): - from lnschema_core.models import Storage - from lnschema_core.users import current_user_id + from lamindb.models import Storage + from lamindb.users import current_user_id from .core.hashing import hash_and_encode_as_b62 @@ -71,7 +71,7 @@ def register_storage_in_instance(ssettings: StorageSettings): def register_user(usettings): - from lnschema_core.models import User + from lamindb.models import User try: # need to have try except because of integer primary key migration @@ -100,7 +100,7 @@ def register_user_and_storage_in_instance(isettings: InstanceSettings, usettings def reload_schema_modules(isettings: InstanceSettings, include_core: bool = True): - schema_names = ["core"] if include_core else [] + schema_names = ["lamindb"] if include_core else [] # schema_names += list(isettings.schema) schema_module_names = [get_schema_module_name(n) for n in schema_names] diff --git a/lamindb_setup/_schema_metadata.py b/lamindb_setup/_schema_metadata.py index 039ba1cf..8857711a 100644 --- a/lamindb_setup/_schema_metadata.py +++ b/lamindb_setup/_schema_metadata.py @@ -232,7 +232,7 @@ def _get_related_fields_metadata(self, model, fields: list[ForeignObjectRel]): return related_fields def _get_field_metadata(self, model, field: Field): - from lnschema_core.models import LinkORM + from lamindb.models import LinkORM internal_type = field.get_internal_type() model_name = field.model._meta.model_name @@ -288,7 +288,7 @@ def _get_field_metadata(self, model, field: Field): @staticmethod def _get_through_many_to_many(field_or_rel: ManyToManyField | ManyToManyRel): - from lnschema_core.models import Registry + from lamindb.models import Registry if isinstance(field_or_rel, ManyToManyField): if field_or_rel.model != Registry: @@ -360,7 +360,7 @@ def _get_relation_type(model, field: Field): class _SchemaHandler: def __init__(self) -> None: - self.included_modules = ["core"] + list(settings.instance.schema) + self.included_modules = ["lamindb"] + list(settings.instance.schema) self.modules = self._get_modules_metadata() def to_dict(self, include_django_objects: bool = True): @@ -376,7 +376,7 @@ def to_json(self): return self.to_dict(include_django_objects=False) def _get_modules_metadata(self): - from lnschema_core.models import Record, Registry + from lamindb.models import Record, Registry all_models = { module_name: { diff --git a/lamindb_setup/core/_settings_instance.py b/lamindb_setup/core/_settings_instance.py index ed9b352a..97410673 100644 --- a/lamindb_setup/core/_settings_instance.py +++ b/lamindb_setup/core/_settings_instance.py @@ -121,7 +121,7 @@ def name(self) -> str: def _search_local_root( self, local_root: str | None = None, mute_warning: bool = False ) -> StorageSettings | None: - from lnschema_core.models import Storage + from lamindb.models import Storage if local_root is not None: local_records = Storage.objects.filter(root=local_root) diff --git a/lamindb_setup/core/_settings_storage.py b/lamindb_setup/core/_settings_storage.py index a68ab917..d0faef2a 100644 --- a/lamindb_setup/core/_settings_storage.py +++ b/lamindb_setup/core/_settings_storage.py @@ -230,7 +230,7 @@ def record(self) -> Any: """Storage record in the current instance.""" if self._record is None: # dynamic import because of import order - from lnschema_core.models import Storage + from lamindb.models import Storage from ._settings import settings diff --git a/lamindb_setup/core/_settings_user.py b/lamindb_setup/core/_settings_user.py index f55b73d0..195eebcb 100644 --- a/lamindb_setup/core/_settings_user.py +++ b/lamindb_setup/core/_settings_user.py @@ -48,7 +48,7 @@ def __repr__(self) -> str: @property def id(self): """Integer id valid in current intance.""" - from lnschema_core.users import current_user_id + from lamindb.users import current_user_id # there is no cache needed here because current_user_id() # has its own cache diff --git a/lamindb_setup/core/django.py b/lamindb_setup/core/django.py index 517c4834..5a13639f 100644 --- a/lamindb_setup/core/django.py +++ b/lamindb_setup/core/django.py @@ -54,7 +54,7 @@ def setup_django( } from .._init_instance import get_schema_module_name - schema_names = ["core"] + list(isettings.schema) + schema_names = ["lamindb"] + list(isettings.schema) raise_import_error = True if init else False installed_apps = [ package_name From ee11da17d6eb8581bd1b80afb2d6ff7e251f2333 Mon Sep 17 00:00:00 2001 From: Alex Wolf Date: Tue, 31 Dec 2024 17:43:59 +0100 Subject: [PATCH 03/32] =?UTF-8?q?=F0=9F=92=9A=20Fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lamindb_setup/_check_setup.py | 26 ++++++++------------------ lamindb_setup/_connect_instance.py | 9 --------- lamindb_setup/_init_instance.py | 30 ------------------------------ 3 files changed, 8 insertions(+), 57 deletions(-) diff --git a/lamindb_setup/_check_setup.py b/lamindb_setup/_check_setup.py index 9f89946e..49eab390 100644 --- a/lamindb_setup/_check_setup.py +++ b/lamindb_setup/_check_setup.py @@ -54,16 +54,11 @@ def _get_current_instance_settings() -> InstanceSettings | None: # we make this a private function because in all the places it's used, # users should not see it -def _check_instance_setup( - from_lamindb: bool = False, from_module: str | None = None -) -> bool: - reload_module = from_lamindb or from_module is not None - from ._init_instance import get_schema_module_name, reload_schema_modules - +def _check_instance_setup(from_module: str | None = None) -> bool: if django.IS_SETUP: # reload logic here because module might not yet have been imported # upon first setup - if from_module is not None: + if from_module is not None and from_module != "lamindb": il.reload(il.import_module(from_module)) return True silence_loggers() @@ -75,18 +70,13 @@ def _check_instance_setup( return True isettings = _get_current_instance_settings() if isettings is not None: - if reload_module and settings.auto_connect: - if not django.IS_SETUP: - django.setup_django(isettings) - if from_module is not None: - # this only reloads `from_module` - il.reload(il.import_module(from_module)) - else: - # this bulk reloads all schema modules - reload_schema_modules(isettings) - logger.important(f"connected lamindb: {isettings.slug}") + if from_module is not None and settings.auto_connect and not django.IS_SETUP: + django.setup_django(isettings) + if from_module != "lamindb": + il.reload(il.import_module(from_module)) + logger.important(f"connected lamindb: {isettings.slug}") return django.IS_SETUP else: - if reload_module and settings.auto_connect: + if from_module is not None and settings.auto_connect: logger.warning(InstanceNotSetupError.default_message) return False diff --git a/lamindb_setup/_connect_instance.py b/lamindb_setup/_connect_instance.py index 5163052a..7a9a5a4e 100644 --- a/lamindb_setup/_connect_instance.py +++ b/lamindb_setup/_connect_instance.py @@ -205,15 +205,6 @@ def connect(slug: str, **kwargs) -> str | tuple | None: if kwarg not in valid_kwargs: raise TypeError(f"connect() got unexpected keyword argument '{kwarg}'") - # migrate away from lnschema_core - try: - import lnschema_core - - logger.important("found legacy lnschema_core, uninstalling it") - subprocess.run("pip uninstall -y lnschema-core", shell=True) - except ImportError: - pass - isettings: InstanceSettings = None # type: ignore # _db is still needed because it is called in init _db: str | None = kwargs.get("_db", None) diff --git a/lamindb_setup/_init_instance.py b/lamindb_setup/_init_instance.py index 577e0684..d191ca43 100644 --- a/lamindb_setup/_init_instance.py +++ b/lamindb_setup/_init_instance.py @@ -99,35 +99,6 @@ def register_user_and_storage_in_instance(isettings: InstanceSettings, usettings logger.warning(f"instance seems not set up ({error})") -def reload_schema_modules(isettings: InstanceSettings, include_core: bool = True): - schema_names = ["lamindb"] if include_core else [] - # schema_names += list(isettings.schema) - schema_module_names = [get_schema_module_name(n) for n in schema_names] - - for schema_module_name in schema_module_names: - if schema_module_name in sys.modules: - schema_module = importlib.import_module(schema_module_name) - importlib.reload(schema_module) - - -def reload_lamindb_itself(isettings) -> bool: - reloaded = False - if "lamindb" in sys.modules: - import lamindb - - importlib.reload(lamindb) - reloaded = True - return reloaded - - -def reload_lamindb(isettings: InstanceSettings): - log_message = settings.auto_connect - if not reload_lamindb_itself(isettings): - log_message = True - if log_message: - logger.important(f"connected lamindb: {isettings.slug}") - - ERROR_SQLITE_CACHE = """ Your cached local SQLite file exists, while your cloud SQLite file ({}) doesn't. Either delete your cache ({}) or add it back to the cloud (if delete was accidental). @@ -378,7 +349,6 @@ def load_from_isettings( if not isettings._get_settings_file().exists(): register_user(user) isettings._persist(write_to_disk=write_settings) - reload_lamindb(isettings) def validate_sqlite_state(isettings: InstanceSettings) -> None: From acb66ae758ff76e9952897a9e230711caef6f910 Mon Sep 17 00:00:00 2001 From: Alex Wolf Date: Tue, 31 Dec 2024 18:02:17 +0100 Subject: [PATCH 04/32] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Install=20bionty=20f?= =?UTF-8?q?rom=20correct=20branch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- noxfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index c7f85cab..bcc75d11 100644 --- a/noxfile.py +++ b/noxfile.py @@ -28,7 +28,7 @@ def lint(session: nox.Session) -> None: ) def install(session: nox.Session, group: str) -> None: no_deps_packages = "git+https://github.com/laminlabs/lnschema-core git+https://github.com/laminlabs/wetlab git+https://github.com/laminlabs/lamin-cli" - schema_deps = f"""uv pip install --system git+https://github.com/laminlabs/bionty git+https://github.com/laminlabs/lamindb + schema_deps = f"""uv pip install --system git+https://github.com/laminlabs/bionty@integrate-lnschema-core git+https://github.com/laminlabs/lamindb uv pip install --system --no-deps {no_deps_packages} """ if group == "hub-cloud": From 522d6ed9eef71ded3a8b5bed2d34290593981dfd Mon Sep 17 00:00:00 2001 From: Alex Wolf Date: Tue, 31 Dec 2024 18:04:50 +0100 Subject: [PATCH 05/32] =?UTF-8?q?=F0=9F=92=9A=20Fix=20installation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- noxfile.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/noxfile.py b/noxfile.py index bcc75d11..725af831 100644 --- a/noxfile.py +++ b/noxfile.py @@ -27,16 +27,14 @@ def lint(session: nox.Session) -> None: ["hub-local", "hub-prod", "hub-cloud", "storage", "docs"], ) def install(session: nox.Session, group: str) -> None: - no_deps_packages = "git+https://github.com/laminlabs/lnschema-core git+https://github.com/laminlabs/wetlab git+https://github.com/laminlabs/lamin-cli" - schema_deps = f"""uv pip install --system git+https://github.com/laminlabs/bionty@integrate-lnschema-core git+https://github.com/laminlabs/lamindb + no_deps_packages = "git+https://github.com/laminlabs/lamindb@integrate-lnschema-core git+https://github.com/laminlabs/wetlab git+https://github.com/laminlabs/lamin-cli" + schema_deps = f"""uv pip install --system git+https://github.com/laminlabs/bionty@integrate-lnschema-core uv pip install --system --no-deps {no_deps_packages} """ if group == "hub-cloud": cmds = schema_deps + "uv pip install --system ./laminhub/rest-hub line_profiler" elif group == "docs": - cmds = ( - """uv pip install --system git+https://github.com/laminlabs/lnschema-core""" - ) + cmds = """uv pip install --system git+https://github.com/laminlabs/lamindb@integrate-lnschema-core""" elif group == "storage": cmds = """uv pip install --system gcsfs""" cmds += """\nuv pip install --system huggingface_hub""" From 63a932f0db79a052d0e100cac66a58786c721a52 Mon Sep 17 00:00:00 2001 From: Alex Wolf Date: Tue, 31 Dec 2024 18:08:16 +0100 Subject: [PATCH 06/32] =?UTF-8?q?=F0=9F=92=9A=20Fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lamindb_setup/_django.py | 12 ++++++------ tests/hub-prod/test_django.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lamindb_setup/_django.py b/lamindb_setup/_django.py index 98970e7b..aeed6b4a 100644 --- a/lamindb_setup/_django.py +++ b/lamindb_setup/_django.py @@ -5,24 +5,24 @@ def django(command: str, package_name: str | None = None, **kwargs): - r"""Manage migrations. + r"""Call Django commands. Examples: Reset auto-incrementing primary integer ids after a database import: >>> import lamindb as ln - >>> ln.setup.django("sqlsequencereset", "lnschema_core") + >>> ln.setup.django("sqlsequencereset", "lamindb") BEGIN; - SELECT setval(pg_get_serial_sequence('"lnschema_core_user"','id'), coalesce(max("id"), 1), max("id") IS NOT null) FROM "lnschema_core_user"; # noqa - SELECT setval(pg_get_serial_sequence('"lnschema_core_storage"','id'), coalesce(max("id"), 1), max("id") IS NOT null) FROM "lnschema_core_storage"; # noqa + SELECT setval(pg_get_serial_sequence('"lamindb_user"','id'), coalesce(max("id"), 1), max("id") IS NOT null) FROM "lamindb_user"; # noqa + SELECT setval(pg_get_serial_sequence('"lamindb_storage"','id'), coalesce(max("id"), 1), max("id") IS NOT null) FROM "lamindb_storage"; # noqa COMMIT; You can then run the SQL output that you'll see like so: >>> sql = \"\"\"BEGIN; - SELECT setval(pg_get_serial_sequence('"lnschema_core_user"','id'), coalesce(max("id"), 1), max("id") IS NOT null) FROM "lnschema_core_user"; # noqa - SELECT setval(pg_get_serial_sequence('"lnschema_core_storage"','id'), coalesce(max("id"), 1), max("id") IS NOT null) FROM "lnschema_core_storage"; # noqa + SELECT setval(pg_get_serial_sequence('"lamindb_user"','id'), coalesce(max("id"), 1), max("id") IS NOT null) FROM "lamindb_user"; # noqa + SELECT setval(pg_get_serial_sequence('"lamindb_storage"','id'), coalesce(max("id"), 1), max("id") IS NOT null) FROM "lamindb_storage"; # noqa COMMIT;\"\"\" >>> from django.db import connection >>> with connection.cursor() as cursor: diff --git a/tests/hub-prod/test_django.py b/tests/hub-prod/test_django.py index 66b598f9..4045455a 100644 --- a/tests/hub-prod/test_django.py +++ b/tests/hub-prod/test_django.py @@ -6,4 +6,4 @@ def test_django(): - django("sqlsequencereset", "lnschema_core") + django("sqlsequencereset", "lamindb") From 45a33cc53dfdf083fbc10b4b3d4562a398df569c Mon Sep 17 00:00:00 2001 From: Alex Wolf Date: Tue, 31 Dec 2024 18:11:45 +0100 Subject: [PATCH 07/32] =?UTF-8?q?=F0=9F=92=9A=20More=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/hub-cloud/scripts/script-to-fail-managed-storage.py | 2 +- tests/hub-local/test_update_schema_in_hub.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/hub-cloud/scripts/script-to-fail-managed-storage.py b/tests/hub-cloud/scripts/script-to-fail-managed-storage.py index a0aa0f9f..9960d31d 100644 --- a/tests/hub-cloud/scripts/script-to-fail-managed-storage.py +++ b/tests/hub-cloud/scripts/script-to-fail-managed-storage.py @@ -15,7 +15,7 @@ with pytest.raises(ProgrammingError) as error: set_managed_storage(test_root) assert error.exconly().endswith( - "ProgrammingError: permission denied for table lnschema_core_storage" + "ProgrammingError: permission denied for table lamindb_storage" ) hub_client = connect_hub_with_auth() diff --git a/tests/hub-local/test_update_schema_in_hub.py b/tests/hub-local/test_update_schema_in_hub.py index d2451f12..ff52e0c5 100644 --- a/tests/hub-local/test_update_schema_in_hub.py +++ b/tests/hub-local/test_update_schema_in_hub.py @@ -129,7 +129,7 @@ def test_update_schema_in_hub(setup_instance): "through": { "left_key": "from_transform_id", "right_key": "to_transform_id", - "link_table_name": "lnschema_core_transform_predecessors", + "link_table_name": "lamindb_transform_predecessors", }, "field_name": "predecessors", "model_name": "transform", @@ -147,7 +147,7 @@ def test_update_schema_in_hub(setup_instance): "through": { "left_key": "to_transform_id", "right_key": "from_transform_id", - "link_table_name": "lnschema_core_transform_predecessors", + "link_table_name": "lamindb_transform_predecessors", }, "field_name": "successors", "model_name": "transform", From f5918993aca06f836aa8830a0d1bca54c4a3faa3 Mon Sep 17 00:00:00 2001 From: Alex Wolf Date: Tue, 31 Dec 2024 18:15:19 +0100 Subject: [PATCH 08/32] =?UTF-8?q?=F0=9F=92=9A=20Fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- noxfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index 725af831..afc78365 100644 --- a/noxfile.py +++ b/noxfile.py @@ -27,7 +27,7 @@ def lint(session: nox.Session) -> None: ["hub-local", "hub-prod", "hub-cloud", "storage", "docs"], ) def install(session: nox.Session, group: str) -> None: - no_deps_packages = "git+https://github.com/laminlabs/lamindb@integrate-lnschema-core git+https://github.com/laminlabs/wetlab git+https://github.com/laminlabs/lamin-cli" + no_deps_packages = "git+https://github.com/laminlabs/lamindb@integrate-lnschema-core git+https://github.com/laminlabs/wetlab@integrate-lnschema-core git+https://github.com/laminlabs/lamin-cli" schema_deps = f"""uv pip install --system git+https://github.com/laminlabs/bionty@integrate-lnschema-core uv pip install --system --no-deps {no_deps_packages} """ From b75ac9b7ff396fd028614cfc9770ada151497c23 Mon Sep 17 00:00:00 2001 From: Alex Wolf Date: Tue, 31 Dec 2024 18:27:01 +0100 Subject: [PATCH 09/32] =?UTF-8?q?=F0=9F=92=9A=20Start=20to=20migrate=20exi?= =?UTF-8?q?sting=20instances?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lamindb_setup/_connect_instance.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lamindb_setup/_connect_instance.py b/lamindb_setup/_connect_instance.py index 7a9a5a4e..4691cce6 100644 --- a/lamindb_setup/_connect_instance.py +++ b/lamindb_setup/_connect_instance.py @@ -299,11 +299,13 @@ def connect(slug: str, **kwargs) -> str | tuple | None: settings._instance_settings = None raise e # migrate away from lnschema-core - (settings_dir / f"no_lnschema_core-{isettings.slug.replace('/', '')}") - # if not no_lnschema_core_file.exists(): - # migrate_lnschema_core( - # isettings, no_lnschema_core_file, write_file=_write_settings - # ) + no_lnschema_core_file = ( + settings_dir / f"no_lnschema_core-{isettings.slug.replace('/', '--')}" + ) + if not no_lnschema_core_file.exists(): + migrate_lnschema_core( + isettings, no_lnschema_core_file, write_file=_write_settings + ) return None @@ -342,7 +344,6 @@ def migrate_lnschema_core( cur = conn.cursor() try: - # check if bionty_source table exists if db_type == "sqlite": cur.execute( "SELECT name FROM sqlite_master WHERE type='table' AND name='lnschema_core_user'" From d83b451742a320a84951f44511a8bba9e122ee00 Mon Sep 17 00:00:00 2001 From: Alex Wolf Date: Tue, 31 Dec 2024 18:35:16 +0100 Subject: [PATCH 10/32] =?UTF-8?q?=F0=9F=92=9A=20Fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lamindb_setup/_init_instance.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lamindb_setup/_init_instance.py b/lamindb_setup/_init_instance.py index d191ca43..f4df0d54 100644 --- a/lamindb_setup/_init_instance.py +++ b/lamindb_setup/_init_instance.py @@ -309,16 +309,17 @@ def init( delete_by_isettings(isettings) else: settings._instance_settings = None - if ( - user_handle != "anonymous" or access_token is not None - ) and isettings.is_on_hub: - delete_instance_record(isettings._id, access_token=access_token) if ( ssettings is not None and (user_handle != "anonymous" or access_token is not None) and ssettings.is_on_hub ): delete_storage_record(ssettings._uuid, access_token=access_token) # type: ignore + if isettings is not None: + if ( + user_handle != "anonymous" or access_token is not None + ) and isettings.is_on_hub: + delete_instance_record(isettings._id, access_token=access_token) raise e return None From da81321329a7b0314fbd6ec96a9e44829af8b0cb Mon Sep 17 00:00:00 2001 From: Alex Wolf Date: Wed, 1 Jan 2025 20:16:42 +0100 Subject: [PATCH 11/32] =?UTF-8?q?=F0=9F=92=9A=20Fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lamindb_setup/_check_setup.py | 10 ++++++++-- lamindb_setup/core/_settings_instance.py | 5 ++++- lamindb_setup/core/django.py | 4 +--- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/lamindb_setup/_check_setup.py b/lamindb_setup/_check_setup.py index 49eab390..b785286d 100644 --- a/lamindb_setup/_check_setup.py +++ b/lamindb_setup/_check_setup.py @@ -27,6 +27,7 @@ class InstanceNotSetupError(DefaultMessageException): CURRENT_ISETTINGS: InstanceSettings | None = None +IS_INITIALIZING: bool = False def _get_current_instance_settings() -> InstanceSettings | None: @@ -70,9 +71,14 @@ def _check_instance_setup(from_module: str | None = None) -> bool: return True isettings = _get_current_instance_settings() if isettings is not None: - if from_module is not None and settings.auto_connect and not django.IS_SETUP: + if ( + from_module is not None + and settings.auto_connect + and not django.IS_SETUP + and not IS_INITIALIZING + ): django.setup_django(isettings) - if from_module != "lamindb": + if not from_module == "lamindb": il.reload(il.import_module(from_module)) logger.important(f"connected lamindb: {isettings.slug}") return django.IS_SETUP diff --git a/lamindb_setup/core/_settings_instance.py b/lamindb_setup/core/_settings_instance.py index 97410673..b1380fb2 100644 --- a/lamindb_setup/core/_settings_instance.py +++ b/lamindb_setup/core/_settings_instance.py @@ -457,9 +457,13 @@ def _persist(self, write_to_disk: bool = True) -> None: settings._instance_settings = self def _init_db(self): + from lamindb_setup import _check_setup + from .django import setup_django + _check_setup.IS_INITIALIZING = True setup_django(self, init=True) + _check_setup.IS_INITIALIZING = False def _load_db(self) -> tuple[bool, str]: # Is the database available and initialized as LaminDB? @@ -472,7 +476,6 @@ def _load_db(self) -> tuple[bool, str]: f" {legacy_file} to {self._sqlite_file}" ) return False, f"SQLite file {self._sqlite_file} does not exist" - from lamindb_setup import settings # to check user from .django import setup_django diff --git a/lamindb_setup/core/django.py b/lamindb_setup/core/django.py index 5a13639f..425c44b9 100644 --- a/lamindb_setup/core/django.py +++ b/lamindb_setup/core/django.py @@ -5,10 +5,8 @@ import os from pathlib import Path import time -from lamin_utils import logger -from ._settings_store import current_instance_settings_file from ._settings_instance import InstanceSettings -import sys + IS_RUN_FROM_IPYTHON = getattr(builtins, "__IPYTHON__", False) IS_SETUP = False From 3b03292f4f9deb24a09780152d075f8cdf95aaef Mon Sep 17 00:00:00 2001 From: Alex Wolf Date: Wed, 1 Jan 2025 20:30:08 +0100 Subject: [PATCH 12/32] =?UTF-8?q?=F0=9F=92=9A=20Fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lamindb_setup/_connect_instance.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lamindb_setup/_connect_instance.py b/lamindb_setup/_connect_instance.py index 4691cce6..49c7103f 100644 --- a/lamindb_setup/_connect_instance.py +++ b/lamindb_setup/_connect_instance.py @@ -1,7 +1,7 @@ from __future__ import annotations +import importlib import os -import subprocess from typing import TYPE_CHECKING from uuid import UUID @@ -292,6 +292,7 @@ def connect(slug: str, **kwargs) -> str | tuple | None: # except ProgrammingError: # pass load_from_isettings(isettings, user=_user, write_settings=_write_settings) + importlib.reload(importlib.import_module("lamindb")) except Exception as e: if isettings is not None: if _write_settings: From c0b8bc60aa52f188f52aba3ac33a929b36034078 Mon Sep 17 00:00:00 2001 From: Alex Wolf Date: Wed, 1 Jan 2025 20:34:31 +0100 Subject: [PATCH 13/32] =?UTF-8?q?=F0=9F=92=9A=20Replace=20laminlabs/lamind?= =?UTF-8?q?ata=20with=20laminlabs/lamin-site-assets?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/hub-prod/test-connect-anonymously.ipynb | 2 +- lamindb_setup/core/upath.py | 2 +- tests/hub-cloud/test_connect_instance.py | 18 ++++++++++-------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/docs/hub-prod/test-connect-anonymously.ipynb b/docs/hub-prod/test-connect-anonymously.ipynb index aa7e34a7..716f42a7 100644 --- a/docs/hub-prod/test-connect-anonymously.ipynb +++ b/docs/hub-prod/test-connect-anonymously.ipynb @@ -31,7 +31,7 @@ "metadata": {}, "outputs": [], "source": [ - "ln_setup.connect(\"laminlabs/lamindata\")" + "ln_setup.connect(\"laminlabs/lamin-site-assets\")" ] }, { diff --git a/lamindb_setup/core/upath.py b/lamindb_setup/core/upath.py index d2bb7707..e21b5465 100644 --- a/lamindb_setup/core/upath.py +++ b/lamindb_setup/core/upath.py @@ -809,7 +809,7 @@ class InstanceNotEmpty(Exception): pass -# is as fast as boto3: https://lamin.ai/laminlabs/lamindata/transform/krGp3hT1f78N5zKv +# is as fast as boto3: https://lamin.ai/laminlabs/lamin-site-assets/transform/krGp3hT1f78N5zKv def check_storage_is_empty( root: UPathStr, *, raise_error: bool = True, account_for_sqlite_file: bool = False ) -> int: diff --git a/tests/hub-cloud/test_connect_instance.py b/tests/hub-cloud/test_connect_instance.py index 4008dc10..2fe11f13 100644 --- a/tests/hub-cloud/test_connect_instance.py +++ b/tests/hub-cloud/test_connect_instance.py @@ -108,38 +108,40 @@ def test_connect_with_db_parameter(): # no more db parameter, it is _db now and is hidden in kwargs # this also tests that only allowed kwargs can be used with pytest.raises(TypeError): - ln_setup.connect("laminlabs/lamindata", db="some_db") + ln_setup.connect("laminlabs/lamin-site-assets", db="some_db") if os.getenv("LAMIN_ENV") == "prod": # take a write-level access collaborator ln_setup.login("testuser1") # test load from hub - ln_setup.connect("laminlabs/lamindata", _test=True) + ln_setup.connect("laminlabs/lamin-site-assets", _test=True) assert "root" in ln_setup.settings.instance.db # test load from provided db argument db = "postgresql://testdbuser:testpwd@database2.cmyfs24wugc3.us-east-1.rds.amazonaws.com:5432/db1" - ln_setup.connect("laminlabs/lamindata", _db=db, _test=True) + ln_setup.connect("laminlabs/lamin-site-assets", _db=db, _test=True) assert "testdbuser" in ln_setup.settings.instance.db # test ignore loading from cache because hub result has >read access - ln_setup.connect("laminlabs/lamindata", _test=True) + ln_setup.connect("laminlabs/lamin-site-assets", _test=True) assert "root" in ln_setup.settings.instance.db # now take a user that has no collaborator status ln_setup.login("testuser2") # the cached high priviledge connection string remains active - ln_setup.connect("laminlabs/lamindata", _test=True) + ln_setup.connect("laminlabs/lamin-site-assets", _test=True) assert "root" in ln_setup.settings.instance.db # now pass the connection string - ln_setup.connect("laminlabs/lamindata", _db=db, _test=True) + ln_setup.connect("laminlabs/lamin-site-assets", _db=db, _test=True) assert "testdbuser" in ln_setup.settings.instance.db # now the cache is used - ln_setup.connect("laminlabs/lamindata", _test=True) + ln_setup.connect("laminlabs/lamin-site-assets", _test=True) assert "testdbuser" in ln_setup.settings.instance.db # test corrupted input db_corrupted = "postgresql://testuser:testpwd@wrongserver:5432/db1" with pytest.raises(ValueError) as error: - ln_setup.connect("laminlabs/lamindata", _db=db_corrupted, _test=True) + ln_setup.connect( + "laminlabs/lamin-site-assets", _db=db_corrupted, _test=True + ) assert error.exconly().startswith( "ValueError: The local differs from the hub database information" ) From 8108c6d25e2c44003ab30b8f8dd10df675af4b8c Mon Sep 17 00:00:00 2001 From: Alex Wolf Date: Wed, 1 Jan 2025 20:39:14 +0100 Subject: [PATCH 14/32] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Add=20some=20logging?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lamindb_setup/_connect_instance.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lamindb_setup/_connect_instance.py b/lamindb_setup/_connect_instance.py index 49c7103f..e41066a2 100644 --- a/lamindb_setup/_connect_instance.py +++ b/lamindb_setup/_connect_instance.py @@ -377,6 +377,7 @@ def migrate_lnschema_core( no_lnschema_core_file.touch(exist_ok=True) else: try: + print(f"migrating from lnschema_core to lamindb: {tables_to_rename}") for table in tables_to_rename: if db_type == "sqlite": cur.execute( @@ -390,6 +391,7 @@ def migrate_lnschema_core( cur.execute( "UPDATE django_migrations SET app = 'lamindb' WHERE app = 'lnschema_core'" ) + print("finished migration") if write_file: no_lnschema_core_file.touch(exist_ok=True) except Exception: From b5fd14d377aa58b508b015bfab3d03892de2018a Mon Sep 17 00:00:00 2001 From: Alex Wolf Date: Wed, 1 Jan 2025 20:52:17 +0100 Subject: [PATCH 15/32] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Organize=20migration?= =?UTF-8?q?=20process?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lamindb_setup/_connect_instance.py | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/lamindb_setup/_connect_instance.py b/lamindb_setup/_connect_instance.py index e41066a2..d136380f 100644 --- a/lamindb_setup/_connect_instance.py +++ b/lamindb_setup/_connect_instance.py @@ -257,6 +257,14 @@ def connect(slug: str, **kwargs) -> str | tuple | None: if _test: return None silence_loggers() + # migrate away from lnschema-core + no_lnschema_core_file = ( + settings_dir / f"no_lnschema_core-{isettings.slug.replace('/', '--')}" + ) + if not no_lnschema_core_file.exists(): + migrate_lnschema_core( + isettings, no_lnschema_core_file, write_file=_write_settings + ) check, msg = isettings._load_db() if not check: local_db = ( @@ -299,14 +307,6 @@ def connect(slug: str, **kwargs) -> str | tuple | None: isettings._get_settings_file().unlink(missing_ok=True) # type: ignore settings._instance_settings = None raise e - # migrate away from lnschema-core - no_lnschema_core_file = ( - settings_dir / f"no_lnschema_core-{isettings.slug.replace('/', '--')}" - ) - if not no_lnschema_core_file.exists(): - migrate_lnschema_core( - isettings, no_lnschema_core_file, write_file=_write_settings - ) return None @@ -347,7 +347,7 @@ def migrate_lnschema_core( try: if db_type == "sqlite": cur.execute( - "SELECT name FROM sqlite_master WHERE type='table' AND name='lnschema_core_user'" + "SELECT name FROM sqlite_master WHERE type='table' AND name='lamindb_user'" ) migrated = cur.fetchone() is not None @@ -360,7 +360,7 @@ def migrate_lnschema_core( ] else: # postgres cur.execute( - "SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_name = 'lnschema_core_user')" + "SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_name = 'lamindb_user')" ) migrated = cur.fetchone()[0] @@ -377,7 +377,12 @@ def migrate_lnschema_core( no_lnschema_core_file.touch(exist_ok=True) else: try: - print(f"migrating from lnschema_core to lamindb: {tables_to_rename}") + response = input( + f"migrating to lamindb 0.78 (integrate lnschema_core into lamindb): will rename {tables_to_rename}" + ) + if response != "y": + print("aborted") + quit() for table in tables_to_rename: if db_type == "sqlite": cur.execute( From e552f44a7d0a9847a18aeb7b73a01bb4a3283eaa Mon Sep 17 00:00:00 2001 From: Alex Wolf Date: Wed, 1 Jan 2025 21:52:12 +0100 Subject: [PATCH 16/32] =?UTF-8?q?=F0=9F=92=9A=20Fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lamindb_setup/_check_setup.py | 4 ++-- lamindb_setup/_connect_instance.py | 4 ++-- lamindb_setup/core/_settings_instance.py | 8 ++++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lamindb_setup/_check_setup.py b/lamindb_setup/_check_setup.py index b785286d..e8cabd90 100644 --- a/lamindb_setup/_check_setup.py +++ b/lamindb_setup/_check_setup.py @@ -27,7 +27,7 @@ class InstanceNotSetupError(DefaultMessageException): CURRENT_ISETTINGS: InstanceSettings | None = None -IS_INITIALIZING: bool = False +IS_LOADING: bool = False def _get_current_instance_settings() -> InstanceSettings | None: @@ -75,7 +75,7 @@ def _check_instance_setup(from_module: str | None = None) -> bool: from_module is not None and settings.auto_connect and not django.IS_SETUP - and not IS_INITIALIZING + and not IS_LOADING ): django.setup_django(isettings) if not from_module == "lamindb": diff --git a/lamindb_setup/_connect_instance.py b/lamindb_setup/_connect_instance.py index d136380f..90e09eaf 100644 --- a/lamindb_setup/_connect_instance.py +++ b/lamindb_setup/_connect_instance.py @@ -378,10 +378,10 @@ def migrate_lnschema_core( else: try: response = input( - f"migrating to lamindb 0.78 (integrate lnschema_core into lamindb): will rename {tables_to_rename}" + f"Do you want to migrate to lamindb 0.78 (integrate lnschema_core into lamindb)? (y/n) -- Will rename {tables_to_rename}" ) if response != "y": - print("aborted") + print("Aborted.") quit() for table in tables_to_rename: if db_type == "sqlite": diff --git a/lamindb_setup/core/_settings_instance.py b/lamindb_setup/core/_settings_instance.py index b1380fb2..575f859d 100644 --- a/lamindb_setup/core/_settings_instance.py +++ b/lamindb_setup/core/_settings_instance.py @@ -461,11 +461,13 @@ def _init_db(self): from .django import setup_django - _check_setup.IS_INITIALIZING = True + _check_setup.IS_LOADING = True setup_django(self, init=True) - _check_setup.IS_INITIALIZING = False + _check_setup.IS_LOADING = False def _load_db(self) -> tuple[bool, str]: + from lamindb_setup import _check_setup + # Is the database available and initialized as LaminDB? # returns a tuple of status code and message if self.dialect == "sqlite" and not self._sqlite_file.exists(): @@ -484,5 +486,7 @@ def _load_db(self) -> tuple[bool, str]: # setting up django also performs a check for migrations & prints them # as warnings # this should fail, e.g., if the db is not reachable + _check_setup.IS_LOADING = True setup_django(self) + _check_setup.IS_LOADING = False return True, "" From e1a1db26aafa79682414151ab0c88239424082c3 Mon Sep 17 00:00:00 2001 From: Alex Wolf Date: Wed, 1 Jan 2025 22:16:16 +0100 Subject: [PATCH 17/32] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Leave=20core=20withi?= =?UTF-8?q?n=20schema=20serialization=20because=20the=20hub=20hardcodes=20?= =?UTF-8?q?some=20of=20it?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lamindb_setup/_schema_metadata.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lamindb_setup/_schema_metadata.py b/lamindb_setup/_schema_metadata.py index 8857711a..b8628ee6 100644 --- a/lamindb_setup/_schema_metadata.py +++ b/lamindb_setup/_schema_metadata.py @@ -273,14 +273,16 @@ def _get_field_metadata(self, model, field: Field): through = self._get_through(field) return FieldMetadata( - schema_name=schema_name, + schema_name=schema_name if schema_name != "lamindb" else "core", model_name=model_name, field_name=field_name, type=internal_type, is_link_table=issubclass(field.model, LinkORM), column_name=column, relation_type=relation_type, - related_schema_name=related_schema_name, + related_schema_name=related_schema_name + if related_schema_name != "lamindb" + else "core", related_model_name=related_model_name, related_field_name=related_field_name, through=through, @@ -365,7 +367,7 @@ def __init__(self) -> None: def to_dict(self, include_django_objects: bool = True): return { - module_name: { + module_name if module_name != "lamindb" else "core": { model_name: model.to_dict(include_django_objects) for model_name, model in module.items() } @@ -401,6 +403,8 @@ def _get_module_set_info(self): module_set_info = [] for module_name in self.included_modules: module = self._get_schema_module(module_name) + if module_name == "lamindb": + module_name = "core" module_set_info.append( {"id": 0, "name": module_name, "version": module.__version__} ) From b4a71cbf7a71cc02b9b9508b37e73a13d4cef5f3 Mon Sep 17 00:00:00 2001 From: Alex Wolf Date: Wed, 1 Jan 2025 22:35:09 +0100 Subject: [PATCH 18/32] =?UTF-8?q?=F0=9F=92=9A=20Fix=20for=20other=20schema?= =?UTF-8?q?=20modules?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lamindb_setup/_check_setup.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lamindb_setup/_check_setup.py b/lamindb_setup/_check_setup.py index e8cabd90..72f653e6 100644 --- a/lamindb_setup/_check_setup.py +++ b/lamindb_setup/_check_setup.py @@ -77,10 +77,13 @@ def _check_instance_setup(from_module: str | None = None) -> bool: and not django.IS_SETUP and not IS_LOADING ): - django.setup_django(isettings) if not from_module == "lamindb": + import lamindb + il.reload(il.import_module(from_module)) - logger.important(f"connected lamindb: {isettings.slug}") + else: + django.setup_django(isettings) + logger.important(f"connected lamindb: {isettings.slug}") return django.IS_SETUP else: if from_module is not None and settings.auto_connect: From c08052da4e6e836f9d28866a3ac955f4ab0f168c Mon Sep 17 00:00:00 2001 From: Alex Wolf Date: Wed, 1 Jan 2025 22:44:42 +0100 Subject: [PATCH 19/32] =?UTF-8?q?=F0=9F=92=9A=20Fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lamindb_setup/_init_instance.py | 2 ++ lamindb_setup/_schema_metadata.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lamindb_setup/_init_instance.py b/lamindb_setup/_init_instance.py index f4df0d54..779d7804 100644 --- a/lamindb_setup/_init_instance.py +++ b/lamindb_setup/_init_instance.py @@ -29,6 +29,8 @@ def get_schema_module_name(schema_name, raise_import_error: bool = True) -> str | None: import importlib.util + if schema_name == "core": + return "lamindb" name_attempts = [f"lnschema_{schema_name.replace('-', '_')}", schema_name] for name in name_attempts: module_spec = importlib.util.find_spec(name) diff --git a/lamindb_setup/_schema_metadata.py b/lamindb_setup/_schema_metadata.py index b8628ee6..92cac8f5 100644 --- a/lamindb_setup/_schema_metadata.py +++ b/lamindb_setup/_schema_metadata.py @@ -362,7 +362,7 @@ def _get_relation_type(model, field: Field): class _SchemaHandler: def __init__(self) -> None: - self.included_modules = ["lamindb"] + list(settings.instance.schema) + self.included_modules = ["core"] + list(settings.instance.schema) self.modules = self._get_modules_metadata() def to_dict(self, include_django_objects: bool = True): From f0308591866dbded14d0a3fa37e731c46afbd5c3 Mon Sep 17 00:00:00 2001 From: Alex Wolf Date: Wed, 1 Jan 2025 22:55:21 +0100 Subject: [PATCH 20/32] =?UTF-8?q?=F0=9F=92=9A=20Fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/hub-cloud/test_connect_instance.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/tests/hub-cloud/test_connect_instance.py b/tests/hub-cloud/test_connect_instance.py index 2fe11f13..4008dc10 100644 --- a/tests/hub-cloud/test_connect_instance.py +++ b/tests/hub-cloud/test_connect_instance.py @@ -108,40 +108,38 @@ def test_connect_with_db_parameter(): # no more db parameter, it is _db now and is hidden in kwargs # this also tests that only allowed kwargs can be used with pytest.raises(TypeError): - ln_setup.connect("laminlabs/lamin-site-assets", db="some_db") + ln_setup.connect("laminlabs/lamindata", db="some_db") if os.getenv("LAMIN_ENV") == "prod": # take a write-level access collaborator ln_setup.login("testuser1") # test load from hub - ln_setup.connect("laminlabs/lamin-site-assets", _test=True) + ln_setup.connect("laminlabs/lamindata", _test=True) assert "root" in ln_setup.settings.instance.db # test load from provided db argument db = "postgresql://testdbuser:testpwd@database2.cmyfs24wugc3.us-east-1.rds.amazonaws.com:5432/db1" - ln_setup.connect("laminlabs/lamin-site-assets", _db=db, _test=True) + ln_setup.connect("laminlabs/lamindata", _db=db, _test=True) assert "testdbuser" in ln_setup.settings.instance.db # test ignore loading from cache because hub result has >read access - ln_setup.connect("laminlabs/lamin-site-assets", _test=True) + ln_setup.connect("laminlabs/lamindata", _test=True) assert "root" in ln_setup.settings.instance.db # now take a user that has no collaborator status ln_setup.login("testuser2") # the cached high priviledge connection string remains active - ln_setup.connect("laminlabs/lamin-site-assets", _test=True) + ln_setup.connect("laminlabs/lamindata", _test=True) assert "root" in ln_setup.settings.instance.db # now pass the connection string - ln_setup.connect("laminlabs/lamin-site-assets", _db=db, _test=True) + ln_setup.connect("laminlabs/lamindata", _db=db, _test=True) assert "testdbuser" in ln_setup.settings.instance.db # now the cache is used - ln_setup.connect("laminlabs/lamin-site-assets", _test=True) + ln_setup.connect("laminlabs/lamindata", _test=True) assert "testdbuser" in ln_setup.settings.instance.db # test corrupted input db_corrupted = "postgresql://testuser:testpwd@wrongserver:5432/db1" with pytest.raises(ValueError) as error: - ln_setup.connect( - "laminlabs/lamin-site-assets", _db=db_corrupted, _test=True - ) + ln_setup.connect("laminlabs/lamindata", _db=db_corrupted, _test=True) assert error.exconly().startswith( "ValueError: The local differs from the hub database information" ) From a8a55b4d3707cb1d9cdc18efabbd83262cf230ee Mon Sep 17 00:00:00 2001 From: Alex Wolf Date: Wed, 1 Jan 2025 23:03:52 +0100 Subject: [PATCH 21/32] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20More=20consistency?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lamindb_setup/core/django.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lamindb_setup/core/django.py b/lamindb_setup/core/django.py index 425c44b9..211b3dd7 100644 --- a/lamindb_setup/core/django.py +++ b/lamindb_setup/core/django.py @@ -52,7 +52,7 @@ def setup_django( } from .._init_instance import get_schema_module_name - schema_names = ["lamindb"] + list(isettings.schema) + schema_names = ["core"] + list(isettings.schema) raise_import_error = True if init else False installed_apps = [ package_name From 8975b5ff6305d43ef24eabbf61990efee6f3a6ec Mon Sep 17 00:00:00 2001 From: Alex Wolf Date: Wed, 1 Jan 2025 23:13:25 +0100 Subject: [PATCH 22/32] =?UTF-8?q?=F0=9F=92=9A=20More=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- noxfile.py | 3 ++- tests/hub-local/test_update_schema_in_hub.py | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index afc78365..145d2a48 100644 --- a/noxfile.py +++ b/noxfile.py @@ -36,7 +36,8 @@ def install(session: nox.Session, group: str) -> None: elif group == "docs": cmds = """uv pip install --system git+https://github.com/laminlabs/lamindb@integrate-lnschema-core""" elif group == "storage": - cmds = """uv pip install --system gcsfs""" + cmds = schema_deps + cmds += """\nuv pip install --system gcsfs""" cmds += """\nuv pip install --system huggingface_hub""" elif group == "hub-prod": # cmds = "git clone --depth 1 https://github.com/django/django\n" diff --git a/tests/hub-local/test_update_schema_in_hub.py b/tests/hub-local/test_update_schema_in_hub.py index ff52e0c5..5106bd9a 100644 --- a/tests/hub-local/test_update_schema_in_hub.py +++ b/tests/hub-local/test_update_schema_in_hub.py @@ -41,6 +41,8 @@ def test_update_schema_in_hub(setup_instance): assert "bionty" in schema["schema_json"] assert "wetlab" in schema["schema_json"] + print(schema["schema_json"]["core"]) + assert schema["schema_json"]["core"]["artifact"]["fields"]["id"] == { "type": "AutoField", "column_name": "id", From c3f9f38be57141f189e9bda32c45d59936febf2f Mon Sep 17 00:00:00 2001 From: Alex Wolf Date: Wed, 1 Jan 2025 23:37:11 +0100 Subject: [PATCH 23/32] =?UTF-8?q?=F0=9F=92=9A=20Try=20fixing=20lamindb=20i?= =?UTF-8?q?nstall?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- noxfile.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/noxfile.py b/noxfile.py index 145d2a48..189337ab 100644 --- a/noxfile.py +++ b/noxfile.py @@ -36,9 +36,7 @@ def install(session: nox.Session, group: str) -> None: elif group == "docs": cmds = """uv pip install --system git+https://github.com/laminlabs/lamindb@integrate-lnschema-core""" elif group == "storage": - cmds = schema_deps - cmds += """\nuv pip install --system gcsfs""" - cmds += """\nuv pip install --system huggingface_hub""" + cmds = schema_deps + "uv pip install --system gcsfs huggingface_hub" elif group == "hub-prod": # cmds = "git clone --depth 1 https://github.com/django/django\n" # cmds += "uv pip install --system -e ./django\n" @@ -53,6 +51,7 @@ def install(session: nox.Session, group: str) -> None: # above downgrades django, I don't understand why, try this if group == "hub-local": cmds += "\nuv pip install --system -e ./laminhub/rest-hub line_profiler" + cmds += "\nuv pip install git+https://github.com/laminlabs/lamindb@integrate-lnschema-core" [run(session, line) for line in cmds.splitlines()] From 79c0c3d43ee2f2aba09c12437563e5df9e913abd Mon Sep 17 00:00:00 2001 From: Alex Wolf Date: Wed, 1 Jan 2025 23:59:42 +0100 Subject: [PATCH 24/32] =?UTF-8?q?=F0=9F=92=9A=20Fix=20noxfile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- noxfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index 189337ab..e0bfc325 100644 --- a/noxfile.py +++ b/noxfile.py @@ -51,7 +51,7 @@ def install(session: nox.Session, group: str) -> None: # above downgrades django, I don't understand why, try this if group == "hub-local": cmds += "\nuv pip install --system -e ./laminhub/rest-hub line_profiler" - cmds += "\nuv pip install git+https://github.com/laminlabs/lamindb@integrate-lnschema-core" + cmds += "\nuv pip install --system git+https://github.com/laminlabs/lamindb@integrate-lnschema-core" [run(session, line) for line in cmds.splitlines()] From 8ea566b94164ee52f65dc31105dbe078171410e0 Mon Sep 17 00:00:00 2001 From: Alex Wolf Date: Thu, 2 Jan 2025 00:00:04 +0100 Subject: [PATCH 25/32] =?UTF-8?q?=F0=9F=92=9A=20Remove=20print=20statement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/hub-local/test_update_schema_in_hub.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/hub-local/test_update_schema_in_hub.py b/tests/hub-local/test_update_schema_in_hub.py index 5106bd9a..ff52e0c5 100644 --- a/tests/hub-local/test_update_schema_in_hub.py +++ b/tests/hub-local/test_update_schema_in_hub.py @@ -41,8 +41,6 @@ def test_update_schema_in_hub(setup_instance): assert "bionty" in schema["schema_json"] assert "wetlab" in schema["schema_json"] - print(schema["schema_json"]["core"]) - assert schema["schema_json"]["core"]["artifact"]["fields"]["id"] == { "type": "AutoField", "column_name": "id", From 1738ba4753a01f8eba568c735a5d33b156aa3564 Mon Sep 17 00:00:00 2001 From: Alex Wolf Date: Thu, 2 Jan 2025 00:04:43 +0100 Subject: [PATCH 26/32] =?UTF-8?q?=F0=9F=92=9A=20Fix=20install?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- noxfile.py | 1 - 1 file changed, 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index e0bfc325..0aef26a6 100644 --- a/noxfile.py +++ b/noxfile.py @@ -51,7 +51,6 @@ def install(session: nox.Session, group: str) -> None: # above downgrades django, I don't understand why, try this if group == "hub-local": cmds += "\nuv pip install --system -e ./laminhub/rest-hub line_profiler" - cmds += "\nuv pip install --system git+https://github.com/laminlabs/lamindb@integrate-lnschema-core" [run(session, line) for line in cmds.splitlines()] From 15d3791600704641049d97cb1e672148596c3763 Mon Sep 17 00:00:00 2001 From: Alex Wolf Date: Thu, 2 Jan 2025 00:08:26 +0100 Subject: [PATCH 27/32] =?UTF-8?q?=F0=9F=94=A5=20Remove=20lnschema-core=20a?= =?UTF-8?q?s=20a=20dependency?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index bc1d09a3..485e14aa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,6 @@ authors = [{name = "Lamin Labs", email = "open-source@lamin.ai"}] readme = "README.md" dynamic = ["version", "description"] dependencies = [ - "lnschema_core>=0.51.0", "lamin_utils>=0.3.3", # External dependencies "django>4.2,<5.3.0", From 876109430378bb44fda00e76ee9ca6ef08732f7c Mon Sep 17 00:00:00 2001 From: Alex Wolf Date: Thu, 2 Jan 2025 00:30:16 +0100 Subject: [PATCH 28/32] =?UTF-8?q?=F0=9F=92=9A=20Fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lamindb_setup/_init_instance.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lamindb_setup/_init_instance.py b/lamindb_setup/_init_instance.py index 779d7804..94bf8536 100644 --- a/lamindb_setup/_init_instance.py +++ b/lamindb_setup/_init_instance.py @@ -2,7 +2,6 @@ import importlib import os -import sys import uuid from typing import TYPE_CHECKING, Literal from uuid import UUID @@ -302,6 +301,8 @@ def init( update_schema_in_hub(access_token=access_token) if _write_settings: settings.auto_connect = True + importlib.reload(importlib.import_module("lamindb")) + logger.important(f"initialized lamindb: {isettings.slug}") except Exception as e: from ._delete import delete_by_isettings from .core._hub_core import delete_instance_record, delete_storage_record From 238bb46427c2bcb8022693eed4a49ec5307680a4 Mon Sep 17 00:00:00 2001 From: Alex Wolf Date: Thu, 2 Jan 2025 00:56:24 +0100 Subject: [PATCH 29/32] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Refactor=20lamindb?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lamindb_setup/_init_instance.py | 2 +- lamindb_setup/core/_settings_user.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lamindb_setup/_init_instance.py b/lamindb_setup/_init_instance.py index 94bf8536..4061f7bb 100644 --- a/lamindb_setup/_init_instance.py +++ b/lamindb_setup/_init_instance.py @@ -43,8 +43,8 @@ def get_schema_module_name(schema_name, raise_import_error: bool = True) -> str def register_storage_in_instance(ssettings: StorageSettings): + from lamidb.base.users import current_user_id from lamindb.models import Storage - from lamindb.users import current_user_id from .core.hashing import hash_and_encode_as_b62 diff --git a/lamindb_setup/core/_settings_user.py b/lamindb_setup/core/_settings_user.py index 195eebcb..37e14661 100644 --- a/lamindb_setup/core/_settings_user.py +++ b/lamindb_setup/core/_settings_user.py @@ -48,7 +48,7 @@ def __repr__(self) -> str: @property def id(self): """Integer id valid in current intance.""" - from lamindb.users import current_user_id + from lamidb.base.users import current_user_id # there is no cache needed here because current_user_id() # has its own cache From 9b65980d2380f1ed3d04665f0c0a049c086c6dd5 Mon Sep 17 00:00:00 2001 From: Alex Wolf Date: Thu, 2 Jan 2025 01:04:13 +0100 Subject: [PATCH 30/32] =?UTF-8?q?=F0=9F=92=9A=20Fix=20import?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lamindb_setup/_init_instance.py | 2 +- lamindb_setup/core/_settings.py | 2 +- lamindb_setup/core/_settings_user.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lamindb_setup/_init_instance.py b/lamindb_setup/_init_instance.py index 4061f7bb..a8216184 100644 --- a/lamindb_setup/_init_instance.py +++ b/lamindb_setup/_init_instance.py @@ -43,7 +43,7 @@ def get_schema_module_name(schema_name, raise_import_error: bool = True) -> str def register_storage_in_instance(ssettings: StorageSettings): - from lamidb.base.users import current_user_id + from lamindb.base.users import current_user_id from lamindb.models import Storage from .core.hashing import hash_and_encode_as_b62 diff --git a/lamindb_setup/core/_settings.py b/lamindb_setup/core/_settings.py index cad3617c..728363ef 100644 --- a/lamindb_setup/core/_settings.py +++ b/lamindb_setup/core/_settings.py @@ -164,7 +164,7 @@ def cache_dir(self) -> UPath: @property def paths(self) -> type[SetupPaths]: - """Convert cloud paths to lamidb local paths. + """Convert cloud paths to lamindb local paths. Use `settings.paths.cloud_to_local_no_update` or `settings.paths.cloud_to_local`. diff --git a/lamindb_setup/core/_settings_user.py b/lamindb_setup/core/_settings_user.py index 37e14661..3b03367a 100644 --- a/lamindb_setup/core/_settings_user.py +++ b/lamindb_setup/core/_settings_user.py @@ -48,7 +48,7 @@ def __repr__(self) -> str: @property def id(self): """Integer id valid in current intance.""" - from lamidb.base.users import current_user_id + from lamindb.base.users import current_user_id # there is no cache needed here because current_user_id() # has its own cache From 895b4b207ac571af344c387b343dd943499b402c Mon Sep 17 00:00:00 2001 From: Alex Wolf Date: Thu, 2 Jan 2025 01:30:49 +0100 Subject: [PATCH 31/32] =?UTF-8?q?=F0=9F=94=8A=20More=20logging?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lamindb_setup/_connect_instance.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lamindb_setup/_connect_instance.py b/lamindb_setup/_connect_instance.py index 90e09eaf..4eb72f15 100644 --- a/lamindb_setup/_connect_instance.py +++ b/lamindb_setup/_connect_instance.py @@ -396,7 +396,9 @@ def migrate_lnschema_core( cur.execute( "UPDATE django_migrations SET app = 'lamindb' WHERE app = 'lnschema_core'" ) - print("finished migration") + print( + "Renaming tables finished.\nNow, *please* call: lamin migrate deploy" + ) if write_file: no_lnschema_core_file.touch(exist_ok=True) except Exception: From a96cc7c178c87e7b6e59fa766306040677a4633a Mon Sep 17 00:00:00 2001 From: Alex Wolf Date: Thu, 2 Jan 2025 01:46:26 +0100 Subject: [PATCH 32/32] =?UTF-8?q?=F0=9F=92=9A=20Fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lamindb_setup/_migrate.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lamindb_setup/_migrate.py b/lamindb_setup/_migrate.py index 9e83c3e0..ae54e63a 100644 --- a/lamindb_setup/_migrate.py +++ b/lamindb_setup/_migrate.py @@ -5,7 +5,7 @@ from lamin_utils import logger from packaging import version -from ._check_setup import _check_instance_setup +from . import _check_setup from .core._settings import settings from .core.django import setup_django @@ -64,16 +64,18 @@ class migrate: @classmethod def create(cls) -> None: """Create a migration.""" - if _check_instance_setup(): + if _check_setup._check_instance_setup(): raise RuntimeError("Restart Python session to create migration or use CLI!") + _check_setup.IS_LOADING = True setup_django(settings.instance, create_migrations=True) + _check_setup.IS_LOADING = False @classmethod def deploy(cls) -> None: """Deploy a migration.""" from ._schema_metadata import update_schema_in_hub - if _check_instance_setup(): + if _check_setup._check_instance_setup(): raise RuntimeError("Restart Python session to migrate or use CLI!") from lamindb_setup.core._hub_client import call_with_fallback_auth from lamindb_setup.core._hub_crud import (