You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"""The space in which entities are created during the run."""
251
+
"""The space in which artifacts, collections, transforms, and runs are saved during the run."""
251
252
returnself._space
252
253
254
+
@property
255
+
defbranch(self) ->Branch|None:
256
+
"""The branch on which entities are created during the run."""
257
+
returnself._branch
258
+
253
259
@property
254
260
defrun(self) ->Run|None:
255
261
"""Managed run of context."""
@@ -261,6 +267,7 @@ def _track(
261
267
*,
262
268
project: str|Project|None=None,
263
269
space: str|Space|None=None,
270
+
branch: str|Branch|None=None,
264
271
params: dict|None=None,
265
272
new_run: bool|None=None,
266
273
path: str|None=None,
@@ -273,11 +280,11 @@ def _track(
273
280
274
281
Args:
275
282
transform: A transform (stem) `uid` (or record). If `None`, auto-creates a `transform` with its `uid`.
276
-
project: A project, its `name` or `uid` for labeling entities created during the run.
277
-
space: A restricted space, its `name` or `uid` for creating sensitive entities are created during the run.
278
-
The default is the common `"All"` space that every LaminDB instance has.
279
-
The `space` argument doesn't affect `Storage`, `ULabel`, `Feature`, `Schema`, `Param` and bionty entities as these provide structure that should typically be commonly accessible.
283
+
project: A project (or its `name` or `uid`) for labeling entities.
284
+
space: A restricted space (or its `name` or `uid`) in which to store artifacts, collections, transforms, and runs.
285
+
Default: the `"All"` space.
280
286
If you want to manually move entities to a different space, set the `.space` field (:doc:`docs:access`).
287
+
branch: A branch (or its `name` or `uid`) on which to store records.
281
288
params: A dictionary of parameters to track for the run.
282
289
new_run: If `False`, loads the latest run of transform
283
290
(default notebook), if `True`, creates new run (default non-notebook).
@@ -299,7 +306,7 @@ def _track(
299
306
300
307
More examples: :doc:`/track`
301
308
"""
302
-
fromlamindb.modelsimportProject, Space
309
+
fromlamindb.modelsimportBranch, Project, Space
303
310
304
311
instance_settings=ln_setup.settings.instance
305
312
# similar logic here: https://github.com/laminlabs/lamindb/pull/2527
@@ -337,6 +344,21 @@ def _track(
337
344
f"Space '{space}', please check on the hub UI whether you have the correct `uid` or `name`."
338
345
)
339
346
self._space=space_record
347
+
ifbranchisnotNone:
348
+
ifisinstance(branch, Branch):
349
+
assertbranch._state.addingisFalse, ( # noqa: S101
350
+
"Branch must be saved before passing it to track()"
351
+
)
352
+
branch_record=branch
353
+
else:
354
+
branch_record=Branch.filter(
355
+
Q(name=branch) |Q(uid=branch)
356
+
).one_or_none()
357
+
ifbranch_recordisNone:
358
+
raiseInvalidArgument(
359
+
f"Space '{branch}', please check on the hub UI whether you have the correct `uid` or `name`."
0 commit comments