Connect to local instance¶
!lamin disconnect
!lamin delete --force mydata
!lamin init --storage mydata
!lamin disconnect
import lamindb_setup as ln_setup
from lamindb_setup._check_setup import ModuleWasntConfigured
import pytest
Load your own instance by name¶
If the user is the instance owner, load the instance by name:
# bionty is not in the (schema) modules of mydata
# _check_instance_setup is called inside with from_module=None
# the branch where django is not setup yet
# as from_module=None it won't connect to an instance here
import bionty
ln_setup.connect(
"mydata", _reload_lamindb=False
) # also test passing _reload_lamindb explicitly
# wetlab is not in the (schema) modules of mydata
with pytest.raises(ModuleWasntConfigured):
# _check_instance_setup is called inside with from_module=None
# the branch where django is setup
import wetlab
# wetlab is not in the (schema) modules of mydata
with pytest.raises(ModuleWasntConfigured):
# _check_instance_setup is called inside with from_module="bionty"
# the branch where django is setup
# in __getattr__ in __init__.py
bionty.CellType
Show code cell content
from pathlib import Path
assert ln_setup.settings.instance.storage.type_is_cloud is False
assert ln_setup.settings.instance.name == "mydata"
root_path = Path("./mydata").resolve()
assert ln_setup.settings.instance.storage.root == root_path
assert (
ln_setup.settings.instance.db
== f"sqlite:///{root_path.as_posix()}/.lamindb/lamin.db"
)
Delete:
ln_setup.delete("mydata", force=True)