Skip to content

Commit

Permalink
fix profile validation
Browse files Browse the repository at this point in the history
  • Loading branch information
muddymudskipper committed Jul 8, 2024
1 parent f4ce052 commit 78f894e
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 10 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

### Added

- parameter for validating the input ontology against OWL2 profiles (EL, DL, RL, QL, and Full) in Reason plugin
- parameter for validating the input ontology against OWL2 profiles (DL, EL, QL, RL, and Full)
- Validate plugin outputs valid profiles with path "profile"

### Changed

- Validate plugin outputs the Markdown result with path "markdown"

## [1.0.0beta2] 2024-07-04

Expand Down
6 changes: 4 additions & 2 deletions cmem_plugin_reason/plugin_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,11 @@ def make_resource(self, context: ExecutionContext) -> None:

def add_profiles(self, valid_profiles: list) -> list:
"""Add profile validation result to output"""
profiles_str = "\n- ".join(valid_profiles)
with (Path(self.temp) / self.md_filename).open("a") as mdfile:
mdfile.write(f"\n\n\n# Valid Profiles:\n- {profiles_str}\n")
mdfile.write("\n\n\n# Valid Profiles:\n")
if valid_profiles:
profiles_str = "\n- ".join(valid_profiles)
mdfile.write(f"- {profiles_str}\n")
if self.produce_graph:
post_profiles(self, valid_profiles)
return valid_profiles
Expand Down
9 changes: 4 additions & 5 deletions cmem_plugin_reason/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
param_type=BoolParameterType(),
name="validate_profile",
label="Annotate ontology with valid OWL2 profiles",
description="""Validate the input ontology against OWL profiles (EL, DL, RL, QL, and
description="""Validate the input ontology against OWL profiles (DL, EL, QL, RL, and
Full) and annotate the result graph.""",
default_value=False,
)
Expand Down Expand Up @@ -227,14 +227,13 @@ def validate_profiles(plugin: WorkflowPlugin, graphs: dict) -> list:
"""Validate OWL2 profiles"""
ontology_location = f"{plugin.temp}/{graphs[plugin.ontology_graph_iri]}"
valid_profiles = []
for profile in ("Full", "DL", "RL", "QL"):
for profile in ("Full", "DL", "EL", "QL", "RL"):
cmd = f"validate-profile --profile {profile} --input {ontology_location}"
response = robot(cmd, plugin.max_ram_percentage)
if response.stdout.endswith(b"[Ontology and imports closure in profile]\n\n"):
valid_profiles.append(profile)
if profile != "Full":
break

elif profile == "Full":
break
return valid_profiles


Expand Down
2 changes: 1 addition & 1 deletion tests/test_reason.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def test_validate(errors: str) -> str:
if next(iter(result.entities)).values[0][0] != md_test: # type: ignore[union-attr]
val_errors += 'EntityPath "markdown" output error. '

if next(iter(result.entities)).values[1] != ["Full", "DL"]: # type: ignore[union-attr]
if next(iter(result.entities)).values[1] != ["Full", "DL", "EL", "QL", "RL"]: # type: ignore[union-attr]
val_errors += 'EntityPath "profile" output error. '

if md_test != get_resource(PROJECT_ID, MD_FILENAME).decode():
Expand Down
3 changes: 3 additions & 0 deletions tests/test_validate.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@
# Valid Profiles:
- Full
- DL
- EL
- QL
- RL
2 changes: 1 addition & 1 deletion tests/test_validate_output.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@

<https://ns.eccenca.com/validateontology/e02aaed014c94e0c91bf960fed127750/vocab/B> a owl:Class .

<https://ns.eccenca.com/validateontology/e02aaed014c94e0c91bf960fed127750/vocab/> <https://vocab.eccenca.com/plugin/reason/profile> "DL", "Full" .
<https://ns.eccenca.com/validateontology/e02aaed014c94e0c91bf960fed127750/vocab/> <https://vocab.eccenca.com/plugin/reason/profile> "Full", "DL", "EL", "QL", "RL" .

0 comments on commit 78f894e

Please sign in to comment.