lamindb 1.6.2__py3-none-any.whl → 1.7.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 (62) hide show
  1. lamindb/__init__.py +1 -3
  2. lamindb/_finish.py +32 -16
  3. lamindb/base/types.py +6 -4
  4. lamindb/core/_context.py +127 -57
  5. lamindb/core/_mapped_collection.py +1 -1
  6. lamindb/core/_settings.py +44 -4
  7. lamindb/core/_track_environment.py +5 -2
  8. lamindb/core/loaders.py +1 -1
  9. lamindb/core/storage/_anndata_accessor.py +1 -1
  10. lamindb/core/storage/_tiledbsoma.py +14 -8
  11. lamindb/core/storage/_valid_suffixes.py +0 -1
  12. lamindb/core/storage/_zarr.py +1 -1
  13. lamindb/core/storage/objects.py +13 -8
  14. lamindb/core/storage/paths.py +9 -6
  15. lamindb/core/types.py +1 -1
  16. lamindb/curators/_legacy.py +2 -1
  17. lamindb/curators/core.py +106 -105
  18. lamindb/errors.py +9 -0
  19. lamindb/examples/fixtures/__init__.py +0 -0
  20. lamindb/examples/fixtures/sheets.py +224 -0
  21. lamindb/migrations/0103_remove_writelog_migration_state_and_more.py +1 -1
  22. lamindb/migrations/0105_record_unique_name.py +20 -0
  23. lamindb/migrations/0106_transfer_data_migration.py +25 -0
  24. lamindb/migrations/0107_add_schema_to_record.py +68 -0
  25. lamindb/migrations/0108_remove_record_sheet_remove_sheetproject_sheet_and_more.py +30 -0
  26. lamindb/migrations/0109_record_input_of_runs_alter_record_run_and_more.py +123 -0
  27. lamindb/migrations/0110_rename_values_artifacts_record_linked_artifacts.py +17 -0
  28. lamindb/migrations/0111_remove_record__sort_order.py +148 -0
  29. lamindb/migrations/0112_alter_recordartifact_feature_and_more.py +105 -0
  30. lamindb/migrations/0113_lower_case_branch_and_space_names.py +62 -0
  31. lamindb/migrations/0114_alter_run__status_code.py +24 -0
  32. lamindb/migrations/0115_alter_space_uid.py +52 -0
  33. lamindb/migrations/{0104_squashed.py → 0115_squashed.py} +261 -257
  34. lamindb/models/__init__.py +4 -3
  35. lamindb/models/_describe.py +88 -31
  36. lamindb/models/_feature_manager.py +627 -658
  37. lamindb/models/_label_manager.py +1 -3
  38. lamindb/models/artifact.py +214 -99
  39. lamindb/models/collection.py +7 -1
  40. lamindb/models/feature.py +288 -60
  41. lamindb/models/has_parents.py +3 -3
  42. lamindb/models/project.py +32 -15
  43. lamindb/models/query_manager.py +7 -1
  44. lamindb/models/query_set.py +118 -41
  45. lamindb/models/record.py +140 -94
  46. lamindb/models/run.py +42 -42
  47. lamindb/models/save.py +102 -16
  48. lamindb/models/schema.py +41 -8
  49. lamindb/models/sqlrecord.py +105 -40
  50. lamindb/models/storage.py +278 -0
  51. lamindb/models/transform.py +10 -2
  52. lamindb/models/ulabel.py +9 -1
  53. lamindb/py.typed +0 -0
  54. lamindb/setup/__init__.py +2 -1
  55. lamindb/setup/_switch.py +16 -0
  56. lamindb/setup/errors/__init__.py +4 -0
  57. lamindb/setup/types/__init__.py +4 -0
  58. {lamindb-1.6.2.dist-info → lamindb-1.7.0.dist-info}/METADATA +5 -5
  59. {lamindb-1.6.2.dist-info → lamindb-1.7.0.dist-info}/RECORD +61 -44
  60. lamindb/models/core.py +0 -135
  61. {lamindb-1.6.2.dist-info → lamindb-1.7.0.dist-info}/LICENSE +0 -0
  62. {lamindb-1.6.2.dist-info → lamindb-1.7.0.dist-info}/WHEEL +0 -0
lamindb/models/core.py DELETED
@@ -1,135 +0,0 @@
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 .run import TracksRun, TracksUpdates
16
- from .sqlrecord import SQLRecord
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(SQLRecord, TracksRun, TracksUpdates):
27
- """Storage locations of artifacts such as S3 buckets or local directories.
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(SQLRecord.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)