diff --git a/docs/validation_codes_dictionary.md b/docs/validation_codes_dictionary.md index 5d9486a..5df15b7 100644 --- a/docs/validation_codes_dictionary.md +++ b/docs/validation_codes_dictionary.md @@ -510,11 +510,17 @@ **Description:** Value of a 'qualifier_constraints.qualifier_set' property in a Query Graph must not be non-empty array! -### error.query_graph.edge.qualifier_constraints.qualifier_set.qualifier.invalid +### error.query_graph.edge.qualifier_constraints.qualifier_set.qualifier.type_id.unknown -**Message:** Edge '{identifier}' qualifier entry is invalid! +**Message:** Edge '{identifier}' qualifier type_id '{qualifier_type_id}' is unknown! -**Description:** A 'qualifier' entry must be a valid JSON object with valid 'qualifier_type_id' and corresponding 'qualifier_value'! +**Description:** A qualifier qualifier_type_id must be defined in the specified version of Biolink! + +### error.query_graph.edge.qualifier_constraints.qualifier_set.qualifier.value.unresolved + +**Message:** Edge '{identifier}' qualifier_value '{qualifier_value}' for '{qualifier_type_id}' cannot be resolved! + +**Description:** A 'qualifier_value' for the specified 'qualifier_type_id' of a qualifier likely could not be resolved without knowledge of the edge category! ### error.knowledge_graph.nodes.empty @@ -750,9 +756,15 @@ **Description:** Value of a 'qualifiers' property in a Knowledge Graph must not be non-empty array! -### error.knowledge_graph.edge.qualifiers.qualifier.invalid +### error.knowledge_graph.edge.qualifiers.qualifier.type_id.unknown + +**Message:** Edge '{identifier}' qualifier type_id '{qualifier_type_id}' is unknown! + +**Description:** A qualifier qualifier_type_id must be defined in the specified version of Biolink! + +### error.knowledge_graph.edge.qualifiers.qualifier.value.unresolved -**Message:** Edge '{identifier}' qualifier entry is invalid! +**Message:** Edge '{identifier}' qualifier_value '{qualifier_value}' for '{qualifier_type_id}' cannot be resolved! -**Description:** A 'qualifier' entry must be a valid JSON object with valid 'qualifier_type_id' and corresponding 'qualifier_value'! +**Description:** A 'qualifier_value' for the specified 'qualifier_type_id' of a qualifier likely could not be resolved without knowledge of the edge category! diff --git a/reasoner_validator/biolink/__init__.py b/reasoner_validator/biolink/__init__.py index dba875f..d205468 100644 --- a/reasoner_validator/biolink/__init__.py +++ b/reasoner_validator/biolink/__init__.py @@ -466,13 +466,19 @@ def validate_qualifier_entry(self, context: str, edge_id: str, qualifiers: List[ qualifier_type_id: str = qualifier['qualifier_type_id'] qualifier_value: str = qualifier['qualifier_value'] try: - if not self.bmt.validate_qualifier( + if not self.bmt.is_qualifier(name=qualifier_type_id): + self.report( + code=f"error.{context}.qualifier.type_id.unknown", + identifier=edge_id, + qualifier_type_id=qualifier_type_id + ) + elif not self.bmt.validate_qualifier( # TODO: temporary workaround, parse 'qualifier_type_id' to core name qualifier_type_id=parse_name(qualifier_type_id), qualifier_value=qualifier_value ): self.report( - code=f"error.{context}.qualifier.invalid", + code=f"error.{context}.qualifier.value.unresolved", identifier=edge_id, qualifier_type_id=qualifier_type_id, qualifier_value=qualifier_value diff --git a/reasoner_validator/codes.yaml b/reasoner_validator/codes.yaml index 4832458..56063cb 100644 --- a/reasoner_validator/codes.yaml +++ b/reasoner_validator/codes.yaml @@ -334,9 +334,14 @@ error: $message: "Edge '{identifier}' qualifier_set property value is empty!" $description: "Value of a 'qualifier_constraints.qualifier_set' property in a Query Graph must not be non-empty array!" qualifier: - invalid: - $message: "Edge '{identifier}' qualifier entry is invalid!" - $description: "A 'qualifier' entry must be a valid JSON object with valid 'qualifier_type_id' and corresponding 'qualifier_value'!" + type_id: + unknown: + $message: "Edge '{identifier}' qualifier type_id '{qualifier_type_id}' is unknown!" + $description: "A qualifier qualifier_type_id must be defined in the specified version of Biolink!" + value: + unresolved: + $message: "Edge '{identifier}' qualifier_value '{qualifier_value}' for '{qualifier_type_id}' cannot be resolved!" + $description: "A 'qualifier_value' for the specified 'qualifier_type_id' of a qualifier likely could not be resolved without knowledge of the edge category!" knowledge_graph: nodes: empty: @@ -474,6 +479,11 @@ error: $message: "Edge '{identifier}' qualifiers property value is empty!" $description: "Value of a 'qualifiers' property in a Knowledge Graph must not be non-empty array!" qualifier: - invalid: - $message: "Edge '{identifier}' qualifier entry is invalid!" - $description: "A 'qualifier' entry must be a valid JSON object with valid 'qualifier_type_id' and corresponding 'qualifier_value'!" + type_id: + unknown: + $message: "Edge '{identifier}' qualifier type_id '{qualifier_type_id}' is unknown!" + $description: "A qualifier qualifier_type_id must be defined in the specified version of Biolink!" + value: + unresolved: + $message: "Edge '{identifier}' qualifier_value '{qualifier_value}' for '{qualifier_type_id}' cannot be resolved!" + $description: "A 'qualifier_value' for the specified 'qualifier_type_id' of a qualifier likely could not be resolved without knowledge of the edge category!" diff --git a/tests/test_biolink_compliance_validation.py b/tests/test_biolink_compliance_validation.py index 0da2c8e..0e9d903 100644 --- a/tests/test_biolink_compliance_validation.py +++ b/tests/test_biolink_compliance_validation.py @@ -1202,7 +1202,7 @@ def qualifier_validator(tested_method, edge_model: str, query: Tuple[Dict, str]) } ] }, - "error.query_graph.edge.qualifier_constraints.qualifier_set.qualifier.invalid" + "error.query_graph.edge.qualifier_constraints.qualifier_set.qualifier.type_id.unknown" ), ( # Query 13 - 'qualifier_type_id' property value is unknown { @@ -1217,7 +1217,7 @@ def qualifier_validator(tested_method, edge_model: str, query: Tuple[Dict, str]) } ] }, - "error.query_graph.edge.qualifier_constraints.qualifier_set.qualifier.invalid" + "error.query_graph.edge.qualifier_constraints.qualifier_set.qualifier.type_id.unknown" ), ( # Query 14 - 'qualifier_type_id' property value is valid but abstract { @@ -1233,7 +1233,7 @@ def qualifier_validator(tested_method, edge_model: str, query: Tuple[Dict, str]) ] }, # "info.query_graph.edge.qualifier.abstract" - "error.query_graph.edge.qualifier_constraints.qualifier_set.qualifier.invalid" + "error.query_graph.edge.qualifier_constraints.qualifier_set.qualifier.value.unresolved" ), ( # Query 15 - 'qualifier_type_id' property value is not a Biolink qualifier term { @@ -1248,7 +1248,7 @@ def qualifier_validator(tested_method, edge_model: str, query: Tuple[Dict, str]) } ] }, - "error.query_graph.edge.qualifier_constraints.qualifier_set.qualifier.invalid" + "error.query_graph.edge.qualifier_constraints.qualifier_set.qualifier.type_id.unknown" ), ( # Query 16 - 'qualifier' entry is missing its 'qualifier_value' property - invalidated by TRAPI schema { @@ -1380,7 +1380,7 @@ def test_validate_qualifier_constraints(query: Tuple[Dict, str]): } ] }, - "error.knowledge_graph.edge.qualifiers.qualifier.invalid" + "error.knowledge_graph.edge.qualifiers.qualifier.type_id.unknown" ), ( # Query 8 - 'qualifier_type_id' property value is unknown { @@ -1391,7 +1391,7 @@ def test_validate_qualifier_constraints(query: Tuple[Dict, str]): } ] }, - "error.knowledge_graph.edge.qualifiers.qualifier.invalid" + "error.knowledge_graph.edge.qualifiers.qualifier.type_id.unknown" ), ( # Query 9 - 'qualifier_type_id' property value is valid but abstract { @@ -1403,7 +1403,7 @@ def test_validate_qualifier_constraints(query: Tuple[Dict, str]): ] }, # "info.query_graph.edge.qualifier.abstract" - "error.knowledge_graph.edge.qualifiers.qualifier.invalid" + "error.knowledge_graph.edge.qualifiers.qualifier.value.unresolved" ), ( # Query 10 - 'qualifier_type_id' property value is not a Biolink qualifier term { @@ -1414,7 +1414,7 @@ def test_validate_qualifier_constraints(query: Tuple[Dict, str]): } ] }, - "error.knowledge_graph.edge.qualifiers.qualifier.invalid" + "error.knowledge_graph.edge.qualifiers.qualifier.type_id.unknown" ), ( # Query 11 - 'qualifier' entry is missing its 'qualifier_value' property - invalidated by TRAPI schema {