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()
    try:
        artifact.delete(permanent=True)
    except Exception as e:
        print(e)
        pass
    features_sets.delete()
    experiments.delete()

artifacts = ln.Artifact.filter(description='test-transfer-to-cloud').all()
for artifact in artifacts:
    cleanup(artifact)
❗ couldn't delete files outside of default storage
artifact = ln.Artifact.using("testuser1/test-transfer-to-cloud").filter(description='test-transfer-to-cloud').one()
artifact.describe()
Artifact(uid='IiFxBv0x4Dg7ygRNH2Z9', description='test-transfer-to-cloud', suffix='.parquet', accessor='DataFrame', size=1654, hash='7D9KyOpePOAwibz6Hl6V4A', hash_type='md5', visibility=1, key_is_virtual=True, updated_at='2024-05-25 15:34:55 UTC')
  Provenance
    .created_by = 'testuser1'
    .storage = '/home/runner/work/lamindb/lamindb/docs/storage/test-transfer-to-cloud'
  Labels
    .organisms = 'human'
    .experiments = 'experiment-test-transfer-to-cloud'
artifact.save()
❗ no run & transform get linked, consider calling ln.track()
💡 returning existing Organism(uid='1dpCL6Td') on default database
Artifact(uid='IiFxBv0x4Dg7ygRNH2Z9', description='test-transfer-to-cloud', suffix='.parquet', accessor='DataFrame', size=1654, hash='7D9KyOpePOAwibz6Hl6V4A', hash_type='md5', visibility=1, key_is_virtual=True, created_by_id=2, storage_id=3, updated_at='2024-05-25 15:35:01 UTC')
artifact.describe()
Artifact(uid='IiFxBv0x4Dg7ygRNH2Z9', description='test-transfer-to-cloud', suffix='.parquet', accessor='DataFrame', size=1654, hash='7D9KyOpePOAwibz6Hl6V4A', hash_type='md5', visibility=1, key_is_virtual=True, updated_at='2024-05-25 15:35:01 UTC')
  Provenance
    .created_by = 'testuser1'
    .storage = '/home/runner/work/lamindb/lamindb/docs/storage/test-transfer-to-cloud'
  Labels
    .organisms = 'human'
    .experiments = 'experiment-test-transfer-to-cloud'
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.19/x64/bin/lamin", line 8, in <module>
    sys.exit(main())
  File "/opt/hostedtoolcache/Python/3.9.19/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.19/x64/lib/python3.9/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/opt/hostedtoolcache/Python/3.9.19/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.19/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.19/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.19/x64/lib/python3.9/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/opt/hostedtoolcache/Python/3.9.19/x64/lib/python3.9/site-packages/lamin_cli/__main__.py", line 103, in delete
    return delete(instance, force=force)
  File "/opt/hostedtoolcache/Python/3.9.19/x64/lib/python3.9/site-packages/lamindb_setup/_delete.py", line 98, in delete
    n_objects = check_storage_is_empty(
  File "/opt/hostedtoolcache/Python/3.9.19/x64/lib/python3.9/site-packages/lamindb_setup/core/upath.py", line 798, 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 ('_is_initialized' ignored) - delete them prior to deleting the instance
['/home/runner/work/lamindb/lamindb/docs/storage/test-transfer-to-cloud/.lamindb/IiFxBv0x4Dg7ygRNH2Z9.parquet', '/home/runner/work/lamindb/lamindb/docs/storage/test-transfer-to-cloud/.lamindb/_is_initialized']