From 4079dbf2cb03654ac60c28c6b5c3f1a7346eb3cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cslesaad=E2=80=9D?= Date: Wed, 2 Mar 2022 10:58:09 -0600 Subject: [PATCH 1/3] Fix silly bugs --- pyQuARC/code/custom_validator.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pyQuARC/code/custom_validator.py b/pyQuARC/code/custom_validator.py index 04aea06a..6469ef39 100644 --- a/pyQuARC/code/custom_validator.py +++ b/pyQuARC/code/custom_validator.py @@ -161,7 +161,7 @@ def collection_progress_consistency_check(collection_state, ends_at_present_flag collection_state = collection_state.upper() ending_date_time_exists = bool(ending_date_time) ends_at_present_flag_exists = bool(ends_at_present_flag) - ends_at_present_flag = ends_at_present_flag_exists.lower() if ends_at_present_flag_exists else None + ends_at_present_flag = str(ends_at_present_flag).lower() if ends_at_present_flag_exists else None if collection_state in ["ACTIVE", "IN WORK"]: validity = (not ending_date_time_exists) and (ends_at_present_flag == "true") @@ -197,6 +197,8 @@ def characteristic_name_uniqueness_check(characteristics): def get_data_url_check(metadata_json): REQUIRED_TYPE = 'GET DATA' related_urls = metadata_json.get('Related_URL', []) + if not isinstance(related_urls, list): + related_urls = [related_urls] validity = False value = None for url in related_urls: From f5a7c8ba8d5f3c28c9b1366daabc7b1c5ec5b302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cslesaad=E2=80=9D?= Date: Wed, 2 Mar 2022 10:58:36 -0600 Subject: [PATCH 2/3] Add an exception catcher for failed rule checking --- pyQuARC/code/checker.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/pyQuARC/code/checker.py b/pyQuARC/code/checker.py index 21437410..67d496cf 100644 --- a/pyQuARC/code/checker.py +++ b/pyQuARC/code/checker.py @@ -199,14 +199,18 @@ def perform_custom_checks(self, metadata_content): ordered_rule = self.scheduler.order_rules() result_dict = {} for rule_id in ordered_rule: - rule_mapping = self.rules_override.get( - rule_id - ) or self.rule_mapping.get(rule_id) - check_id = rule_mapping.get("check_id", rule_id) - check = self.checks_override.get(check_id) or self.checks.get(check_id) - func = Checker.map_to_function(check["data_type"], check["check_function"]) - if func: - self._run_func(func, check, rule_id, metadata_content, result_dict) + try: + rule_mapping = self.rules_override.get( + rule_id + ) or self.rule_mapping.get(rule_id) + check_id = rule_mapping.get("check_id", rule_id) + check = self.checks_override.get(check_id) or self.checks.get(check_id) + func = Checker.map_to_function(check["data_type"], check["check_function"]) + if func: + self._run_func(func, check, rule_id, metadata_content, result_dict) + except Exception as e: + print(f"Running check for the rule: '{rule_id}' failed.\nPlease report the issue to https://github.com/NASA-IMPACT/pyquarc along with the metadata file and the following error message:") + print(f"ERROR: {e}") return result_dict def run(self, metadata_content): From 1e4c926d5e126315254989e95fd2222d4b95a9d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cslesaad=E2=80=9D?= Date: Wed, 2 Mar 2022 11:01:08 -0600 Subject: [PATCH 3/3] Update version --- CHANGELOG.md | 5 +++++ pyQuARC/version.txt | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f3ac3068..7e5a11b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # CHANGELOG +## v1.1.4 + +- Added error handling for errored checks +- Fixed minor bugs + ## v1.1.3 - Fixed null pointer exception in the check `collection_progress_consistency_check` diff --git a/pyQuARC/version.txt b/pyQuARC/version.txt index 781dcb07..65087b4f 100644 --- a/pyQuARC/version.txt +++ b/pyQuARC/version.txt @@ -1 +1 @@ -1.1.3 +1.1.4