What happens when importing lamindb and the instance is not yet setup?

Hide code cell content
!lamin close
💡 no instance loaded
import lamindb as ln
import pytest
❗ To use lamindb, you need to connect to an instance.

Connect to an instance: `ln.connect()`. Init an instance: `ln.setup.init()`.

If you used the CLI to set up lamindb in a notebook, restart the Python session.

If you try to use lamindb, it will raise an InstanceNotSetupError and ask you to init or load an instance via the python API.

Hide code cell content
with pytest.raises(ln.InstanceNotSetupError):
    ln.track()
ln.setup.init(storage="./testsetup")
💡 connected lamindb: testuser1/testsetup

Now we can access functionality:

ln.settings.transform.stem_uid = "2lhqA4uTKSFP"
ln.settings.transform.version = "0"
ln.track()
💡 notebook imports: lamindb==0.72.1 pytest==8.2.1
💡 saved: Transform(uid='2lhqA4uTKSFP6K79', version='0', name='What happens when importing lamindb and the instance is not yet setup?', key='setup', type='notebook', created_by_id=1, updated_at='2024-05-25 15:26:07 UTC')
💡 saved: Run(uid='cObfNRkJa48IyumpsogM', transform_id=1, created_by_id=1)
Run(uid='cObfNRkJa48IyumpsogM', started_at='2024-05-25 15:26:07 UTC', is_consecutive=True, transform_id=1, created_by_id=1)

Let us try to init another instance in the same Python session: It doesn’t work.

with pytest.raises(RuntimeError):
    ln.setup.init(storage="./testsetup2")
!lamin delete --force testsetup
💡 deleting instance testuser1/testsetup