What happens when importing lamindb and the instance it not yet setup?#
Show 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.
Show code cell content
with pytest.raises(ln.InstanceNotSetupError):
ln.track()
ln.setup.init(storage="./testsetup")
✅ saved: User(id='DzTjkKse', handle='testuser1', email='testuser1@lamin.ai', name='Test User1', updated_at=2023-09-26 15:21:38)
✅ saved: Storage(id='6miZxt5M', root='/home/runner/work/lamindb/lamindb/docs/faq/testsetup', type='local', updated_at=2023-09-26 15:21:38, created_by_id='DzTjkKse')
💡 loaded instance: testuser1/testsetup (lamindb 0.54.2)
💡 did not register local instance on hub (if you want, call `lamin register`)
Now we can access functionality:
ln.track()
💡 notebook imports: lamindb==0.54.2 pytest==7.4.2
💡 Transform(id='2lhqA4uTKSFPz8', name='What happens when importing lamindb and the instance it not yet setup?', short_name='setup', version='0', type=notebook, updated_at=2023-09-26 15:21:40, created_by_id='DzTjkKse')
💡 Run(id='REQh5UzYnRBcToa5xgrX', run_at=2023-09-26 15:21:40, transform_id='2lhqA4uTKSFPz8', created_by_id='DzTjkKse')
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")
with pytest.raises(RuntimeError):
ln.setup.load("testsetup")
!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