Transfer artifacts from a local instance to a cloud instance

import lamindb as ln
import bionty as bt

ln.connect("laminlabs/lamin-dev")
bt.settings.organism = "human"
Hide code cell content
def cleanup(artifact: ln.Artifact):
    features_sets = artifact.feature_sets.all()
    experiments = artifact.experiments.all()
    artifact.delete(permanent=True, storage=False)
    features_sets.delete()
    experiments.delete()

artifacts = ln.Artifact.filter(description='test-transfer-to-cloud').all()
for artifact in artifacts:
    cleanup(artifact)
→ a file/folder remains here: /home/runner/work/lamindb/lamindb/docs/storage/test-transfer-to-cloud/.lamindb/dQQkyRHlKBnlRkYF0000.parquet
artifact = ln.Artifact.using("testuser1/test-transfer-to-cloud").get(description='test-transfer-to-cloud')
artifact.describe()
Artifact(uid='EbndeiviTrYcoAfg0000', is_latest=True, description='test-transfer-to-cloud', suffix='.parquet', type='dataset', size=1571, hash='5v6hhBMnN8GEQz6OMYjeeQ', _hash_type='md5', _accessor='DataFrame', visibility=1, _key_is_virtual=True, created_at=2024-11-07 12:40:06 UTC)
  Database instance
    slug: testuser1/test-transfer-to-cloud
  Provenance
    .storage = '/home/runner/work/lamindb/lamindb/docs/storage/test-transfer-to-cloud'
    .created_by = 'testuser1'
  Labels
    .experiments = 'experiment-test-transfer-to-cloud'
    .organisms = 'human'
  Feature sets
    'var' = 'PD1', 'CD21'
artifact.save()
! no run & transform got linked, call `ln.track()` & re-run
→ mapped records: Organism(uid='1dpCL6Td')
→ transferred records: Artifact(uid='EbndeiviTrYcoAfg0000'), Experiment(uid='52Jryhd3')
Artifact(uid='EbndeiviTrYcoAfg0000', is_latest=True, description='test-transfer-to-cloud', suffix='.parquet', type='dataset', size=1571, hash='5v6hhBMnN8GEQz6OMYjeeQ', _hash_type='md5', _accessor='DataFrame', visibility=1, _key_is_virtual=True, storage_id=3, transform_id=106, run_id=178, created_by_id=2, created_at=2024-11-07 12:40:18 UTC)
artifact.describe()
Artifact(uid='EbndeiviTrYcoAfg0000', is_latest=True, description='test-transfer-to-cloud', suffix='.parquet', type='dataset', size=1571, hash='5v6hhBMnN8GEQz6OMYjeeQ', _hash_type='md5', _accessor='DataFrame', visibility=1, _key_is_virtual=True, created_at=2024-11-07 12:40:18 UTC)
  Provenance
    .storage = '/home/runner/work/lamindb/lamindb/docs/storage/test-transfer-to-cloud'
    .transform = 'Transfer from `testuser1/test-transfer-to-cloud`'
    .run = '2024-09-27T19:31:22.07491+00:00'
    .created_by = 'testuser1'
  Labels
    .experiments = 'experiment-test-transfer-to-cloud'
    .organisms = 'human'
  Feature sets
    'var' = 'CD21', 'PD1'
assert artifact._state.db == "default"
assert artifact.organisms.get().name == "human"
assert artifact.experiments.get().name == "experiment-test-transfer-to-cloud"
assert artifact.features["var"].count() == 2
!lamin delete --force test-transfer-to-cloud
!rm -r ./test-transfer-to-cloud
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.9.20/x64/bin/lamin", line 8, in <module>
    sys.exit(main())
  File "/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/rich_click/rich_command.py", line 367, in __call__
    return super().__call__(*args, **kwargs)
  File "/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/rich_click/rich_command.py", line 152, in main
    rv = self.invoke(ctx)
  File "/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/lamin_cli/__main__.py", line 209, in delete
    return delete(instance, force=force)
  File "/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/lamindb_setup/_delete.py", line 102, in delete
    n_objects = check_storage_is_empty(
  File "/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/lamindb_setup/core/upath.py", line 817, in check_storage_is_empty
    raise InstanceNotEmpty(message)
lamindb_setup.core.upath.InstanceNotEmpty: Storage '/home/runner/work/lamindb/lamindb/docs/storage/test-transfer-to-cloud/.lamindb' contains 1 objects - delete them prior to deleting the instance