Skip to content

Commit

Permalink
🔊 Profile more
Browse files Browse the repository at this point in the history
  • Loading branch information
falexwolf committed Sep 29, 2024
1 parent afffe9e commit 594ec16
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 13 deletions.
15 changes: 5 additions & 10 deletions lamindb_setup/_connect_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
from ._close import close as close_instance
from ._init_instance import MESSAGE_NO_MULTIPLE_INSTANCE, load_from_isettings
from ._silence_loggers import silence_loggers
from .core._hub_core import connect_instance as load_instance_from_hub
from .core._hub_core import connect_instance_new as load_instance_from_hub_edge
from .core._hub_core import connect_instance as connect_instance_from_hub
from .core._hub_utils import (
LaminDsn,
LaminDsnModel,
Expand Down Expand Up @@ -111,6 +110,7 @@ def update_db_using_local(
return db_updated


@profile
def _connect_instance(
owner: str,
name: str,
Expand All @@ -130,14 +130,9 @@ def _connect_instance(
# on the hub
# do not call hub if the user is anonymous
if owner != "anonymous":
if settings.user.handle in {"Koncopd", "sunnyosun", "falexwolf"}:
hub_result = load_instance_from_hub_edge(
owner=owner, name=name, access_token=access_token
)
else:
hub_result = load_instance_from_hub(
owner=owner, name=name, access_token=access_token
)
hub_result = connect_instance_from_hub(
owner=owner, name=name, access_token=access_token
)
else:
hub_result = "anonymous-user"
# if hub_result is not a string, it means it made a request
Expand Down
3 changes: 0 additions & 3 deletions lamindb_setup/_init_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ def reload_schema_modules(isettings: InstanceSettings, include_core: bool = True
importlib.reload(schema_module)


@profile
def reload_lamindb_itself(isettings) -> bool:
reloaded = False
if "lamindb" in sys.modules:
Expand All @@ -120,7 +119,6 @@ def reload_lamindb_itself(isettings) -> bool:
return reloaded


@profile
def reload_lamindb(isettings: InstanceSettings):
log_message = settings.auto_connect
if not reload_lamindb_itself(isettings):
Expand Down Expand Up @@ -343,7 +341,6 @@ def init(
return None


@profile
def load_from_isettings(
isettings: InstanceSettings,
*,
Expand Down
2 changes: 2 additions & 0 deletions lamindb_setup/core/_hub_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from uuid import UUID

from lamin_utils import logger
from line_profiler import profile
from postgrest.exceptions import APIError

from lamindb_setup._migrate import check_whether_migrations_in_sync
Expand Down Expand Up @@ -341,6 +342,7 @@ def connect_instance(
return call_with_fallback(_connect_instance, owner=owner, name=name)


@profile
def _connect_instance(
*,
owner: str, # account_handle
Expand Down
2 changes: 2 additions & 0 deletions lamindb_setup/core/_settings_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from django.db.utils import ProgrammingError
from lamin_utils import logger
from line_profiler import profile

from ._hub_client import call_with_fallback
from ._hub_crud import select_account_handle_name_by_lnid
Expand Down Expand Up @@ -456,6 +457,7 @@ def _init_db(self):

setup_django(self, init=True)

@profile
def _load_db(self) -> tuple[bool, str]:
# Is the database available and initialized as LaminDB?
# returns a tuple of status code and message
Expand Down
2 changes: 2 additions & 0 deletions lamindb_setup/core/django.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from ._settings_store import current_instance_settings_file
from ._settings_instance import InstanceSettings
import sys
from line_profiler import profile

IS_RUN_FROM_IPYTHON = getattr(builtins, "__IPYTHON__", False)
IS_SETUP = False
Expand All @@ -24,6 +25,7 @@ def close_if_health_check_failed(self) -> None:


# this bundles set up and migration management
@profile
def setup_django(
isettings: InstanceSettings,
deploy_migrations: bool = False,
Expand Down

0 comments on commit 594ec16

Please sign in to comment.