From fbd36a65c3101abacdbc46919432be285f3db736 Mon Sep 17 00:00:00 2001 From: Gaurav Vaidya Date: Fri, 23 Aug 2024 21:31:25 -0400 Subject: [PATCH] Add check for empty conflation file. --- node_normalizer/loader.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/node_normalizer/loader.py b/node_normalizer/loader.py index efae44f..3f518b2 100644 --- a/node_normalizer/loader.py +++ b/node_normalizer/loader.py @@ -418,6 +418,10 @@ async def load_conflation(self, conflation: dict, block_size: int) -> bool: await RedisConnection.execute_pipeline(conflation_pipeline) logger.info(f"{line_counter} {conflation_file} total lines processed") + # Fail if the file was empty. + if line_counter == 0: + raise RuntimeError(f"Conflation file {conflation_file} is empty.") + print(f"Done loading {conflation_file}...") except Exception as e: logger.error(f"Exception thrown in load_conflation({conflation_file}), line {line_counter}: {e}") @@ -497,7 +501,7 @@ async def load_compendium(self, compendium_filename: str, block_size: int) -> bo id2type_pipeline.set(identifier, instance["type"]) # if there is information content add it to the cache - if "ic" in instance: + if "ic" in instance and instance["ic"] is not None: info_content_pipeline.set(identifier, instance["ic"]) if self._test_mode != 1 and line_counter % block_size == 0: