Skip to content

Commit

Permalink
Renamed a few more validation codes then fixed code and unit tests ac…
Browse files Browse the repository at this point in the history
…cordingly
  • Loading branch information
RichardBruskiewich committed May 10, 2024
1 parent 44d705a commit 74e4efb
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
4 changes: 2 additions & 2 deletions docs/validation_codes_dictionary.md
Original file line number Diff line number Diff line change
Expand Up @@ -896,13 +896,13 @@

**Description:** The TRAPI Response should specify its Biolink Model version compliance.

### warning.trapi.response.knowledge_graph.empty
### warning.trapi.response.message.knowledge_graph.empty

**Message:** Response returned an empty Message Knowledge Graph?

**Description:** An empty Knowledge Graph is allowed but merits a boundary response warning?

### warning.trapi.response.results.empty
### warning.trapi.response.message.results.empty

**Message:** Response returned empty Message.results?

Expand Down
17 changes: 9 additions & 8 deletions reasoner_validator/codes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -689,14 +689,15 @@ warning:
missing:
$message: "TRAPI Response is missing its Biolink Model version"
$description: "The TRAPI Response should specify its Biolink Model version compliance."
knowledge_graph:
empty:
$message: "Response returned an empty Message Knowledge Graph?"
$description: "An empty Knowledge Graph is allowed but merits a boundary response warning?"
results:
empty:
$message: "Response returned empty Message.results?"
$description: "Empty Results is allowed but merits a boundary response warning?"
message:
knowledge_graph:
empty:
$message: "Response returned an empty Message Knowledge Graph?"
$description: "An empty Knowledge Graph is allowed but merits a boundary response warning?"
results:
empty:
$message: "Response returned empty Message.results?"
$description: "Empty Results is allowed but merits a boundary response warning?"
workflow:
runner_parameters:
missing:
Expand Down
4 changes: 2 additions & 2 deletions reasoner_validator/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def has_valid_knowledge_graph(
# An empty knowledge graph (warning) does not generally invalidate
# the whole Message, but no more validation tests are needed
if not self.suppress_empty_data_warnings:
self.report(code="warning.trapi.response.knowledge_graph.empty")
self.report(code="warning.trapi.response.message.knowledge_graph.empty")
else:
mapping_validator: MappingValidator = check_node_edge_mappings(knowledge_graph)
if mapping_validator.has_messages():
Expand Down Expand Up @@ -360,7 +360,7 @@ def has_valid_results(self, message: Dict, sample_size: int = 0) -> bool:

if not (results and len(results) > 0):
if not self.suppress_empty_data_warnings:
self.report(code="warning.trapi.response.results.empty")
self.report(code="warning.trapi.response.message.results.empty")
# An empty result (warning) does not generally invalidate
# the whole Message, but no more validation tests are needed

Expand Down
10 changes: 5 additions & 5 deletions tests/test_response_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ def test_sample_graph(edges_limit: int, number_of_nodes_returned: int, number_of


@pytest.mark.parametrize(
"response,trapi_version,biolink_version,target_provenance,strict_validation,message",
"response,trapi_version,biolink_version,target_provenance,strict_validation,code",
[
( # Query 0 - Completely empty Response.Message
{
Expand Down Expand Up @@ -526,7 +526,7 @@ def test_sample_graph(edges_limit: int, number_of_nodes_returned: int, number_of
None,
False,
# "Validate TRAPI Response: WARNING - Response returned an empty Message Knowledge Graph?"
"warning.trapi.response.knowledge_graph.empty"
"warning.trapi.response.message.knowledge_graph.empty"
),
(
# Query 5 - Partly empty Response.Message with a modest but workable
Expand Down Expand Up @@ -560,7 +560,7 @@ def test_sample_graph(edges_limit: int, number_of_nodes_returned: int, number_of
None,
False,
# "Validate TRAPI Response: WARNING -Response returned empty Message.results?"
"warning.trapi.response.results.empty"
"warning.trapi.response.message.results.empty"
),
(
# Query 7 - Partly empty Response.Message with a modest but workable
Expand Down Expand Up @@ -999,7 +999,7 @@ def test_check_biolink_model_compliance_of_trapi_response(
biolink_version: str,
target_provenance: Dict,
strict_validation: bool,
message: str
code
):
validator: TRAPIResponseValidator = TRAPIResponseValidator(
trapi_version=trapi_version,
Expand All @@ -1008,7 +1008,7 @@ def test_check_biolink_model_compliance_of_trapi_response(
target_provenance=target_provenance
)
validator.check_compliance_of_trapi_response(response=response)
check_messages(validator, message, no_errors=True)
check_messages(validator, code, no_errors=True)


@pytest.mark.parametrize(
Expand Down

0 comments on commit 74e4efb

Please sign in to comment.