From d00bad45a5e75bb76316cbe95dc1011e48a212b6 Mon Sep 17 00:00:00 2001 From: ashkankzme Date: Tue, 6 Aug 2024 11:17:13 -0700 Subject: [PATCH] added more logging per skye's request --- lib/model/classycat_classify.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/model/classycat_classify.py b/lib/model/classycat_classify.py index d623679..1b47579 100644 --- a/lib/model/classycat_classify.py +++ b/lib/model/classycat_classify.py @@ -130,6 +130,11 @@ def classify_and_store_results(self, schema_id, items): # and items with no labels can be retried later by the user, indicated by an empty list for labels permitted_labels = [topic['topic'] for topic in schema['topics']] + ['Other', 'Unsure'] for result in final_results: + + # log the items that had at least one out-of-schema label + if not all([label in permitted_labels for label in result['labels']]): + logger.error(f"Item {result['id']} had out-of-schema labels: {result['labels']}, permitted labels: {permitted_labels}") + result['labels'] = [label for label in result['labels'] if label in permitted_labels] if not all([len(result['labels']) == 0 for result in final_results]):