Skip to content

Commit

Permalink
Merge pull request #52 from hubmapconsortium/sunset666/bugfix_excepti…
Browse files Browse the repository at this point in the history
…on_handling

Bugfix exception catching and tasks
  • Loading branch information
sunset666 authored Apr 15, 2024
2 parents 93a301c + 30e2508 commit 0f1b3d1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/ingest_validation_tests/fastq_validator_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ def validate_fastq_file(self, fastq_file: Path) -> None:
except IOError:
self.errors.append(self._format_error(f"Unable to open FASTQ data file {fastq_file}."))
return
except EOFError:
self.errors.append(self._format_error(f"EOF in FASTQ data file {fastq_file}."))
except Exception as e:
self.errors.append(
self._format_error(f"Unexpected error: {e} on data file {fastq_file}.")
)
self._file_record_counts[str(fastq_file)] = records_read

def validate_fastq_files_in_path(self, paths: List[Path], threads: int) -> None:
Expand All @@ -192,6 +198,9 @@ def validate_fastq_files_in_path(self, paths: List[Path], threads: int) -> None:
data_output = pool.imap_unordered(engine, file_list)
except Exception as e:
_log(f"Error {e}")
pool.close()
pool.join()
data_found_one.append(f"Error {e}")
else:
pool.close()
pool.join()
Expand All @@ -215,7 +224,8 @@ def _find_duplicates(self, dirs_and_files):
if len(filepaths) > 1:
self.errors.append(
_log(
f"{filename} has been found multiple times during this validation. Locations of duplicates: {filepaths}." # noqa: E501
f"{filename} has been found multiple times during this validation. "
f"Locations of duplicates: {filepaths}." # noqa: E501
)
)

Expand Down
3 changes: 3 additions & 0 deletions src/ingest_validation_tests/gz_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ def collect_errors(self, **kwargs) -> List[str]:
data_output = pool.imap_unordered(engine, file_list)
except Exception as e:
_log(f"Error {e}")
pool.close()
pool.join()
data_output2.extend(f"Error: {e}")
else:
pool.close()
pool.join()
Expand Down

0 comments on commit 0f1b3d1

Please sign in to comment.