Skip to content

Commit

Permalink
Split the qualifier validation reporting into distinct codes for the …
Browse files Browse the repository at this point in the history
…qualifier_type_id ("qualifier.type_id.unknown") versus qualifier_value ("qualifier.value.unresolved")
  • Loading branch information
RichardBruskiewich committed Mar 16, 2023
1 parent d824426 commit 8dec02c
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 22 deletions.
24 changes: 18 additions & 6 deletions docs/validation_codes_dictionary.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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!

10 changes: 8 additions & 2 deletions reasoner_validator/biolink/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 16 additions & 6 deletions reasoner_validator/codes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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!"
16 changes: 8 additions & 8 deletions tests/test_biolink_compliance_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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
{
Expand All @@ -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
{
Expand All @@ -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
{
Expand Down Expand Up @@ -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
{
Expand All @@ -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
{
Expand All @@ -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
{
Expand All @@ -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
{
Expand Down

0 comments on commit 8dec02c

Please sign in to comment.