From 9acf62de272a9630adc67882b5ae1bbbb53d7aec Mon Sep 17 00:00:00 2001 From: Oscar Beijbom Date: Mon, 17 Jun 2024 03:25:06 -1000 Subject: [PATCH] making list_samples endpoint robust to stale predictions --- pyproject.toml | 2 +- src/nyckel/functions/tags/tabular_tags.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 4bfa2cc..3cfa0b3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ packages = ["src/nyckel"] [project] name = "nyckel" -version = "0.4.11" +version = "0.4.12" authors = [{ name = "Oscar Beijbom", email = "oscar@nyckel.com" }] description = "Python package for the Nyckel API" readme = "README.md" diff --git a/src/nyckel/functions/tags/tabular_tags.py b/src/nyckel/functions/tags/tabular_tags.py index ae4bc6e..72a0ba2 100644 --- a/src/nyckel/functions/tags/tabular_tags.py +++ b/src/nyckel/functions/tags/tabular_tags.py @@ -308,12 +308,16 @@ def _sample_from_dict( annotation = None if "prediction" in sample_dict: + # TODO: Note that we filter out predictsion that are not in the label list. + # This is a temporary fix since these should not be there in the first place. + prediction = [ ClassificationPrediction( confidence=entry["confidence"], label_name=label_name_by_id[strip_nyckel_prefix(entry["labelId"])], ) for entry in sample_dict["prediction"] + if strip_nyckel_prefix(entry["labelId"]) in label_name_by_id ] else: prediction = None