Skip to content

Commit

Permalink
🚚 Rename lnschema_core to lamindb
Browse files Browse the repository at this point in the history
  • Loading branch information
falexwolf committed Dec 31, 2024
1 parent 1560475 commit 25c4f71
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 23 deletions.
2 changes: 1 addition & 1 deletion docs/hub-cloud/01-init-local-instance.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion docs/hub-cloud/03-add-managed-storage.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion docs/hub-cloud/08-test-multi-session.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"metadata": {},
"outputs": [],
"source": [
"from lnschema_core.models import User"
"from lamindb.models import User"
]
},
{
Expand Down
12 changes: 5 additions & 7 deletions lamindb_setup/_connect_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion lamindb_setup/_exportdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pathlib import Path

MODELS = {
"core": {
"lamindb": {
"Collection": False,
"Artifact": False,
"Transform": False,
Expand Down
8 changes: 4 additions & 4 deletions lamindb_setup/_init_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]

Expand Down
8 changes: 4 additions & 4 deletions lamindb_setup/_schema_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand All @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion lamindb_setup/core/_settings_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lamindb_setup/core/_settings_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lamindb_setup/core/_settings_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lamindb_setup/core/django.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 25c4f71

Please sign in to comment.