lamindb 1.1.1__py3-none-any.whl → 1.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. lamindb/__init__.py +30 -25
  2. lamindb/_tracked.py +1 -1
  3. lamindb/_view.py +2 -3
  4. lamindb/base/__init__.py +1 -1
  5. lamindb/base/ids.py +1 -10
  6. lamindb/core/__init__.py +7 -65
  7. lamindb/core/_compat.py +60 -0
  8. lamindb/core/_context.py +43 -20
  9. lamindb/core/_settings.py +6 -6
  10. lamindb/core/_sync_git.py +1 -1
  11. lamindb/core/loaders.py +30 -19
  12. lamindb/core/storage/_backed_access.py +4 -2
  13. lamindb/core/storage/_tiledbsoma.py +8 -6
  14. lamindb/core/storage/_zarr.py +104 -25
  15. lamindb/core/storage/objects.py +63 -28
  16. lamindb/core/storage/paths.py +4 -1
  17. lamindb/core/types.py +10 -0
  18. lamindb/curators/__init__.py +100 -85
  19. lamindb/errors.py +1 -1
  20. lamindb/integrations/_vitessce.py +4 -4
  21. lamindb/migrations/0089_subsequent_runs.py +159 -0
  22. lamindb/migrations/0090_runproject_project_runs.py +73 -0
  23. lamindb/migrations/{0088_squashed.py → 0090_squashed.py} +245 -177
  24. lamindb/models/__init__.py +79 -0
  25. lamindb/{core → models}/_describe.py +3 -3
  26. lamindb/{core → models}/_django.py +8 -5
  27. lamindb/{core → models}/_feature_manager.py +103 -87
  28. lamindb/{_from_values.py → models/_from_values.py} +5 -2
  29. lamindb/{core/versioning.py → models/_is_versioned.py} +94 -6
  30. lamindb/{core → models}/_label_manager.py +10 -17
  31. lamindb/{core/relations.py → models/_relations.py} +8 -1
  32. lamindb/models/artifact.py +2602 -0
  33. lamindb/{_can_curate.py → models/can_curate.py} +349 -180
  34. lamindb/models/collection.py +683 -0
  35. lamindb/models/core.py +135 -0
  36. lamindb/models/feature.py +643 -0
  37. lamindb/models/flextable.py +163 -0
  38. lamindb/{_parents.py → models/has_parents.py} +55 -49
  39. lamindb/models/project.py +384 -0
  40. lamindb/{_query_manager.py → models/query_manager.py} +10 -8
  41. lamindb/{_query_set.py → models/query_set.py} +40 -26
  42. lamindb/models/record.py +1762 -0
  43. lamindb/models/run.py +563 -0
  44. lamindb/{_save.py → models/save.py} +9 -7
  45. lamindb/models/schema.py +732 -0
  46. lamindb/models/transform.py +360 -0
  47. lamindb/models/ulabel.py +249 -0
  48. {lamindb-1.1.1.dist-info → lamindb-1.2.0.dist-info}/METADATA +6 -6
  49. {lamindb-1.1.1.dist-info → lamindb-1.2.0.dist-info}/RECORD +51 -51
  50. lamindb/_artifact.py +0 -1379
  51. lamindb/_collection.py +0 -440
  52. lamindb/_feature.py +0 -316
  53. lamindb/_is_versioned.py +0 -40
  54. lamindb/_record.py +0 -1064
  55. lamindb/_run.py +0 -60
  56. lamindb/_schema.py +0 -347
  57. lamindb/_storage.py +0 -15
  58. lamindb/_transform.py +0 -170
  59. lamindb/_ulabel.py +0 -56
  60. lamindb/_utils.py +0 -9
  61. lamindb/base/validation.py +0 -63
  62. lamindb/core/_data.py +0 -491
  63. lamindb/core/fields.py +0 -12
  64. lamindb/models.py +0 -4475
  65. {lamindb-1.1.1.dist-info → lamindb-1.2.0.dist-info}/LICENSE +0 -0
  66. {lamindb-1.1.1.dist-info → lamindb-1.2.0.dist-info}/WHEEL +0 -0
lamindb/models/core.py ADDED
@@ -0,0 +1,135 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import (
4
+ TYPE_CHECKING,
5
+ overload,
6
+ )
7
+
8
+ from django.db import models
9
+
10
+ from lamindb.base.fields import (
11
+ CharField,
12
+ )
13
+
14
+ from ..base.ids import base62_12
15
+ from .record import Record
16
+ from .run import TracksRun, TracksUpdates
17
+
18
+ if TYPE_CHECKING:
19
+ from pathlib import Path
20
+
21
+ from upath import UPath
22
+
23
+ from .artifact import Artifact
24
+
25
+
26
+ class Storage(Record, TracksRun, TracksUpdates):
27
+ """Storage locations.
28
+
29
+ A storage location is either a directory/folder (local or in the cloud) or
30
+ an entire S3/GCP bucket.
31
+
32
+ A LaminDB instance can manage and link multiple storage locations. But any
33
+ storage location is managed by *at most one* LaminDB instance.
34
+
35
+ .. dropdown:: Managed vs. linked storage locations
36
+
37
+ The LaminDB instance can update & delete artifacts in managed storage
38
+ locations but merely read artifacts in linked storage locations.
39
+
40
+ When you transfer artifacts from another instance, the default is to
41
+ only copy metadata into the target instance, but merely link the data.
42
+
43
+ The `instance_uid` field indicates the managing LaminDB instance of a
44
+ storage location.
45
+
46
+ When you delete a LaminDB instance, you'll be warned about data in managed
47
+ storage locations while data in linked storage locations is ignored.
48
+
49
+ See Also:
50
+ :attr:`~lamindb.core.Settings.storage`
51
+ Default storage.
52
+ :attr:`~lamindb.setup.core.StorageSettings`
53
+ Storage settings.
54
+
55
+ Examples:
56
+
57
+ Configure the default storage location upon initiation of a LaminDB instance::
58
+
59
+ lamin init --storage ./mydata # or "s3://my-bucket" or "gs://my-bucket"
60
+
61
+ View the default storage location:
62
+
63
+ >>> ln.settings.storage
64
+ PosixPath('/home/runner/work/lamindb/lamindb/docs/guide/mydata')
65
+
66
+ Dynamically change the default storage:
67
+
68
+ >>> ln.settings.storage = "./storage_2" # or a cloud bucket
69
+ """
70
+
71
+ class Meta(Record.Meta, TracksRun.Meta, TracksUpdates.Meta):
72
+ abstract = False
73
+
74
+ _name_field: str = "root"
75
+
76
+ id: int = models.AutoField(primary_key=True)
77
+ """Internal id, valid only in one DB instance."""
78
+ uid: str = CharField(
79
+ editable=False, unique=True, max_length=12, default=base62_12, db_index=True
80
+ )
81
+ """Universal id, valid across DB instances."""
82
+ root: str = CharField(db_index=True, unique=True)
83
+ """Root path of storage (cloud or local path)."""
84
+ description: str | None = CharField(db_index=True, null=True)
85
+ """A description of what the storage location is used for (optional)."""
86
+ type: str = CharField(max_length=30, db_index=True)
87
+ """Can be "local" vs. "s3" vs. "gs"."""
88
+ region: str | None = CharField(max_length=64, db_index=True, null=True)
89
+ """Cloud storage region, if applicable."""
90
+ instance_uid: str | None = CharField(max_length=12, db_index=True, null=True)
91
+ """Instance that manages this storage location."""
92
+ artifacts: Artifact
93
+ """Artifacts contained in this storage location."""
94
+
95
+ @overload
96
+ def __init__(
97
+ self,
98
+ root: str,
99
+ type: str,
100
+ region: str | None,
101
+ ): ...
102
+
103
+ @overload
104
+ def __init__(
105
+ self,
106
+ *db_args,
107
+ ): ...
108
+
109
+ def __init__(
110
+ self,
111
+ *args,
112
+ **kwargs,
113
+ ):
114
+ super().__init__(*args, **kwargs)
115
+
116
+ @property
117
+ def path(self) -> Path | UPath:
118
+ """Bucket or folder path.
119
+
120
+ Cloud storage bucket:
121
+
122
+ >>> ln.Storage("s3://my-bucket").save()
123
+
124
+ Directory/folder in cloud storage:
125
+
126
+ >>> ln.Storage("s3://my-bucket/my-directory").save()
127
+
128
+ Local directory/folder:
129
+
130
+ >>> ln.Storage("./my-directory").save()
131
+ """
132
+ from lamindb_setup.core.upath import create_path
133
+
134
+ access_token = self._access_token if hasattr(self, "_access_token") else None
135
+ return create_path(self.root, access_token=access_token)