When do visibility of artifacts and collections change?

Files and collections in LaminDB have the following 3 levels if visibility:

  • 1: “default”, visible in the UI by default, returned from the query results

  • 0: “hidden”, excluded from the query results, notebook artifacts (generated by lamin save) are default to be hidden

  • -1: “trash”, excluded from the query results, set with .delete()

Setup

!lamin init --storage test-visibility
💡 connected lamindb: testuser1/test-visibility
import lamindb as ln
import pandas as pd
💡 connected lamindb: testuser1/test-visibility
artifact = ln.Artifact.from_df(pd.DataFrame({"a": [1, 2], "b": [3, 4]}), description="mydf")
artifact.save()
❗ no run & transform get linked, consider calling ln.track()
Artifact(uid='ZzuSzU715owPE8CgJYME', description='mydf', suffix='.parquet', accessor='DataFrame', size=2240, hash='pCh1QueKcIO78R19tjOUag', hash_type='md5', visibility=1, key_is_virtual=True, created_by_id=1, storage_id=1, updated_at='2024-05-25 15:26:24 UTC')

New artifact has default visibility 1:

assert artifact.visibility == 1

When you delete an artifact, its visibility is set to -1 (“trash”):

artifact.delete()
❗ moved artifact to trash (visibility = -1)
assert artifact.visibility == -1

Files in trash won’t be returned from default queries:

ln.Artifact.filter(description="mydf").all()
<QuerySet []>

Unless you specify visibility=None to see all hidden and trashed artifacts:

ln.Artifact.filter(description="mydf", visibility=None).all()
<QuerySet [Artifact(uid='ZzuSzU715owPE8CgJYME', description='mydf', suffix='.parquet', accessor='DataFrame', size=2240, hash='pCh1QueKcIO78R19tjOUag', hash_type='md5', visibility=-1, key_is_virtual=True, created_by_id=1, storage_id=1, updated_at='2024-05-25 15:26:24 UTC')]>

You can restore an artifact from trash:

artifact.restore()
assert artifact.visibility == 1
ln.Artifact.filter(description="mydf").all()
<QuerySet [Artifact(uid='ZzuSzU715owPE8CgJYME', description='mydf', suffix='.parquet', accessor='DataFrame', size=2240, hash='pCh1QueKcIO78R19tjOUag', hash_type='md5', visibility=1, key_is_virtual=True, created_by_id=1, storage_id=1, updated_at='2024-05-25 15:26:24 UTC')]>

Delete test artifact and instance:

artifact.delete(permanent=True)
!lamin delete --force test-visibility
💡 deleting instance testuser1/test-visibility