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.74.0 pytest==8.2.2
💡 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-06-19 23:05:39 UTC')
💡 saved: Run(uid='aqgOfULvtA9nUEYgu53q', transform_id=1, created_by_id=1)
Run(uid='aqgOfULvtA9nUEYgu53q', started_at='2024-06-19 23:05:39 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