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()

# !pip install lamindb
!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 got linked, call `ln.track()` & re-run
Artifact(uid='9R5i7zudTfvcRmGf0000', is_latest=True, description='mydf', suffix='.parquet', type='dataset', size=2063, hash='dA85j_zyux35XCnQIWxdGw', _hash_type='md5', _accessor='DataFrame', visibility=1, _key_is_virtual=True, storage_id=1, created_by_id=1, created_at=2024-11-07 20:54:42 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='9R5i7zudTfvcRmGf0000', is_latest=True, description='mydf', suffix='.parquet', type='dataset', size=2063, hash='dA85j_zyux35XCnQIWxdGw', _hash_type='md5', _accessor='DataFrame', visibility=-1, _key_is_virtual=True, storage_id=1, created_by_id=1, created_at=2024-11-07 20:54:42 UTC)]>

You can restore an artifact from trash:

artifact.restore()
assert artifact.visibility == 1
ln.Artifact.filter(description="mydf").all()
<QuerySet [Artifact(uid='9R5i7zudTfvcRmGf0000', is_latest=True, description='mydf', suffix='.parquet', type='dataset', size=2063, hash='dA85j_zyux35XCnQIWxdGw', _hash_type='md5', _accessor='DataFrame', visibility=1, _key_is_virtual=True, storage_id=1, created_by_id=1, created_at=2024-11-07 20:54:42 UTC)]>

Delete test artifact and instance:

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