From 440fdf09174a3163fd5f1a2625d6b996e4373fd2 Mon Sep 17 00:00:00 2001 From: Gesina Phillips Date: Tue, 25 Jul 2023 13:11:47 -0400 Subject: [PATCH] attempting to make tests pass --- CHANGELOG.md | 2 +- src/ingest_validation_tools/upload.py | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ed2b72cf..1700c3d19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ - Added examples for fields with pattern constraint - Replaced `preparation_temperature` with `preparation_condition` and updated associated enumerations in the sample-section, sample-block, and sample-suspension schemas - Replaced `storage_temperature` with `storage_method` and updated associated enumerations in the sample-section, sample-block, and sample-suspension schemas -- Updated upload.py to integrate CEDAR validation +- Updated upload.py to integrate CEDAR validation, replaced walrus operators - Updated CEDAR validation routine based on changes to Spreadsheet Validator ## v0.0.15 - 2023-04-04 diff --git a/src/ingest_validation_tools/upload.py b/src/ingest_validation_tools/upload.py index ebf9fecf9..6755de8d4 100644 --- a/src/ingest_validation_tools/upload.py +++ b/src/ingest_validation_tools/upload.py @@ -115,21 +115,26 @@ def get_errors(self, **kwargs) -> dict: errors = {} - if tsv_errors := self._check_tsvs(): + tsv_errors = self._check_tsvs() + if tsv_errors: errors["Metadata TSV Errors"] = tsv_errors - if dir_errors := self.get_directory_errors(): + dir_errors = self.get_directory_errors() + if dir_errors: errors["Directory Errors"] = dir_errors - if validation_errors := self.cedar_validation_routine(): + validation_errors = self.cedar_validation_routine() + if validation_errors: errors["Validation Errors"] = validation_errors # if validation_errors := self.local_validation_routine(): # errors["Validation Errors"] = validation_errors - if reference_errors := self._get_reference_errors(): + reference_errors = self._get_reference_errors() + if reference_errors: errors["Reference Errors"] = reference_errors - if plugin_errors := self._get_plugin_errors(**kwargs): + plugin_errors = self._get_plugin_errors(**kwargs) + if plugin_errors: errors["Plugin Errors"] = plugin_errors return errors @@ -167,7 +172,8 @@ def get_directory_errors(self) -> dict: if not row.get("data_path"): continue path = self.directory_path / row["data_path"] - if ref_errors := self.__get_ref_errors("data", path, schema_name): + ref_errors = self.__get_ref_errors("data", path, schema_name) + if ref_errors: single_path_errors[f"{row_number}, data {path}"] = ref_errors errors[f"{path} (as {schema_name})"] = single_path_errors return errors @@ -208,7 +214,8 @@ def cedar_validation_routine(self) -> dict: def local_validation_routine(self) -> dict: errors = {} - if tsv_errors := self._get_tsv_errors(): + tsv_errors = self._get_tsv_errors() + if tsv_errors: errors["Metadata TSV Errors"] = tsv_errors return errors