Skip to content

Commit

Permalink
fix: copying label copy all existing predictions
Browse files Browse the repository at this point in the history
  • Loading branch information
baptiste-olivier committed Dec 13, 2024
1 parent dbcfde0 commit 9269109
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/kili/services/copy_project/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,22 +286,34 @@ def _copy_labels(self, from_project_id: str, new_project_id: str) -> None:
],
disable_tqdm=True,
)
labels = [label for label in labels if label["isLatestLabelForUser"]]
labels = [
label for label in labels if (label["isLatestLabelForUser"] or label.get("modelName"))
]

# `append_labels` does not take arrays for `model_name` and `label_type` arguments
# we need to sort and group the labels by `model_name` and `label_type`
# and upload the grouped labels by batch to `append_labels`
labels = sorted(
labels,
key=lambda label: (label["labelType"], label["modelName"] is None, label["modelName"]),
key=lambda label: (
label["labelType"],
label["modelName"] is None,
label["isLatestLabelForUser"],
label["modelName"],
),
)
labels_iterator = itertools.groupby(
labels,
key=lambda label: (label["labelType"], label["modelName"] is None, label["modelName"]),
key=lambda label: (
label["labelType"],
label["modelName"] is None,
label["isLatestLabelForUser"],
label["modelName"],
),
)

for key, group in labels_iterator:
label_type, _, model_name = key
label_type, _, _, model_name = key
group = list(group)

# map external id of source project asset to
Expand Down

0 comments on commit 9269109

Please sign in to comment.