lamindb_setup 1.7.2__py3-none-any.whl → 1.7.3__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_setup/__init__.py CHANGED
@@ -35,7 +35,7 @@ Modules & settings:
35
35
 
36
36
  """
37
37
 
38
- __version__ = "1.7.2" # denote a release candidate for 0.1.0 with 0.1rc1
38
+ __version__ = "1.7.3" # denote a release candidate for 0.1.0 with 0.1rc1
39
39
 
40
40
  import os
41
41
 
@@ -56,8 +56,6 @@ class SetupSettings:
56
56
  _instance_settings_env: str | None = None
57
57
 
58
58
  _auto_connect_path: Path = settings_dir / "auto_connect"
59
- _branch_path: Path = settings_dir / "branch_uid.txt"
60
- _space_path: Path = settings_dir / "space_uid.txt"
61
59
  _private_django_api_path: Path = settings_dir / "private_django_api"
62
60
 
63
61
  _cache_dir: Path | None = None
@@ -95,14 +93,30 @@ class SetupSettings:
95
93
  else:
96
94
  self._auto_connect_path.unlink(missing_ok=True)
97
95
 
96
+ @property
97
+ def _branch_path(self) -> Path:
98
+ return (
99
+ settings_dir
100
+ / f"current-branch--{self.instance.owner}--{self.instance.name}.txt"
101
+ )
102
+
103
+ def _read_branch_idlike_name(self) -> tuple[int | str, str]:
104
+ idlike: str | int = 1
105
+ name: str = "main"
106
+ try:
107
+ branch_path = self._branch_path
108
+ except SystemExit: # in case no instance setup
109
+ return idlike, name
110
+ if branch_path.exists():
111
+ idlike, name = branch_path.read_text().split("\n")
112
+ return idlike, name
113
+
98
114
  @property
99
115
  def branch(self) -> Branch:
100
116
  """Default branch."""
101
117
  from lamindb import Branch
102
118
 
103
- idlike: str | int = 1
104
- if self._branch_path.exists():
105
- idlike = self._branch_path.read_text()
119
+ idlike, _ = self._read_branch_idlike_name()
106
120
  return Branch.get(idlike)
107
121
 
108
122
  @branch.setter
@@ -119,16 +133,34 @@ class SetupSettings:
119
133
  raise DoesNotExist(
120
134
  f"Branch '{value}', please check on the hub UI whether you have the correct `uid` or `name`."
121
135
  )
122
- self._branch_path.write_text(branch_record.uid)
136
+ # we are sure that the current instance is setup because
137
+ # it will error on lamindb import otherwise
138
+ self._branch_path.write_text(f"{branch_record.uid}\n{branch_record.name}")
139
+
140
+ @property
141
+ def _space_path(self) -> Path:
142
+ return (
143
+ settings_dir
144
+ / f"current-space--{self.instance.owner}--{self.instance.name}.txt"
145
+ )
146
+
147
+ def _read_space_idlike_name(self) -> tuple[int | str, str]:
148
+ idlike: str | int = 1
149
+ name: str = "all"
150
+ try:
151
+ space_path = self._space_path
152
+ except SystemExit: # in case no instance setup
153
+ return idlike, name
154
+ if space_path.exists():
155
+ idlike, name = space_path.read_text().split("\n")
156
+ return idlike, name
123
157
 
124
158
  @property
125
159
  def space(self) -> Space:
126
160
  """Default space."""
127
161
  from lamindb import Space
128
162
 
129
- idlike: str | int = 1
130
- if self._space_path.exists():
131
- idlike = self._space_path.read_text()
163
+ idlike, _ = self._read_space_idlike_name()
132
164
  return Space.get(idlike)
133
165
 
134
166
  @space.setter
@@ -145,7 +177,9 @@ class SetupSettings:
145
177
  raise DoesNotExist(
146
178
  f"Space '{value}', please check on the hub UI whether you have the correct `uid` or `name`."
147
179
  )
148
- self._space_path.write_text(space_record.uid)
180
+ # we are sure that the current instance is setup because
181
+ # it will error on lamindb import otherwise
182
+ self._space_path.write_text(f"{space_record.uid}\n{space_record.name}")
149
183
 
150
184
  @property
151
185
  def is_connected(self) -> bool:
@@ -264,8 +298,8 @@ class SetupSettings:
264
298
  repr = ""
265
299
  if self._instance_exists:
266
300
  repr += "Current branch & space:\n"
267
- repr += f" - branch: {self.branch.name}\n"
268
- repr += f" - space: {self.space.name}\n"
301
+ repr += f" - branch: {self._read_branch_idlike_name()[1]}\n"
302
+ repr += f" - space: {self._read_space_idlike_name()[1]}\n"
269
303
  repr += self.instance.__repr__()
270
304
  else:
271
305
  repr += "Current instance: None"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: lamindb_setup
3
- Version: 1.7.2
3
+ Version: 1.7.3
4
4
  Summary: Setup & configure LaminDB.
5
5
  Author-email: Lamin Labs <open-source@lamin.ai>
6
6
  Requires-Python: >=3.10
@@ -1,4 +1,4 @@
1
- lamindb_setup/__init__.py,sha256=rXOlL53oN84rtC715KZqc82f3DmiFQu7G2giORCTMdY,2782
1
+ lamindb_setup/__init__.py,sha256=YCc_Qq5IYq91E9yQdWzQwsOoWSjH5qBpBkZulYdQaJ0,2782
2
2
  lamindb_setup/_cache.py,sha256=5o749NuW6zi6uP4rmBtwxg7ifWpAHXVngzC0tEgXLgo,2776
3
3
  lamindb_setup/_check.py,sha256=28PcG8Kp6OpjSLSi1r2boL2Ryeh6xkaCL87HFbjs6GA,129
4
4
  lamindb_setup/_check_setup.py,sha256=bXuqx2HEc178RM7gbKZQ65PEVJFu6uSOKiHAs_xz6GI,5575
@@ -30,7 +30,7 @@ lamindb_setup/core/_hub_core.py,sha256=x77WpaPMr1uA1kJBSvM5JRNyRG0vYIVlxQbhjAdOh
30
30
  lamindb_setup/core/_hub_crud.py,sha256=Jz0d8wFKM1Pv9B9byyUJPlCIMkIzk56Jd-c3Awpm9Xw,5730
31
31
  lamindb_setup/core/_hub_utils.py,sha256=6dyDGyzYFgVfR_lE3VN3CP1jGp98gxPtr-T91PAP05U,2687
32
32
  lamindb_setup/core/_private_django_api.py,sha256=By63l3vIEtK1pq246FhHq3tslxsaTJGKm5VakYluWp4,2656
33
- lamindb_setup/core/_settings.py,sha256=SIXxs0ZCqjNz53PwPYdLoC5sMQ2pjraEBZ3BpA8jGYU,11726
33
+ lamindb_setup/core/_settings.py,sha256=0la2eYAHcdMYophheGsgQaD2nJGQrPuX4jMV5GKDiC0,12946
34
34
  lamindb_setup/core/_settings_instance.py,sha256=nXSOc6qPwamcoD-4W8sIOFD_L-W8VO8e0tT-U0INuYo,19518
35
35
  lamindb_setup/core/_settings_load.py,sha256=JWd0_hBy04xjKo-tH4y8C9RkaywjrmoT0PsKzVme0n4,5176
36
36
  lamindb_setup/core/_settings_save.py,sha256=XZx-vow7BT6y3JpRBB2UOJp2vwc7jOGea4wSgOPqjPU,3262
@@ -44,7 +44,7 @@ lamindb_setup/core/exceptions.py,sha256=qjMzqy_uzPA7mCOdnoWnS_fdA6OWbdZGftz-YYpl
44
44
  lamindb_setup/core/hashing.py,sha256=Y8Uc5uSGTfU6L2R_gb5w8DdHhGRog7RnkK-e9FEMjPY,3680
45
45
  lamindb_setup/core/types.py,sha256=T7NwspfRHgIIpYsXDcApks8jkOlGeGRW-YbVLB7jNIo,67
46
46
  lamindb_setup/core/upath.py,sha256=tvu178E08VSC7YUNrcDYxri4ODuVtX3BGNhJO8UZf00,34302
47
- lamindb_setup-1.7.2.dist-info/LICENSE,sha256=UOZ1F5fFDe3XXvG4oNnkL1-Ecun7zpHzRxjp-XsMeAo,11324
48
- lamindb_setup-1.7.2.dist-info/WHEEL,sha256=CpUCUxeHQbRN5UGRQHYRJorO5Af-Qy_fHMctcQ8DSGI,82
49
- lamindb_setup-1.7.2.dist-info/METADATA,sha256=RO5_HhbMpABK27CGooW3cLDubeImzHtltprOJB4sLUQ,1797
50
- lamindb_setup-1.7.2.dist-info/RECORD,,
47
+ lamindb_setup-1.7.3.dist-info/LICENSE,sha256=UOZ1F5fFDe3XXvG4oNnkL1-Ecun7zpHzRxjp-XsMeAo,11324
48
+ lamindb_setup-1.7.3.dist-info/WHEEL,sha256=CpUCUxeHQbRN5UGRQHYRJorO5Af-Qy_fHMctcQ8DSGI,82
49
+ lamindb_setup-1.7.3.dist-info/METADATA,sha256=LkK3UmxVpUDNES_P4zFdkeMx02PzrEWjAtqPrpX0-PQ,1797
50
+ lamindb_setup-1.7.3.dist-info/RECORD,,