Hi all,
I have recently started playing with Owlready2 and one of the errors I have faced is this one: * Owlready2 * Running Pellet... java -Xmx2000M -cp /home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/slf4j-api-1.6.4.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/jgrapht-jdk1.5.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/slf4j-log4j12-1.6.4.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/aterm-java-1.6.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/pellet-2.3.1.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/log4j-1.2.16.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/jena-tdb-0.10.0.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/xml-apis-1.4.01.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/antlr-runtime-3.2.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/xercesImpl-2.10.0.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/httpcore-4.2.2.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/jena-iri-0.9.5.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/antlr-3.2.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/httpclient-4.2.3.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/owlapi-distribution-3.4.3-bin.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/jena-arq-2.10.0.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/commons-codec-1.6.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/jcl-over-slf4j-1.6.4.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/jena-core-2.10.0.jar pellet.Pellet realize --loader Jena --input-format N-Triples --ignore-imports /tmp/tmprashqybv Traceback (most recent call last): File "/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/reasoning.py", line 259, in sync_reasoner_pellet output = subprocess.run(command, stdout = subprocess.PIPE, stderr = subprocess.PIPE, check = True, **_subprocess_kargs).stdout File "/usr/lib/python3.9/subprocess.py", line 528, in run raise CalledProcessError(retcode, process.args, subprocess.CalledProcessError: Command '['java', '-Xmx2000M', '-cp', '/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/slf4j-api-1.6.4.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/jgrapht-jdk1.5.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/slf4j-log4j12-1.6.4.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/aterm-java-1.6.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/pellet-2.3.1.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/log4j-1.2.16.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/jena-tdb-0.10.0.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/xml-apis-1.4.01.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/antlr-runtime-3.2.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/xercesImpl-2.10.0.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/httpcore-4.2.2.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/jena-iri-0.9.5.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/antlr-3.2.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/httpclient-4.2.3.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/owlapi-distribution-3.4.3-bin.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/jena-arq-2.10.0.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/commons-codec-1.6.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/jcl-over-slf4j-1.6.4.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/jena-core-2.10.0.jar', 'pellet.Pellet', 'realize', '--loader', 'Jena', '--input-format', 'N-Triples', '--ignore-imports', '/tmp/tmprashqybv']' returned non-zero exit status 1. During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/reasoning.py", line 267, in sync_reasoner_pellet msg += "\nThis is the output of `pellet explain`: \n {}\n{}".format(_decode(process), _decode(process.stderr)) File "/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/reasoning.py", line 112, in _decode return s.decode("utf8") AttributeError: 'CompletedProcess' object has no attribute 'decode' Process finished with exit code 1 The code that creates it is: from owlready2 import * on = get_ontology("http://tetete.com/ontology.owl") class Human(Thing): namespace = on class Male(Thing): namespace = on class Female(Thing): namespace = on Human.equivalent_to.append(Male | Female) maria = Human("MARIA") maria.is_instance_of.append(Not(Male)) maria.is_instance_of.append(Male) on.save(file='test') sync_reasoner_pellet(debug=4) It is purposefully inconsistent, as I want to see what will be the pellet explanation. My setup is: Python 3.9 Owlready2 0.35 and for java -version: openjdk version "11.0.13" 2021-10-19 OpenJDK Runtime Environment (build 11.0.13+8) OpenJDK 64-Bit Server VM (build 11.0.13+8, mixed mode) Do you have any insight? Stelios |
I think this is a bug in how the output of the subprocess call to the reasoner is handled.
I also tried to fix it: https://bitbucket.org/cvk/owlready2/branch/bugfix/pellet_inconsistent_error Works in my setup. The call now raises an OwlReadyInconsistentOntologyError. Best, Carsten |
Hi Carsten, thanks for your quick response.
I added your fix to my setup but another error is thrown. Specifically: * Owlready2 * Warning: optimized Cython parser module 'owlready2_optimized' is not available, defaulting to slower Python implementation * Owlready2 * Running Pellet... java -Xmx2000M -cp /home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/slf4j-api-1.6.4.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/jgrapht-jdk1.5.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/slf4j-log4j12-1.6.4.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/aterm-java-1.6.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/pellet-2.3.1.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/log4j-1.2.16.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/jena-tdb-0.10.0.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/xml-apis-1.4.01.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/antlr-runtime-3.2.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/xercesImpl-2.10.0.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/httpcore-4.2.2.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/jena-iri-0.9.5.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/antlr-3.2.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/httpclient-4.2.3.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/owlapi-distribution-3.4.3-bin.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/jena-arq-2.10.0.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/commons-codec-1.6.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/jcl-over-slf4j-1.6.4.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/jena-core-2.10.0.jar pellet.Pellet realize --loader Jena --input-format N-Triples --ignore-imports /tmp/tmpt9he5926 Traceback (most recent call last): File "/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/reasoning.py", line 271, in sync_reasoner_pellet output = subprocess.run(command, stdout = subprocess.PIPE, stderr = subprocess.PIPE, check = True, **_subprocess_kargs).stdout File "/usr/lib/python3.9/subprocess.py", line 528, in run raise CalledProcessError(retcode, process.args, subprocess.CalledProcessError: Command '['java', '-Xmx2000M', '-cp', '/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/slf4j-api-1.6.4.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/jgrapht-jdk1.5.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/slf4j-log4j12-1.6.4.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/aterm-java-1.6.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/pellet-2.3.1.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/log4j-1.2.16.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/jena-tdb-0.10.0.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/xml-apis-1.4.01.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/antlr-runtime-3.2.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/xercesImpl-2.10.0.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/httpcore-4.2.2.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/jena-iri-0.9.5.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/antlr-3.2.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/httpclient-4.2.3.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/owlapi-distribution-3.4.3-bin.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/jena-arq-2.10.0.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/commons-codec-1.6.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/jcl-over-slf4j-1.6.4.jar:/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/pellet/jena-core-2.10.0.jar', 'pellet.Pellet', 'realize', '--loader', 'Jena', '--input-format', 'N-Triples', '--ignore-imports', '/tmp/tmpt9he5926']' returned non-zero exit status 1. During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/stelios/VirtualPythonEnvironments/ProverPlayground/lib/python3.9/site-packages/owlready2/reasoning.py", line 281, in sync_reasoner_pellet raise OwlReadyInconsistentOntologyError("Java error message is: %s" % msg) owlready2.base.OwlReadyInconsistentOntologyError: Java error message is: log4j:WARN No appenders could be found for logger (com.hp.hpl.jena.sparql.mgt.ARQMgt). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. ERROR: Ontology is inconsistent, run "pellet explain" to get the reason This is the output of `pellet explain`: log4j:WARN No appenders could be found for logger (com.hp.hpl.jena.sparql.mgt.ARQMgt). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. Exception in thread "main" org.semanticweb.owlapi.model.OWLRuntimeException: No explanation computed at com.clarkparsia.owlapi.explanation.GlassBoxExplanation.convertExplanation(GlassBoxExplanation.java:258) at com.clarkparsia.owlapi.explanation.GlassBoxExplanation.getPelletExplanation(GlassBoxExplanation.java:228) at com.clarkparsia.owlapi.explanation.GlassBoxExplanation.getExplanation(GlassBoxExplanation.java:191) at com.clarkparsia.owlapi.explanation.HSTExplanationGenerator.getExplanation(HSTExplanationGenerator.java:113) at com.clarkparsia.owlapi.explanation.HSTExplanationGenerator.getExplanations(HSTExplanationGenerator.java:137) at pellet.PelletExplain.explainAxiom(PelletExplain.java:269) at pellet.PelletExplain.explainSubClass(PelletExplain.java:371) at pellet.PelletExplain.explainUnsatisfiableClass(PelletExplain.java:385) at pellet.PelletExplain.run(PelletExplain.java:233) at pellet.Pellet.run(Pellet.java:105) at pellet.Pellet.main(Pellet.java:59) Since it works for you, there should be something wrong with my java setup? Stelios |
Hi Stelios,
you are experiencing now the desired behavior now (at least as far I understand it): You get an `OwlReadyInconsistentOntologyError`. Explanaition: Owlready calls the reasoner via `subproces` module. This allows python to call other programs, java in our case. The reasoner discovers an inconsistent ontology and this process exits with an nonzero status code. As this is usually indicating that something went wrong. Thus, a CalledProcessError is raised. However, owlready catches this error with try ... except clause and handles it. This handling consists in calling the reasoner again (now with the `explain` argument. It caputures the output of this call and then raises an `OwlReadyInconsistentOntologyError` – as briefly mentioned in my last message. Thus owlready is telling you: Your ontology is inconsistent and here is some output from the pellet reasonser that might help you in debugging. This is better then raising an AttributeError as it was before). Your initial intention was to find out the pellet explanation. Now you have it. If its not helpful, then it is probably an issue of pellet. I truncated your output below to the most relevant part which hopefully illustrates my above explanation. One last tip: You can use `sync_reasoner_pellet(debug=4, keep_tmp_file=True)` to prevent the temporary ontology file from deleting. This allows you to call the reasoner directly from the command line (with the command which is shown by the debug output) without owlready postprocessing it. This might be also useful for debugging.
|
Ok, I see now. I expected that Owlready wouldn't exit with error, but it would indicate how the ontology is inconsistent (similarly to Protege) that's why I got confused. The
Exception in thread "main" org.semanticweb.owlapi.model.OWLRuntimeException: No explanation computedpart confused me. Thank you for your explanation, I appreciate it. Stelios |
Free forum by Nabble | Edit this page |