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"
! schema module 'clinicore' is not installed → no access to its labels & registries (resolve via `pip install clinicore`)
→ connected lamindb: laminlabs/lamin-dev
Show 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/zydt1XENMylPghgh0000.parquet
artifact = ln.Artifact.using("testuser1/test-transfer-to-cloud").get(
description="test-transfer-to-cloud"
)
artifact.describe()
Artifact .parquet/DataFrame ├── General │ ├── .uid = 'eju4fdhwcvisNTkE0000' │ ├── .size = 1562 │ ├── .hash = 'poQJlkY6NKUW_FTujwevGQ' │ ├── .path = │ │ /home/runner/work/lamindb/lamindb/docs/storage/test-transfer-to-cloud/.lamindb/eju4fdhwcvisNTkE0000.parquet │ ├── .created_by = testuser1 (Test User1) │ └── .created_at = 2025-01-17 14:21:29 ├── Dataset features/._schemas_m2m │ └── var • 2 [bionty.CellMarker] │ PD1 num │ CD21 num └── Labels └── .experiments wetlab.Experiment experiment-test-transfer-to-cloud .organisms bionty.Organism human
artifact.save()
! no run & transform got linked, call `ln.track()` & re-run
→ mapped records: Organism(uid='1dpCL6Td')
→ transferred records: Artifact(uid='eju4fdhwcvisNTkE0000'), Experiment(uid='BkxZyddH')
Artifact(uid='eju4fdhwcvisNTkE0000', is_latest=True, description='test-transfer-to-cloud', suffix='.parquet', kind='dataset', otype='DataFrame', size=1562, hash='poQJlkY6NKUW_FTujwevGQ', space_id=1, storage_id=3, run_id=178, created_by_id=2, created_at=2025-01-17 14:21:29 UTC)
artifact.describe()
Artifact .parquet/DataFrame ├── General │ ├── .uid = 'eju4fdhwcvisNTkE0000' │ ├── .size = 1562 │ ├── .hash = 'poQJlkY6NKUW_FTujwevGQ' │ ├── .path = │ │ /home/runner/work/lamindb/lamindb/docs/storage/test-transfer-to-cloud/.lamindb/eju4fdhwcvisNTkE0000.parquet │ ├── .created_by = testuser1 (Test User1) │ ├── .created_at = 2025-01-17 14:21:29 │ └── .transform = 'Transfer from `testuser1/test-transfer-to-cloud`' ├── Dataset features/._schemas_m2m │ └── var • 2 [bionty.CellMarker] │ CD21 num │ PD1 num └── Labels └── .experiments wetlab.Experiment experiment-test-transfer-to-cloud .organisms bionty.Organism human
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
╭─ Error ──────────────────────────────────────────────────────────────────────╮
│ Storage │
│ '/home/runner/work/lamindb/lamindb/docs/storage/test-transfer-to-cloud/.lami │
│ ndb' contains 1 objects - delete them prior to deleting the instance │
╰──────────────────────────────────────────────────────────────────────────────╯