Skip to content

Commit

Permalink
refactor parameter variable generation
Browse files Browse the repository at this point in the history
  • Loading branch information
muddymudskipper committed Aug 12, 2024
1 parent 021f78f commit bc6cf5e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
19 changes: 5 additions & 14 deletions cmem_plugin_reason/plugin_reason.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from cmem_plugin_base.dataintegration.ports import FixedNumberOfInputs, FixedSchemaPort
from cmem_plugin_base.dataintegration.types import BoolParameterType
from cmem_plugin_base.dataintegration.utils import setup_cmempy_user_access
from inflection import underscore
from urllib3.exceptions import InsecureRequestWarning

from cmem_plugin_reason.utils import (
Expand Down Expand Up @@ -245,20 +246,7 @@ def __init__( # noqa: PLR0913, C901
errors += 'Invalid value for parameter "Maximum RAM Percentage". '
if errors:
raise ValueError(errors[:-1])
self.sub_class = sub_class
self.equivalent_class = equivalent_class
self.disjoint_classes = disjoint_classes
self.data_property_characteristic = data_property_characteristic
self.equivalent_data_properties = equivalent_data_properties
self.sub_data_property = sub_data_property
self.class_assertion = class_assertion
self.property_assertion = property_assertion
self.equivalent_object_property = equivalent_object_property
self.inverse_object_properties = inverse_object_properties
self.object_property_characteristic = object_property_characteristic
self.sub_object_property = sub_object_property
self.object_property_range = object_property_range
self.object_property_domain = object_property_domain

self.data_graph_iri = data_graph_iri
self.ontology_graph_iri = ontology_graph_iri
self.output_graph_iri = output_graph_iri
Expand All @@ -267,6 +255,9 @@ def __init__( # noqa: PLR0913, C901
self.input_profiles = input_profiles
self.max_ram_percentage = max_ram_percentage

for k, v in self.axioms.items():
self.__dict__[underscore(k)] = v

if validate_profile and input_profiles:
self.input_ports = FixedNumberOfInputs([FixedSchemaPort(self.generate_input_schema())])
else:
Expand Down
3 changes: 0 additions & 3 deletions cmem_plugin_reason/plugin_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,11 @@ def explain(self, graphs: dict) -> None:
"""Reason"""
data_location = f"{self.temp}/{graphs[self.ontology_graph_iri]}"
utctime = str(datetime.fromtimestamp(int(time()), tz=UTC))[:-6].replace(" ", "T") + "Z"

cmd = (
f'explain --input "{data_location}" '
f"--reasoner {self.reasoner} -M inconsistency "
f'--explanation "{self.temp}/{self.md_filename}"'
)

if self.output_graph_iri:
cmd += (
f' annotate --ontology-iri "{self.output_graph_iri}" '
Expand All @@ -161,7 +159,6 @@ def explain(self, graphs: dict) -> None:
f'--typed-annotation dc:created "{utctime}" xsd:dateTime '
f'--output "{self.temp}/output.ttl"'
)

response = robot(cmd, self.max_ram_percentage)
if response.returncode != 0:
if response.stdout:
Expand Down
19 changes: 15 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ validators = "^0.33.0"
pathvalidate = "^3.2.0"
defusedxml = "^0.7.1"
urllib3 = "^2.2.2"
inflection = "^0.5.1"

[tool.poetry.dependencies.cmem-plugin-base]
version = "^4.5.0"
Expand Down

0 comments on commit bc6cf5e

Please sign in to comment.