Skip to content

Commit

Permalink
do not write no_lnschema_bionty_file
Browse files Browse the repository at this point in the history
  • Loading branch information
Koncopd committed Sep 20, 2024
1 parent 38153b5 commit f4f0583
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lamindb_setup/_connect_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,15 @@ def connect(
settings_dir / f"no_lnschema_bionty-{isettings.slug.replace('/', '')}"
)
if not no_lnschema_bionty_file.exists():
migrate_lnschema_bionty(isettings, no_lnschema_bionty_file)
migrate_lnschema_bionty(
isettings, no_lnschema_bionty_file, write_file=_write_settings
)
return None


def migrate_lnschema_bionty(isettings: InstanceSettings, no_lnschema_bionty_file: Path):
def migrate_lnschema_bionty(
isettings: InstanceSettings, no_lnschema_bionty_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')
Expand Down Expand Up @@ -350,7 +354,8 @@ def migrate_lnschema_bionty(isettings: InstanceSettings, no_lnschema_bionty_file
]

if migrated:
no_lnschema_bionty_file.touch(exist_ok=True)
if write_file:
no_lnschema_bionty_file.touch(exist_ok=True)
else:
try:
# rename tables only if bionty_source doesn't exist and there are tables to rename
Expand All @@ -372,8 +377,8 @@ def migrate_lnschema_bionty(isettings: InstanceSettings, no_lnschema_bionty_file
logger.warning(
"Please uninstall lnschema-bionty via `pip uninstall lnschema-bionty`!"
)

no_lnschema_bionty_file.touch(exist_ok=True)
if write_file:
no_lnschema_bionty_file.touch(exist_ok=True)

Check warning on line 381 in lamindb_setup/_connect_instance.py

View check run for this annotation

Codecov / codecov/patch

lamindb_setup/_connect_instance.py#L380-L381

Added lines #L380 - L381 were not covered by tests
except Exception:
# read-only users can't rename tables
pass
Expand Down

0 comments on commit f4f0583

Please sign in to comment.