Skip to content

Commit

Permalink
save labels
Browse files Browse the repository at this point in the history
  • Loading branch information
Koncopd committed Dec 2, 2024
1 parent 5bd647f commit b841470
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions lamindb/_curate.py
Original file line number Diff line number Diff line change
Expand Up @@ -1368,10 +1368,13 @@ def save_artifact(
revises: Artifact | None = None,
run: Run | None = None,
) -> Artifact:
from lamindb.core._data import add_labels

if not self._validated:
self.validate()
if not self._validated:
raise ValidationError("Dataset does not validate. Please curate.")

artifact = Artifact(
self._experiment_uri,
description=description,
Expand Down Expand Up @@ -1407,6 +1410,29 @@ def save_artifact(
)
artifact._feature_sets = feature_sets

feature_ref_is_name = _ref_is_name(self._columns_field)
features = Feature.lookup().dict()
for key, field in self._obs_fields.items():
feature = features.get(key)
registry = field.field.model
organism = check_registry_organism(field.field.model, self._organism).get(
"organism"
)
labels = registry.from_values(
values=self._validated_values[key], field=field, organism=organism
)
if len(labels) == 0:
continue
if hasattr(registry, "_name_field"):
label_ref_is_name = field.field.name == registry._name_field
add_labels(
artifact,
records=labels,
feature=feature,
feature_ref_is_name=feature_ref_is_name,
label_ref_is_name=label_ref_is_name,
)

return artifact.save()


Expand Down

0 comments on commit b841470

Please sign in to comment.