Skip to content

Commit

Permalink
Add check for empty conflation file.
Browse files Browse the repository at this point in the history
  • Loading branch information
gaurav committed Aug 24, 2024
1 parent 55b9701 commit fbd36a6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion node_normalizer/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit fbd36a6

Please sign in to comment.