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
❗ You haven't yet setup an instance: Please call `ln.setup.init()` or `ln.setup.load()`

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):
✅ saved: User(uid='DzTjkKse', handle='testuser1', name='Test User1', updated_at=2024-03-04 13:55:29 UTC)
✅ saved: Storage(uid='DrBy2EkR', root='/home/runner/work/lamindb/lamindb/docs/faq/testsetup', type='local', updated_at=2024-03-04 13:55:29 UTC, created_by_id=1)
💡 lamindb instance: testuser1/testsetup
💡 did not register local instance on lamin.ai

Now we can access functionality:

ln.transform.stem_uid = "2lhqA4uTKSFP"
ln.transform.version = "0"
💡 notebook imports: lamindb==0.68.0 pytest==8.1.0
💡 saved: Transform(uid='2lhqA4uTKSFP6K79', name='What happens when importing lamindb and the instance is not yet setup?', short_name='setup', version='0', type=notebook, updated_at=2024-03-04 13:55:30 UTC, created_by_id=1)
💡 saved: Run(uid='mQlgVXCjF3n0w6TNPiSV', run_at=2024-03-04 13:55:30 UTC, 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):
with pytest.raises(RuntimeError):
!lamin delete --force testsetup
💡 deleting instance testuser1/testsetup
✅     deleted instance settings file: /home/runner/.lamin/instance--testuser1--testsetup.env
✅     instance cache deleted
✅     deleted '.lndb' sqlite file
❗     consider manually deleting your stored data: /home/runner/work/lamindb/lamindb/docs/faq/testsetup