From c51bf666d742f980a308705404e0310d3c42e8c7 Mon Sep 17 00:00:00 2001 From: Gesina Phillips Date: Fri, 12 Jan 2024 11:51:30 -0500 Subject: [PATCH 1/2] update to accommodate multi-assay--component assays passed from IVT in Validator.contains --- .../codex_common_errors_validator.py | 7 ++++++- src/ingest_validation_tests/codex_json_validator.py | 8 ++++++-- src/ingest_validation_tests/publication_validator.py | 9 +++++++-- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/ingest_validation_tests/codex_common_errors_validator.py b/src/ingest_validation_tests/codex_common_errors_validator.py index 01bda98..74cedc3 100644 --- a/src/ingest_validation_tests/codex_common_errors_validator.py +++ b/src/ingest_validation_tests/codex_common_errors_validator.py @@ -45,11 +45,16 @@ class CodexCommonErrorsValidator(Validator): """ description = "Test for common problems found in CODEX" cost = 1.0 + required = "codex" + def collect_errors(self, **kwargs) -> List[str]: """ Return the errors found by this validator """ - if self.assay_type != 'CODEX': + if ( + self.required not in self.contains + and self.assay_type.lower() != self.required + ): return [] # We only test CODEX data rslt = [] try: diff --git a/src/ingest_validation_tests/codex_json_validator.py b/src/ingest_validation_tests/codex_json_validator.py index 17b4ee9..e75b9ba 100644 --- a/src/ingest_validation_tests/codex_json_validator.py +++ b/src/ingest_validation_tests/codex_json_validator.py @@ -10,10 +10,14 @@ class CodexJsonValidator(Validator): description = "Check CODEX JSON against schema" cost = 1.0 + required = "codex" def collect_errors(self, **kwargs) -> List[str]: - if 'codex' not in self.assay_type.lower(): - return [] + if ( + self.required not in self.contains + and self.assay_type.lower() != self.required + ): + return [] # We only test CODEX data schema_path = Path(__file__).parent / 'codex_schema.json' schema = json.loads(schema_path.read_text()) diff --git a/src/ingest_validation_tests/publication_validator.py b/src/ingest_validation_tests/publication_validator.py index 9399f2c..59cdadf 100644 --- a/src/ingest_validation_tests/publication_validator.py +++ b/src/ingest_validation_tests/publication_validator.py @@ -19,11 +19,16 @@ class PublicationValidator(Validator): cost = 1.0 base_url_re = r'(\s*\{\{\s*base_url\s*\}\})/(.*)' url_re = r'[Uu][Rr][Ll]' + required = "publications" + def collect_errors(self, **kwargs) -> List[str]: """ Return the errors found by this validator """ - if self.assay_type != 'Publication': + if ( + self.required not in self.contains + and self.assay_type.lower() != self.required + ): return [] # We only test Publication data rslt = [] try: @@ -86,7 +91,7 @@ def validate_vitessce_config(self, json_path): rslt = [] with open(json_path) as f: dct = json.load(f) - for key, val in self.url_search_iter(dct): + for _, val in self.url_search_iter(dct): try: match = re.match(self.base_url_re, val) if match: # it starts with {{ base_url }} From ee0ebc71bcbd4d9ed1dab3726b12637aefe5cccd Mon Sep 17 00:00:00 2001 From: Gesina Phillips Date: Mon, 26 Feb 2024 16:15:30 -0500 Subject: [PATCH 2/2] fixing silly typo --- src/ingest_validation_tests/publication_validator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ingest_validation_tests/publication_validator.py b/src/ingest_validation_tests/publication_validator.py index a68d549..a3d705a 100644 --- a/src/ingest_validation_tests/publication_validator.py +++ b/src/ingest_validation_tests/publication_validator.py @@ -21,7 +21,7 @@ class PublicationValidator(Validator): cost = 1.0 base_url_re = r"(\s*\{\{\s*base_url\s*\}\})/(.*)" url_re = r"[Uu][Rr][Ll]" - required = "publications" + required = "publication" def collect_errors(self, **kwargs) -> List[str]: """