Skip to content

Commit

Permalink
♻️ Refactor setup bionty sources (#906)
Browse files Browse the repository at this point in the history
  • Loading branch information
falexwolf authored Nov 24, 2024
1 parent a3f1449 commit 0116981
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions lamindb_setup/core/_setup_bionty_sources.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
from __future__ import annotations

import os
from typing import TYPE_CHECKING

from django.db.utils import OperationalError, ProgrammingError
from lamin_utils import logger

from ._settings import settings as setup_settings

if TYPE_CHECKING:
from ._settings_instance import InstanceSettings
Expand Down Expand Up @@ -63,10 +67,21 @@ def _get_currently_used(key: str):
Source.objects.bulk_create(all_records, ignore_conflicts=True)


def load_bionty_sources(isettings: InstanceSettings):
def load_bionty_sources(isettings: InstanceSettings | None = None):
"""Write currently_used bionty sources to LAMINDB_VERSIONS_PATH in bionty."""
if "bionty" not in isettings.schema:
return None
if isettings is None:
if setup_settings._instance_settings is not None:
isettings = setup_settings.instance
else:
logger.warning(
f"Ignoring bionty setup because running in LAMINDB_MULTI_INSTANCE mode = {os.environ.get('LAMINDB_MULTI_INSTANCE')}"
)
# not setting up bionty sources
return None
if isettings is not None:
if "bionty" not in isettings.schema:
# no need to setup anything
return None

import bionty.base as bionty_base
from bionty.base.dev._handle_sources import parse_currently_used_sources
Expand Down

0 comments on commit 0116981

Please sign in to comment.