Skip to content

Commit

Permalink
🩹 Fix an issue in transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
falexwolf committed Sep 30, 2024
1 parent c6d9274 commit a88e217
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
11 changes: 6 additions & 5 deletions lamindb/_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,14 +524,15 @@ def transfer_to_default_db(
if hasattr(record, "created_by_id"):
record.created_by = None
record.created_by_id = ln_setup.settings.user.id
# run & transform
run = transfer_logs["run"]
if hasattr(record, "run_id"):
record.run = None
run = transfer_logs["run"]
record.run_id = run.id
# deal with denormalized transform FK on artifact and collection
if hasattr(record, "transform_id"):
record.transform = None
record.transform_id = run.transform_id
# deal with denormalized transform FK on artifact and collection
if hasattr(record, "transform_id"):
record.transform = None
record.transform_id = run.transform_id
# transfer other foreign key fields
fk_fields = [
i.name
Expand Down
16 changes: 11 additions & 5 deletions lamindb/core/_label_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import numpy as np
from django.db import connections
from lamin_utils import colors, logger
from lnschema_core.models import Feature
from lnschema_core.models import CanValidate, Feature

from lamindb._from_values import _print_values
from lamindb._record import (
Expand Down Expand Up @@ -133,10 +133,16 @@ def validate_labels_registry(
label_uids = np.array(
[getattr(label, field) for label in labels if label is not None]
)
validated = registry.validate(label_uids, field=field, mute=True)
validated_uids = label_uids[validated]
validated_labels = registry.filter(**{f"{field}__in": validated_uids}).list()
new_labels = [labels[int(i)] for i in np.argwhere(~validated).flatten()]
if issubclass(registry, CanValidate):
validated = registry.validate(label_uids, field=field, mute=True)
validated_uids = label_uids[validated]
validated_labels = registry.filter(
**{f"{field}__in": validated_uids}
).list()
new_labels = [labels[int(i)] for i in np.argwhere(~validated).flatten()]
else:
validated_labels = []
new_labels = list(labels)
return validated_labels, new_labels

if isinstance(labels, dict):
Expand Down

0 comments on commit a88e217

Please sign in to comment.