lamindb 0.74.0__py3-none-any.whl → 0.74.2__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 (43) hide show
  1. lamindb/__init__.py +9 -9
  2. lamindb/_artifact.py +36 -46
  3. lamindb/_can_validate.py +24 -22
  4. lamindb/_collection.py +5 -6
  5. lamindb/{_annotate.py → _curate.py} +62 -40
  6. lamindb/_feature.py +7 -9
  7. lamindb/_feature_set.py +17 -18
  8. lamindb/_filter.py +5 -5
  9. lamindb/_finish.py +19 -7
  10. lamindb/_from_values.py +15 -15
  11. lamindb/_is_versioned.py +2 -2
  12. lamindb/_parents.py +7 -7
  13. lamindb/_query_manager.py +8 -8
  14. lamindb/_query_set.py +32 -30
  15. lamindb/{_registry.py → _record.py} +91 -50
  16. lamindb/_save.py +6 -6
  17. lamindb/_storage.py +1 -1
  18. lamindb/_view.py +4 -4
  19. lamindb/core/__init__.py +19 -16
  20. lamindb/core/_data.py +11 -11
  21. lamindb/core/_feature_manager.py +49 -32
  22. lamindb/core/_label_manager.py +5 -5
  23. lamindb/core/_mapped_collection.py +4 -1
  24. lamindb/core/_run_context.py +6 -4
  25. lamindb/core/_settings.py +45 -50
  26. lamindb/core/_sync_git.py +22 -12
  27. lamindb/core/_track_environment.py +5 -1
  28. lamindb/core/datasets/_core.py +3 -3
  29. lamindb/core/fields.py +1 -1
  30. lamindb/core/schema.py +6 -6
  31. lamindb/core/storage/_backed_access.py +56 -12
  32. lamindb/core/storage/paths.py +4 -4
  33. lamindb/core/subsettings/__init__.py +12 -0
  34. lamindb/core/subsettings/_creation_settings.py +38 -0
  35. lamindb/core/subsettings/_transform_settings.py +21 -0
  36. lamindb/core/versioning.py +1 -1
  37. lamindb/integrations/_vitessce.py +4 -3
  38. {lamindb-0.74.0.dist-info → lamindb-0.74.2.dist-info}/METADATA +7 -9
  39. lamindb-0.74.2.dist-info/RECORD +57 -0
  40. lamindb/core/_transform_settings.py +0 -9
  41. lamindb-0.74.0.dist-info/RECORD +0 -55
  42. {lamindb-0.74.0.dist-info → lamindb-0.74.2.dist-info}/LICENSE +0 -0
  43. {lamindb-0.74.0.dist-info → lamindb-0.74.2.dist-info}/WHEEL +0 -0
lamindb/_save.py CHANGED
@@ -13,7 +13,7 @@ from django.db import IntegrityError, transaction
13
13
  from django.utils.functional import partition
14
14
  from lamin_utils import logger
15
15
  from lamindb_setup.core.upath import LocalPathClasses
16
- from lnschema_core.models import Artifact, Registry
16
+ from lnschema_core.models import Artifact, Record
17
17
 
18
18
  from lamindb.core._settings import settings
19
19
  from lamindb.core.storage.paths import (
@@ -28,7 +28,7 @@ if TYPE_CHECKING:
28
28
 
29
29
 
30
30
  def save(
31
- records: Iterable[Registry], ignore_conflicts: bool | None = False, **kwargs
31
+ records: Iterable[Record], ignore_conflicts: bool | None = False, **kwargs
32
32
  ) -> None:
33
33
  """Bulk save to registries & storage.
34
34
 
@@ -42,7 +42,7 @@ def save(
42
42
  existing records! Use ``record.save()`` for these use cases.
43
43
 
44
44
  Args:
45
- records: Multiple :class:`~lamindb.core.Registry` objects.
45
+ records: Multiple :class:`~lamindb.core.Record` objects.
46
46
  ignore_conflicts: If ``True``, do not error if some records violate a
47
47
  unique or another constraint. However, it won't inplace update the id
48
48
  fields of records. If you need records with ids, you need to query
@@ -69,7 +69,7 @@ def save(
69
69
  >>> transform.save()
70
70
 
71
71
  """
72
- if isinstance(records, Registry):
72
+ if isinstance(records, Record):
73
73
  raise ValueError("Please use record.save() if saving a single record.")
74
74
 
75
75
  # previously, this was all set based,
@@ -122,7 +122,7 @@ def save(
122
122
  return None
123
123
 
124
124
 
125
- def bulk_create(records: Iterable[Registry], ignore_conflicts: bool | None = False):
125
+ def bulk_create(records: Iterable[Record], ignore_conflicts: bool | None = False):
126
126
  records_by_orm = defaultdict(list)
127
127
  for record in records:
128
128
  records_by_orm[record.__class__].append(record)
@@ -130,7 +130,7 @@ def bulk_create(records: Iterable[Registry], ignore_conflicts: bool | None = Fal
130
130
  orm.objects.bulk_create(records, ignore_conflicts=ignore_conflicts)
131
131
 
132
132
 
133
- def bulk_update(records: Iterable[Registry], ignore_conflicts: bool | None = False):
133
+ def bulk_update(records: Iterable[Record], ignore_conflicts: bool | None = False):
134
134
  records_by_orm = defaultdict(list)
135
135
  for record in records:
136
136
  records_by_orm[record.__class__].append(record)
lamindb/_storage.py CHANGED
@@ -6,7 +6,7 @@ from lnschema_core import Storage
6
6
  @property # type: ignore
7
7
  @doc_args(Storage.path.__doc__)
8
8
  def path(self) -> UPath:
9
- """{}."""
9
+ """{}""" # noqa: D415
10
10
  access_token = self._access_token if hasattr(self, "_access_token") else None
11
11
  return create_path(self.root, access_token=access_token)
12
12
 
lamindb/_view.py CHANGED
@@ -7,7 +7,7 @@ import inspect
7
7
  from lamin_utils import colors, logger
8
8
  from lamindb_setup import settings
9
9
  from lamindb_setup._init_instance import get_schema_module_name
10
- from lnschema_core import Registry
10
+ from lnschema_core import Record
11
11
 
12
12
  is_run_from_ipython = getattr(builtins, "__IPYTHON__", False)
13
13
 
@@ -21,7 +21,7 @@ def view(
21
21
  n: Display the last `n` rows of a registry.
22
22
  schema: Schema module to view. Default's to
23
23
  `None` and displays all schema modules.
24
- registries: List of Registry names. Defaults to
24
+ registries: List of Record names. Defaults to
25
25
  `None` and lists all registries.
26
26
 
27
27
  Examples:
@@ -44,8 +44,8 @@ def view(
44
44
  orm
45
45
  for orm in schema_module.__dict__.values()
46
46
  if inspect.isclass(orm)
47
- and issubclass(orm, Registry)
48
- and orm.__name__ != "Registry"
47
+ and issubclass(orm, Record)
48
+ and orm.__name__ != "Record"
49
49
  }
50
50
  if registries is not None:
51
51
  filtered_registries = {
lamindb/core/__init__.py CHANGED
@@ -5,7 +5,7 @@ Registries:
5
5
  .. autosummary::
6
6
  :toctree: .
7
7
 
8
- Registry
8
+ Record
9
9
  QuerySet
10
10
  QueryManager
11
11
  RecordsList
@@ -19,26 +19,27 @@ Registries:
19
19
  HasParents
20
20
  TracksRun
21
21
  TracksUpdates
22
+ ParamValue
23
+ FeatureValue
22
24
  InspectResult
23
25
  fields
24
26
 
25
- Annotators:
27
+ Curators:
26
28
 
27
29
  .. autosummary::
28
30
  :toctree: .
29
31
 
30
- DataFrameAnnotator
31
- AnnDataAnnotator
32
- MuDataAnnotator
33
- AnnotateLookup
32
+ DataFrameCurator
33
+ AnnDataCurator
34
+ MuDataCurator
35
+ CurateLookup
34
36
 
35
- Classes:
37
+ Other:
36
38
 
37
39
  .. autosummary::
38
40
  :toctree: .
39
41
 
40
42
  Settings
41
- TransformSettings
42
43
  MappedCollection
43
44
  run_context
44
45
 
@@ -51,34 +52,36 @@ Modules:
51
52
  storage
52
53
  types
53
54
  exceptions
55
+ subsettings
54
56
 
55
57
  """
56
58
 
57
59
  from lamin_utils._inspect import InspectResult
58
60
  from lnschema_core.models import (
59
61
  CanValidate,
62
+ FeatureValue,
60
63
  HasFeatures,
61
64
  HasParams,
62
65
  HasParents,
63
66
  IsVersioned,
64
- Registry,
67
+ ParamValue,
68
+ Record,
65
69
  TracksRun,
66
70
  TracksUpdates,
67
71
  )
68
72
 
69
- from lamindb._annotate import (
70
- AnnDataAnnotator,
71
- AnnotateLookup,
72
- DataFrameAnnotator,
73
- MuDataAnnotator,
73
+ from lamindb._curate import (
74
+ AnnDataCurator,
75
+ CurateLookup,
76
+ DataFrameCurator,
77
+ MuDataCurator,
74
78
  )
75
79
  from lamindb._query_manager import QueryManager
76
80
  from lamindb._query_set import QuerySet, RecordsList
77
81
  from lamindb.core._feature_manager import FeatureManager, ParamManager
78
82
  from lamindb.core._label_manager import LabelManager
79
83
 
80
- from . import _data, datasets, exceptions, fields, types
84
+ from . import _data, datasets, exceptions, fields, subsettings, types
81
85
  from ._mapped_collection import MappedCollection
82
86
  from ._run_context import run_context
83
87
  from ._settings import Settings
84
- from ._transform_settings import TransformSettings
lamindb/core/_data.py CHANGED
@@ -11,7 +11,7 @@ from lnschema_core.models import (
11
11
  Feature,
12
12
  FeatureSet,
13
13
  HasFeatures,
14
- Registry,
14
+ Record,
15
15
  Run,
16
16
  ULabel,
17
17
  __repr__,
@@ -20,7 +20,7 @@ from lnschema_core.models import (
20
20
 
21
21
  from lamindb._parents import view_lineage
22
22
  from lamindb._query_set import QuerySet
23
- from lamindb._registry import get_default_str_field
23
+ from lamindb._record import get_default_str_field
24
24
  from lamindb.core._settings import settings
25
25
 
26
26
  from ._feature_manager import (
@@ -46,7 +46,7 @@ WARNING_RUN_TRANSFORM = "no run & transform get linked, consider calling ln.trac
46
46
  def get_run(run: Run | None) -> Run | None:
47
47
  if run is None:
48
48
  run = run_context.run
49
- if run is None and not settings.silence_file_run_transform_warning:
49
+ if run is None and not settings.creation.artifact_silence_missing_run_warning:
50
50
  logger.warning(WARNING_RUN_TRANSFORM)
51
51
  # suppress run by passing False
52
52
  elif not run:
@@ -96,7 +96,7 @@ def save_feature_set_links(self: Artifact | Collection) -> None:
96
96
 
97
97
  @doc_args(HasFeatures.describe.__doc__)
98
98
  def describe(self: HasFeatures, print_types: bool = False):
99
- """{}."""
99
+ """{}""" # noqa: D415
100
100
  # prefetch all many-to-many relationships
101
101
  # doesn't work for describing using artifact
102
102
  # self = (
@@ -166,7 +166,7 @@ def describe(self: HasFeatures, print_types: bool = False):
166
166
  logger.print(msg)
167
167
 
168
168
 
169
- def validate_feature(feature: Feature, records: list[Registry]) -> None:
169
+ def validate_feature(feature: Feature, records: list[Record]) -> None:
170
170
  """Validate feature record, adjust feature.dtype based on labels records."""
171
171
  if not isinstance(feature, Feature):
172
172
  raise TypeError("feature has to be of type Feature")
@@ -183,7 +183,7 @@ def get_labels(
183
183
  mute: bool = False,
184
184
  flat_names: bool = False,
185
185
  ) -> QuerySet | dict[str, QuerySet] | list:
186
- """{}."""
186
+ """{}""" # noqa: D415
187
187
  if not isinstance(feature, Feature):
188
188
  raise TypeError("feature has to be of type Feature")
189
189
  if feature.dtype is None or not feature.dtype.startswith("cat["):
@@ -210,7 +210,7 @@ def get_labels(
210
210
  ).all()
211
211
  if flat_names:
212
212
  # returns a flat list of names
213
- from lamindb._registry import get_default_str_field
213
+ from lamindb._record import get_default_str_field
214
214
 
215
215
  values = []
216
216
  for v in qs_by_registry.values():
@@ -224,18 +224,18 @@ def get_labels(
224
224
 
225
225
  def add_labels(
226
226
  self,
227
- records: Registry | list[Registry] | QuerySet | Iterable,
227
+ records: Record | list[Record] | QuerySet | Iterable,
228
228
  feature: Feature | None = None,
229
229
  *,
230
230
  field: StrField | None = None,
231
231
  ) -> None:
232
- """{}."""
232
+ """{}""" # noqa: D415
233
233
  if self._state.adding:
234
234
  raise ValueError("Please save the artifact/collection before adding a label!")
235
235
 
236
236
  if isinstance(records, (QuerySet, QuerySet.__base__)): # need to have both
237
237
  records = records.list()
238
- if isinstance(records, (str, Registry)):
238
+ if isinstance(records, (str, Record)):
239
239
  records = [records]
240
240
  if not isinstance(records, List): # avoids warning for pd Series
241
241
  records = list(records)
@@ -260,7 +260,7 @@ def add_labels(
260
260
  # ask users to pass records
261
261
  if len(records_validated) == 0:
262
262
  raise ValueError(
263
- "Please pass a record (a `Registry` object), not a string, e.g., via:"
263
+ "Please pass a record (a `Record` object), not a string, e.g., via:"
264
264
  " label"
265
265
  f" = ln.ULabel(name='{records[0]}')" # type: ignore
266
266
  )
@@ -30,14 +30,14 @@ from lnschema_core.models import (
30
30
  ParamManagerArtifact,
31
31
  ParamManagerRun,
32
32
  ParamValue,
33
- Registry,
33
+ Record,
34
34
  Run,
35
35
  ULabel,
36
36
  )
37
37
 
38
38
  from lamindb._feature import FEATURE_TYPES, convert_numpy_dtype_to_lamin_feature_type
39
39
  from lamindb._feature_set import DICT_KEYS_TYPE, FeatureSet
40
- from lamindb._registry import (
40
+ from lamindb._record import (
41
41
  REGISTRY_UNIQUE_FIELD,
42
42
  get_default_str_field,
43
43
  transfer_fk_to_default_db_bulk,
@@ -118,7 +118,9 @@ def get_feature_set_links(host: Artifact | Collection) -> QuerySet:
118
118
 
119
119
  def get_link_attr(link: LinkORM | type[LinkORM], data: HasFeatures) -> str:
120
120
  link_model_name = link.__class__.__name__
121
- if link_model_name == "ModelBase": # we passed the type of the link
121
+ if (
122
+ link_model_name == "ModelBase" or link_model_name == "RecordMeta"
123
+ ): # we passed the type of the link
122
124
  link_model_name = link.__name__
123
125
  link_attr = link_model_name.replace(data.__class__.__name__, "")
124
126
  if link_attr == "ExperimentalFactor":
@@ -162,6 +164,7 @@ def print_features(
162
164
  labels_by_feature[link.feature_id].append(
163
165
  getattr(link, link_attr).name
164
166
  )
167
+ labels_msgs = []
165
168
  for feature_id, labels_list in labels_by_feature.items():
166
169
  feature = Feature.objects.using(self._state.db).get(id=feature_id)
167
170
  print_values = _print_values(labels_list, n=10)
@@ -170,8 +173,9 @@ def print_features(
170
173
  dictionary[feature.name] = (
171
174
  labels_list if len(labels_list) > 1 else labels_list[0]
172
175
  )
173
- labels_msg += f" '{feature.name}'{type_str} = {print_values}\n"
174
- if labels_msg:
176
+ labels_msgs.append(f" '{feature.name}'{type_str} = {print_values}")
177
+ if len(labels_msgs) > 0:
178
+ labels_msg = "\n".join(sorted(labels_msgs)) + "\n"
175
179
  msg += labels_msg
176
180
 
177
181
  # non-categorical feature values
@@ -182,6 +186,7 @@ def print_features(
182
186
  getattr(self, f"{attr_name}_values")
183
187
  .values(f"{attr_name}__name", f"{attr_name}__dtype")
184
188
  .annotate(values=custom_aggregate("value", self._state.db))
189
+ .order_by(f"{attr_name}__name")
185
190
  )
186
191
  if len(feature_values) > 0:
187
192
  for fv in feature_values:
@@ -232,7 +237,7 @@ def parse_feature_sets_from_anndata(
232
237
  var_field: FieldAttr | None = None,
233
238
  obs_field: FieldAttr = Feature.name,
234
239
  mute: bool = False,
235
- organism: str | Registry | None = None,
240
+ organism: str | Record | None = None,
236
241
  ) -> dict:
237
242
  data_parse = adata
238
243
  if not isinstance(adata, AnnData): # is a path
@@ -243,7 +248,7 @@ def parse_feature_sets_from_anndata(
243
248
  using_key = settings._using_key
244
249
  data_parse = backed_access(filepath, using_key)
245
250
  else:
246
- data_parse = ad.read(filepath, backed="r")
251
+ data_parse = ad.read_h5ad(filepath, backed="r")
247
252
  type = "float"
248
253
  else:
249
254
  type = (
@@ -322,7 +327,12 @@ def infer_feature_type_convert_json(
322
327
  return FEATURE_TYPES["str"] + "[ULabel]", value
323
328
  else:
324
329
  return "list[str]", value
325
- elif isinstance(value, Registry):
330
+ elif first_element_type == Record:
331
+ return (
332
+ f"cat[{first_element_type.__get_name_with_schema__()}]",
333
+ value,
334
+ )
335
+ elif isinstance(value, Record):
326
336
  return (f"cat[{value.__class__.__get_name_with_schema__()}]", value)
327
337
  if not mute:
328
338
  logger.warning(f"cannot infer feature type of: {value}, returning '?")
@@ -417,7 +427,7 @@ def _add_values(
417
427
  feature_param_field: FieldAttr,
418
428
  str_as_ulabel: bool = True,
419
429
  ) -> None:
420
- """Annotate artifact with features & values.
430
+ """Curate artifact with features & values.
421
431
 
422
432
  Args:
423
433
  values: A dictionary of keys (features) & values (labels, numbers, booleans).
@@ -430,7 +440,7 @@ def _add_values(
430
440
  if isinstance(keys, DICT_KEYS_TYPE):
431
441
  keys = list(keys) # type: ignore
432
442
  # deal with other cases later
433
- assert all(isinstance(key, str) for key in keys)
443
+ assert all(isinstance(key, str) for key in keys) # noqa: S101
434
444
  registry = feature_param_field.field.model
435
445
  is_param = registry == Param
436
446
  model = Param if is_param else Feature
@@ -483,10 +493,11 @@ def _add_values(
483
493
  f"Value for feature '{key}' with type {feature.dtype} must be a number"
484
494
  )
485
495
  elif feature.dtype.startswith("cat"):
486
- if not (inferred_type.startswith("cat") or isinstance(value, Registry)):
487
- raise TypeError(
488
- f"Value for feature '{key}' with type '{feature.dtype}' must be a string or record."
489
- )
496
+ if inferred_type != "?":
497
+ if not (inferred_type.startswith("cat") or isinstance(value, Record)):
498
+ raise TypeError(
499
+ f"Value for feature '{key}' with type '{feature.dtype}' must be a string or record."
500
+ )
490
501
  elif not inferred_type == feature.dtype:
491
502
  raise ValidationError(
492
503
  f"Expected dtype for '{key}' is '{feature.dtype}', got '{inferred_type}'"
@@ -499,15 +510,21 @@ def _add_values(
499
510
  feature_value = value_model(**filter_kwargs)
500
511
  feature_values.append(feature_value)
501
512
  else:
502
- if isinstance(value, Registry):
503
- if value._state.adding:
504
- raise ValidationError(
505
- "Please save your label record before annotation."
513
+ if isinstance(value, Record) or (
514
+ isinstance(value, Iterable) and isinstance(next(iter(value)), Record)
515
+ ):
516
+ if isinstance(value, Record):
517
+ label_records = [value]
518
+ else:
519
+ label_records = value # type: ignore
520
+ for record in label_records:
521
+ if record._state.adding:
522
+ raise ValidationError(
523
+ f"Please save {record} before annotation."
524
+ )
525
+ features_labels[record.__class__.__get_name_with_schema__()].append(
526
+ (feature, record)
506
527
  )
507
- label_record = value
508
- features_labels[
509
- label_record.__class__.__get_name_with_schema__()
510
- ].append((feature, label_record))
511
528
  else:
512
529
  if isinstance(value, str):
513
530
  values = [value] # type: ignore
@@ -589,7 +606,7 @@ def _add_values(
589
606
  links = [
590
607
  LinkORM(
591
608
  **{
592
- f"{self._host.__get_name_with_schema__().lower()}_id": self._host.id,
609
+ f"{self._host.__class__.__get_name_with_schema__().lower()}_id": self._host.id,
593
610
  valuefield_id: feature_value.id,
594
611
  }
595
612
  )
@@ -606,7 +623,7 @@ def add_values_features(
606
623
  feature_field: FieldAttr = Feature.name,
607
624
  str_as_ulabel: bool = True,
608
625
  ) -> None:
609
- """Annotate artifact with features & values.
626
+ """Curate artifact with features & values.
610
627
 
611
628
  Args:
612
629
  values: A dictionary of keys (features) & values (labels, numbers, booleans).
@@ -621,7 +638,7 @@ def add_values_params(
621
638
  self,
622
639
  values: dict[str, str | int | float | bool],
623
640
  ) -> None:
624
- """Annotate artifact with features & values.
641
+ """Curate artifact with features & values.
625
642
 
626
643
  Args:
627
644
  values: A dictionary of keys (features) & values (labels, numbers, booleans).
@@ -630,7 +647,7 @@ def add_values_params(
630
647
 
631
648
 
632
649
  def add_feature_set(self, feature_set: FeatureSet, slot: str) -> None:
633
- """Annotate artifact with a feature set.
650
+ """Curate artifact with a feature set.
634
651
 
635
652
  Args:
636
653
  feature_set: `FeatureSet` A feature set record.
@@ -666,10 +683,10 @@ def _add_set_from_df(
666
683
  ):
667
684
  """Add feature set corresponding to column names of DataFrame."""
668
685
  if isinstance(self._host, Artifact):
669
- assert self._host.accessor == "DataFrame"
686
+ assert self._host.accessor == "DataFrame" # noqa: S101
670
687
  else:
671
688
  # Collection
672
- assert self._host.artifact.accessor == "DataFrame"
689
+ assert self._host.artifact.accessor == "DataFrame" # noqa: S101
673
690
 
674
691
  # parse and register features
675
692
  registry = field.field.model
@@ -693,11 +710,11 @@ def _add_set_from_anndata(
693
710
  var_field: FieldAttr,
694
711
  obs_field: FieldAttr | None = Feature.name,
695
712
  mute: bool = False,
696
- organism: str | Registry | None = None,
713
+ organism: str | Record | None = None,
697
714
  ):
698
715
  """Add features from AnnData."""
699
716
  if isinstance(self._host, Artifact):
700
- assert self._host.accessor == "AnnData"
717
+ assert self._host.accessor == "AnnData" # noqa: S101
701
718
  else:
702
719
  raise NotImplementedError()
703
720
 
@@ -721,13 +738,13 @@ def _add_set_from_mudata(
721
738
  var_fields: dict[str, FieldAttr],
722
739
  obs_fields: dict[str, FieldAttr] = None,
723
740
  mute: bool = False,
724
- organism: str | Registry | None = None,
741
+ organism: str | Record | None = None,
725
742
  ):
726
743
  """Add features from MuData."""
727
744
  if obs_fields is None:
728
745
  obs_fields = {}
729
746
  if isinstance(self._host, Artifact):
730
- assert self._host.accessor == "MuData"
747
+ assert self._host.accessor == "MuData" # noqa: S101
731
748
  else:
732
749
  raise NotImplementedError()
733
750
 
@@ -8,7 +8,7 @@ from lamin_utils import colors, logger
8
8
  from lnschema_core.models import Feature
9
9
 
10
10
  from lamindb._from_values import _print_values
11
- from lamindb._registry import (
11
+ from lamindb._record import (
12
12
  REGISTRY_UNIQUE_FIELD,
13
13
  get_default_str_field,
14
14
  transfer_fk_to_default_db_bulk,
@@ -20,7 +20,7 @@ from ._settings import settings
20
20
  from .schema import dict_related_model_to_related_name
21
21
 
22
22
  if TYPE_CHECKING:
23
- from lnschema_core.models import Artifact, Collection, HasFeatures, Registry
23
+ from lnschema_core.models import Artifact, Collection, HasFeatures, Record
24
24
 
25
25
  from lamindb._query_set import QuerySet
26
26
 
@@ -66,7 +66,7 @@ def print_labels(self: HasFeatures, field: str = "name", print_types: bool = Fal
66
66
  print_values = _print_values(labels_list, n=10)
67
67
  type_str = f": {related_model}" if print_types else ""
68
68
  labels_msg += f" .{related_name}{type_str} = {print_values}\n"
69
- except Exception:
69
+ except Exception: # noqa: S112
70
70
  continue
71
71
  msg = ""
72
72
  if labels_msg:
@@ -102,7 +102,7 @@ def validate_labels(labels: QuerySet | list | dict, parents: bool = True):
102
102
  records = registry.from_values(label_uids, field=field)
103
103
  if len(records) > 0:
104
104
  save(records, parents=parents)
105
- except Exception:
105
+ except Exception: # noqa S110
106
106
  pass
107
107
  field = "uid"
108
108
  label_uids = np.array(
@@ -146,7 +146,7 @@ class LabelManager:
146
146
 
147
147
  def add(
148
148
  self,
149
- records: Registry | list[Registry] | QuerySet,
149
+ records: Record | list[Record] | QuerySet,
150
150
  feature: Feature | None = None,
151
151
  ) -> None:
152
152
  """Add one or several labels and associate them with a feature.
@@ -107,7 +107,10 @@ class MappedCollection:
107
107
  parallel: bool = False,
108
108
  dtype: str | None = None,
109
109
  ):
110
- assert join in {None, "inner", "outer"}
110
+ if join not in {None, "inner", "outer"}: # pragma: nocover
111
+ raise ValueError(
112
+ f"join must be one of None, 'inner, or 'outer' but was {type(join)}"
113
+ )
111
114
 
112
115
  if layers_keys is None:
113
116
  self.layers_keys = ["X"]
@@ -14,8 +14,6 @@ from lnschema_core.models import Param, ParamValue, RunParamValue
14
14
  from lnschema_core.types import TransformType
15
15
  from lnschema_core.users import current_user_id
16
16
 
17
- from lamindb.core._transform_settings import transform as transform_settings
18
-
19
17
  from ._settings import settings
20
18
  from ._sync_git import get_transform_reference_from_git_repo
21
19
  from .exceptions import (
@@ -24,6 +22,7 @@ from .exceptions import (
24
22
  NoTitleError,
25
23
  UpdateTransformSettings,
26
24
  )
25
+ from .subsettings._transform_settings import transform_settings
27
26
  from .versioning import bump_version as bump_version_function
28
27
 
29
28
  if TYPE_CHECKING:
@@ -44,7 +43,7 @@ def get_uid_ext(version: str) -> str:
44
43
  # merely zero-padding the nbproject version such that the base62 encoding is
45
44
  # at least 4 characters long doesn't yields sufficiently diverse hashes and
46
45
  # leads to collisions; it'd be nice because the uid_ext would be ordered
47
- return encodebytes(hashlib.md5(version.encode()).digest())[:4]
46
+ return encodebytes(hashlib.md5(version.encode()).digest())[:4] # noqa: S324
48
47
 
49
48
 
50
49
  def update_stem_uid_or_version(
@@ -114,7 +113,7 @@ def get_notebook_name_colab() -> str:
114
113
 
115
114
  ip = gethostbyname(gethostname()) # 172.28.0.12
116
115
  try:
117
- name = get(f"http://{ip}:9000/api/sessions").json()[0]["name"]
116
+ name = get(f"http://{ip}:9000/api/sessions").json()[0]["name"] # noqa: S113
118
117
  except Exception:
119
118
  logger.warning(
120
119
  "could not get notebook name from Google Colab, using: notebook.ipynb"
@@ -288,6 +287,9 @@ class run_context:
288
287
  path=path
289
288
  )
290
289
  transform_type = TransformType.script
290
+ # overwrite whatever is auto-detected in the notebook or script
291
+ if transform_settings.name is not None:
292
+ name = transform_settings.name
291
293
  cls._create_or_load_transform(
292
294
  stem_uid=stem_uid,
293
295
  version=version,