lamindb 1.7a1__py3-none-any.whl → 1.7.1__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.
lamindb/__init__.py CHANGED
@@ -108,7 +108,7 @@ Backwards compatibility.
108
108
 
109
109
  # ruff: noqa: I001
110
110
  # denote a release candidate for 0.1.0 with 0.1rc1, 0.1a1, 0.1b1, etc.
111
- __version__ = "1.7a1"
111
+ __version__ = "1.7.1"
112
112
 
113
113
  import warnings
114
114
 
lamindb/core/_context.py CHANGED
@@ -334,8 +334,8 @@ class Context:
334
334
  Args:
335
335
  transform: A transform (stem) `uid` (or record). If `None`, auto-creates a `transform` with its `uid`.
336
336
  project: A project (or its `name` or `uid`) for labeling entities.
337
- space: A restricted space (or its `name` or `uid`) in which to store artifacts, collections, transforms, and runs.
338
- Default: the `"All"` space.
337
+ space: A restricted space (or its `name` or `uid`) in which to store entities.
338
+ Default: the `"all"` space. Note that bionty entities ignore this setting and always get written to the `"all"` space.
339
339
  If you want to manually move entities to a different space, set the `.space` field (:doc:`docs:access`).
340
340
  branch: A branch (or its `name` or `uid`) on which to store records.
341
341
  params: A dictionary of parameters to track for the run.
@@ -0,0 +1,52 @@
1
+ # Generated by Django 5.2 on 2025-07-06 23:09
2
+
3
+ from django.db import migrations
4
+
5
+ import lamindb.base.fields
6
+
7
+
8
+ def extenddefault_values(apps, schema_editor):
9
+ """Lowercase default values for Space and Branch models."""
10
+ Space = apps.get_model("lamindb", "Space")
11
+ Branch = apps.get_model("lamindb", "Branch")
12
+
13
+ space = Space.objects.get(uid="a")
14
+ space.uid = 12 * "a"
15
+ space.save()
16
+
17
+ trash_branch = Branch.objects.get(uid="t")
18
+ trash_branch.uid = 12 * "t"
19
+ trash_branch.save()
20
+
21
+ archive_branch = Branch.objects.get(uid="a")
22
+ archive_branch.uid = 12 * "a"
23
+ archive_branch.save()
24
+
25
+ main_branch = Branch.objects.get(uid="m")
26
+ main_branch.uid = 12 * "m"
27
+ main_branch.save()
28
+
29
+
30
+ class Migration(migrations.Migration):
31
+ dependencies = [
32
+ ("lamindb", "0114_alter_run__status_code"),
33
+ ]
34
+
35
+ operations = [
36
+ migrations.AlterField(
37
+ model_name="space",
38
+ name="uid",
39
+ field=lamindb.base.fields.CharField(
40
+ blank=True,
41
+ db_default="aaaaaaaaaaaa",
42
+ db_index=True,
43
+ default="aaaaaaaaaaaaa",
44
+ editable=False,
45
+ max_length=12,
46
+ unique=True,
47
+ ),
48
+ ),
49
+ migrations.RunPython(
50
+ extenddefault_values,
51
+ ),
52
+ ]
@@ -136,6 +136,7 @@ class Migration(migrations.Migration):
136
136
  ("lamindb", "0112_alter_recordartifact_feature_and_more"),
137
137
  ("lamindb", "0113_lower_case_branch_and_space_names"),
138
138
  ("lamindb", "0114_alter_run__status_code"),
139
+ ("lamindb", "0115_alter_space_uid"),
139
140
  ]
140
141
 
141
142
  dependencies = [] # type: ignore
@@ -214,9 +215,9 @@ class Migration(migrations.Migration):
214
215
  "uid",
215
216
  lamindb.base.fields.CharField(
216
217
  blank=True,
217
- db_default="A",
218
+ db_default="aaaaaaaaaaaa",
218
219
  db_index=True,
219
- default="A",
220
+ default="aaaaaaaaaaaaa",
220
221
  editable=False,
221
222
  max_length=12,
222
223
  unique=True,
@@ -661,43 +661,53 @@ class BaseSQLRecord(models.Model, metaclass=Registry):
661
661
  def __init__(self, *args, **kwargs):
662
662
  skip_validation = kwargs.pop("_skip_validation", False)
663
663
  if not args:
664
- if self.__class__.__name__ in {
665
- "Artifact",
666
- "Collection",
667
- "Transform",
668
- "Run",
669
- }:
664
+ if (
665
+ issubclass(self.__class__, SQLRecord)
666
+ and self.__class__.__name__ != "Storage"
667
+ # do not save bionty entities in restricted spaces by default
668
+ and self.__class__.__module__ != "bionty.models"
669
+ ):
670
670
  from lamindb import context as run_context
671
671
 
672
672
  if run_context.space is not None:
673
+ current_space = run_context.space
674
+ elif setup_settings.space is not None:
675
+ current_space = setup_settings.space
676
+
677
+ if current_space is not None:
673
678
  if "space_id" in kwargs:
674
679
  # space_id takes precedence over space
675
680
  # https://claude.ai/share/f045e5dc-0143-4bc5-b8a4-38309229f75e
676
681
  if kwargs["space_id"] == 1: # ignore default space
677
682
  kwargs.pop("space_id")
678
- kwargs["space"] = run_context.space
683
+ kwargs["space"] = current_space
679
684
  elif "space" in kwargs:
680
685
  if kwargs["space"] is None:
681
- kwargs["space"] = run_context.space
686
+ kwargs["space"] = current_space
682
687
  else:
683
- kwargs["space"] = run_context.space
688
+ kwargs["space"] = current_space
684
689
  if issubclass(
685
690
  self.__class__, SQLRecord
686
691
  ) and self.__class__.__name__ not in {"Storage", "Source"}:
687
692
  from lamindb import context as run_context
688
693
 
689
694
  if run_context.branch is not None:
695
+ current_branch = run_context.branch
696
+ elif setup_settings.branch is not None:
697
+ current_branch = setup_settings.branch
698
+
699
+ if current_branch is not None:
690
700
  # branch_id takes precedence over branch
691
701
  # https://claude.ai/share/f045e5dc-0143-4bc5-b8a4-38309229f75e
692
702
  if "branch_id" in kwargs:
693
703
  if kwargs["branch_id"] == 1: # ignore default branch
694
704
  kwargs.pop("branch_id")
695
- kwargs["branch"] = run_context.branch
705
+ kwargs["branch"] = current_branch
696
706
  elif "branch" in kwargs:
697
707
  if kwargs["branch"] is None:
698
- kwargs["branch"] = run_context.branch
708
+ kwargs["branch"] = current_branch
699
709
  else:
700
- kwargs["branch"] = run_context.branch
710
+ kwargs["branch"] = current_branch
701
711
  if skip_validation:
702
712
  super().__init__(**kwargs)
703
713
  else:
@@ -952,8 +962,8 @@ class Space(BaseSQLRecord):
952
962
  editable=False,
953
963
  unique=True,
954
964
  max_length=12,
955
- default="A",
956
- db_default="A",
965
+ default="aaaaaaaaaaaaa",
966
+ db_default="aaaaaaaaaaaa",
957
967
  db_index=True,
958
968
  )
959
969
  """Universal id."""
lamindb/setup/__init__.py CHANGED
@@ -8,6 +8,7 @@ from lamindb_setup import (
8
8
  )
9
9
 
10
10
  from . import core, errors, types
11
+ from ._switch import switch # noqa: F401
11
12
 
12
13
  del connect # we have this at the root level, hence, we don't want it here
13
14
  __doc__ = _lamindb_setup.__doc__.replace("lamindb_setup", "lamindb.setup")
@@ -0,0 +1,16 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING
4
+
5
+ from lamindb_setup import settings
6
+
7
+ if TYPE_CHECKING:
8
+ from lamindb.models import Branch, Space
9
+
10
+
11
+ def switch(*, branch: str | Branch | None = None, space: str | Space | None = None):
12
+ """Switch to a branch or space, create if not exists."""
13
+ if branch is not None:
14
+ settings.branch = branch
15
+ if space is not None:
16
+ settings.space = space
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: lamindb
3
- Version: 1.7a1
3
+ Version: 1.7.1
4
4
  Summary: A data framework for biology.
5
5
  Author-email: Lamin Labs <open-source@lamin.ai>
6
6
  Requires-Python: >=3.10,<3.14
@@ -10,8 +10,8 @@ Classifier: Programming Language :: Python :: 3.11
10
10
  Classifier: Programming Language :: Python :: 3.12
11
11
  Classifier: Programming Language :: Python :: 3.13
12
12
  Requires-Dist: lamin_utils==0.15.0
13
- Requires-Dist: lamin_cli==1.5.1
14
- Requires-Dist: lamindb_setup[aws]==1.7.0
13
+ Requires-Dist: lamin_cli==1.5.4
14
+ Requires-Dist: lamindb_setup[aws]==1.7.3
15
15
  Requires-Dist: pyyaml
16
16
  Requires-Dist: pyarrow
17
17
  Requires-Dist: pandera>=0.24.0
@@ -1,4 +1,4 @@
1
- lamindb/__init__.py,sha256=FzHtSn1eMOasSWUktr67iYTP9M5kqs1SF325l6orecQ,2904
1
+ lamindb/__init__.py,sha256=AbAQWHFKQBqEh_bjTl3Vby-9IxDwDvg4k3RYbT7eDLs,2904
2
2
  lamindb/_finish.py,sha256=MZKXiGk_NFRyc693OXitqq7Qd9bGojcBe26JkingJGI,20859
3
3
  lamindb/_tracked.py,sha256=-wK7BJv30nf4v2_nH5qDCyxHvug7ih6duQNGxDrj3UE,4447
4
4
  lamindb/_view.py,sha256=cod1RnZoLyzMVJcjWjytg78Sf4qsR8IAdqpwzsi8FTw,4950
@@ -12,7 +12,7 @@ lamindb/base/uids.py,sha256=cLBi5mIlsf1ltkTb17r1FLzlOjlGmjvsCygoVJHQ-A8,2116
12
12
  lamindb/base/users.py,sha256=8MSmAvCKoUF15YsDE6BGLBXsFWpfoEEg8iDTKZ7kD48,848
13
13
  lamindb/core/__init__.py,sha256=aaBq0UVjNolMynbT1V5hB6UrJm1tK0M6WHu_r6em9_4,604
14
14
  lamindb/core/_compat.py,sha256=NLnKk1qk4xdgMV-QwFDnBnbio02ujjlF86icvhpdv4c,2029
15
- lamindb/core/_context.py,sha256=Lv6Ag5p7dQgIiAKlJM8VKPVIAOlBXxR_DeamVKq-vS4,39736
15
+ lamindb/core/_context.py,sha256=pRcpBW1gsk3xBKL6dV2BiyHV_Iz0bGjSGDXkBsZz6Hc,39791
16
16
  lamindb/core/_mapped_collection.py,sha256=osquwC6ee0wJ_I6O-8AZwnQUa_r9zqa0MN82Q-nBI3Y,25746
17
17
  lamindb/core/_settings.py,sha256=7Dw1SOtUCfyg3VyxgV696UYjJYmVogyiNM2P1ZL9RMk,7937
18
18
  lamindb/core/_sync_git.py,sha256=Z7keuyS5X7CAj285sEbZIFExZF9mtjGH8DzKwz3xhHw,5881
@@ -97,7 +97,8 @@ lamindb/migrations/0111_remove_record__sort_order.py,sha256=m5CC_VXupeUywupKQ74R
97
97
  lamindb/migrations/0112_alter_recordartifact_feature_and_more.py,sha256=19AothLLch_iY5W5YhH3G-paNFSlqTeGwVfYX78o8Hc,3458
98
98
  lamindb/migrations/0113_lower_case_branch_and_space_names.py,sha256=Xt2krstx3t30iTi2z0qTCBNteDA5Wy9L-thRXJSeUA8,1734
99
99
  lamindb/migrations/0114_alter_run__status_code.py,sha256=KkGecSBJElA3LBnhSK5_rFpcFridOuv6BhM8DCYqTKw,612
100
- lamindb/migrations/0114_squashed.py,sha256=O_iKRrE4wgcrcJjXuOIigE5EfunJeY03Ev9INsyaBus,162867
100
+ lamindb/migrations/0115_alter_space_uid.py,sha256=18fCP8d31Ox1KxSSmfzU-W3lSpS3xtiaBNbPeHQiuTM,1332
101
+ lamindb/migrations/0115_squashed.py,sha256=gDjKt5S-Uk5NK72JPnsB1zD_kyAVIXR5DFEBHNAUcr4,162935
101
102
  lamindb/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
102
103
  lamindb/models/__init__.py,sha256=mtjZH0x31aV463YaUef8ZvdQHlGa6SZr_thsrlbdkCg,2419
103
104
  lamindb/models/_describe.py,sha256=kxw7E_a5FqAI_GEH0QDGsBywQtmZ9DqQrJxnFmVJDt8,7717
@@ -120,15 +121,16 @@ lamindb/models/record.py,sha256=syOBBefZhlqZpoVJD32uqzEzbwXiOboAOA3AlGaOkhE,1205
120
121
  lamindb/models/run.py,sha256=3xCAJnxK4iNeFlFz1bAxYDnRGU4HnRpDfxq4MwB6cPw,15565
121
122
  lamindb/models/save.py,sha256=jXha2jfY-pWsKuP2dwaEROhUGxhM8fTWQGWAzA_xsM0,16777
122
123
  lamindb/models/schema.py,sha256=oI3_eUYTYrMofOVJTCCKVkGr4L6VWpIxx5L4fauTtn8,48244
123
- lamindb/models/sqlrecord.py,sha256=bnsDXXqnfUMdhYwCPL82xLxR8JuJJUpzwsIbkYbuSl4,67588
124
+ lamindb/models/sqlrecord.py,sha256=FqtK9epCiFPhqr2DI0W6OmU621wU7FVh9rXouGK3_3w,68136
124
125
  lamindb/models/storage.py,sha256=D5wVikrFiQqrDIOVB0nJvX2f5nicrFHIBlan7AMqDn0,11387
125
126
  lamindb/models/transform.py,sha256=BceBz250AznWf85LefgS2nJNye_xJ0w_jce-mGJDN6Y,12474
126
127
  lamindb/models/ulabel.py,sha256=ocAMSKeQcq2Kr6Dq0mxGupOmW1K0pAs19vjDeTEb6vM,9335
127
- lamindb/setup/__init__.py,sha256=VOkMk9WVySxj0cHj9ASJnjpjhJiDOg2hA9HjNNzoxQE,425
128
+ lamindb/setup/__init__.py,sha256=QZ-JF8IzO_ckDOU223lsJrdO5ay7cDFgvCbkLeAuxYA,467
129
+ lamindb/setup/_switch.py,sha256=njZJN__JOhVrBFGClQG1wobdhJJp6l_XzPGKtKSCrfU,434
128
130
  lamindb/setup/core/__init__.py,sha256=SevlVrc2AZWL3uALbE5sopxBnIZPWZ1IB0NBDudiAL8,167
129
131
  lamindb/setup/errors/__init__.py,sha256=bAHTxOUJW1rm4zpF0Pvqkftn8W6iMGnQ-uyNBu13Nfg,171
130
132
  lamindb/setup/types/__init__.py,sha256=ATaosOi6q-cDWB52T69_sRmLMqj8cHfc-vljzZsrJNw,169
131
- lamindb-1.7a1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
132
- lamindb-1.7a1.dist-info/WHEEL,sha256=CpUCUxeHQbRN5UGRQHYRJorO5Af-Qy_fHMctcQ8DSGI,82
133
- lamindb-1.7a1.dist-info/METADATA,sha256=a12fDALiPF1EygwixlW206Yl0zTnPznU9BORJr5NMQs,2669
134
- lamindb-1.7a1.dist-info/RECORD,,
133
+ lamindb-1.7.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
134
+ lamindb-1.7.1.dist-info/WHEEL,sha256=CpUCUxeHQbRN5UGRQHYRJorO5Af-Qy_fHMctcQ8DSGI,82
135
+ lamindb-1.7.1.dist-info/METADATA,sha256=HDXe5RSeh62HIA03TRjUWqnNCRKtFfbegaG1rhy_8bI,2669
136
+ lamindb-1.7.1.dist-info/RECORD,,