From cade63bf471f8cc4629a4426fc7c8ff5168d1af4 Mon Sep 17 00:00:00 2001 From: Evan Morris Date: Thu, 7 Nov 2024 13:29:36 -0500 Subject: [PATCH] making error catching more broad for all bagel methods --- parsers/LitCoin/src/bagel/bagel.py | 3 +-- parsers/LitCoin/src/loadLitCoin.py | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/parsers/LitCoin/src/bagel/bagel.py b/parsers/LitCoin/src/bagel/bagel.py index a417157..2496f35 100644 --- a/parsers/LitCoin/src/bagel/bagel.py +++ b/parsers/LitCoin/src/bagel/bagel.py @@ -41,9 +41,8 @@ def get_orion_bagel_results(text, term, abstract_id): update_by_id(terms, nr_results, "NameRes") update_by_id(terms, sb_results, "SAPBert") augment_results(terms, nameres, taxon_id_to_name) + # make the call to the LLM asking it to classify the synonyms gpt_class_desc_response = ask_classes_and_descriptions(text, term, terms, abstract_id, session) - # gpt_label_response = ask_labels(abstract, term, terms) - # gpt_class_response = ask_classes(abstract, term, terms) return gpt_class_desc_response diff --git a/parsers/LitCoin/src/loadLitCoin.py b/parsers/LitCoin/src/loadLitCoin.py index 1900be4..93c58a1 100644 --- a/parsers/LitCoin/src/loadLitCoin.py +++ b/parsers/LitCoin/src/loadLitCoin.py @@ -300,10 +300,10 @@ def bagelize_entity(self, entity_name, abstract_id, abstract_text): entity=entity_name, abstract_id=abstract_id) self.bagel_results_lookup[abstract_id]["terms"][entity_name] = bagel_results - except requests.exceptions.HTTPError as e: + except Exception as e: error_message = f'Failed Bagelization: {type(e)}:{e}' self.logger.error(error_message) - if e.response.status_code == 429: + if isinstance(e, requests.exceptions.HTTPError) and e.response.status_code == 429: raise e self.parsing_metadata['bagelization_errors'] += 1 bagel_results = {'error': error_message}