Skip to content

Pellet Bug #195

@LckyLke

Description

@LckyLke
import sys
from owlapy.iri import IRI
from owlapy.class_expression import (
    OWLClass, OWLObjectComplementOf, OWLObjectMinCardinality, OWLObjectOneOf
)
from owlapy.owl_property import OWLObjectProperty, OWLObjectInverseOf
from owlapy.owl_reasoner import SyncReasoner
import jpype

def recreate_bug():
    NS = "http://www.biopax.org/examples/glycolysis#"
    
    print("Loading biopax.owl ...")
    reasoner = SyncReasoner("KGs/Biopax/biopax.owl", reasoner="Pellet")

    participants_inv = OWLObjectInverseOf(OWLObjectProperty(IRI(NS, "PARTICIPANTS")))
    not_pathway_step = OWLObjectComplementOf(OWLClass(IRI(NS, "pathwayStep")))

    print("Retrieving instances of '¬pathwayStep' to pass as OneOf nominals...")
    global_iris = list(reasoner.instances(not_pathway_step))
    print(f"Found {len(global_iris)} instances.")

    nominal_ce = OWLObjectOneOf(global_iris)
    ce = OWLObjectMinCardinality(2, property=participants_inv, filler=nominal_ce)
    
    print(f"\nEvaluating: {ce}")

    try:
        # Direct call to pellet
        res = list(reasoner.instances(ce))
        print(f"Success! Found {len(res)} instances")
    except Exception as e:
        print("\n" + "="*80)
        print("CAUGHT EXCEPTION!")
        print("="*80)
        
        # Unwrap concurrency futures exception if present
        if hasattr(e, '__cause__') and e.__cause__:
            e = e.__cause__
            
        print(f"Type: {type(e)}")
        print(f"Name: {e.__class__.__name__}")
        
        # Try to print the Java stacktrace 
        try:
            if hasattr(e, 'stacktrace'):
                print("\n--- JAVA STACK TRACE ---")
                e.stacktrace().printStackTrace()
            else:
                try:
                    import traceback
                    print("\n--- PYTHON STACK TRACE ---")
                    traceback.print_exc()
                except Exception:
                    pass
        except Exception as inner_e:
            print("Failed to print Java stack trace:", inner_e)

if __name__ == "__main__":
    recreate_bug()

Results in:

================================================================================
CAUGHT EXCEPTION!
================================================================================
Type: <class 'Exception'>
Name: Exception

--- PYTHON STACK TRACE ---
Traceback (most recent call last):
  File "PelletReasoner.java", line 704, in openllet.owlapi.PelletReasoner.getInstances
Exception: Java Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/lukef/Documents/GitHub/owlapy/recreate_bug.py", line 31, in recreate_bug
    res = list(reasoner.instances(ce))
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lukef/Documents/GitHub/owlapy/owlapy/owl_reasoner.py", line 1143, in instances
    return run_with_timeout(self._instances, timeout, (ce, direct))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lukef/Documents/GitHub/owlapy/owlapy/utils.py", line 80, in run_with_timeout
    result = future.result(timeout=timeout)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lukef/miniconda3/envs/owlapy/lib/python3.11/concurrent/futures/_base.py", line 456, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/home/lukef/miniconda3/envs/owlapy/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/home/lukef/miniconda3/envs/owlapy/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lukef/Documents/GitHub/owlapy/owlapy/owl_reasoner.py", line 1137, in _instances
    instances = self._owlapi_reasoner.getInstances(mapped_ce, direct)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
java.lang.java.lang.ArrayIndexOutOfBoundsException: java.lang.ArrayIndexOutOfBoundsException: Index 2 out of bounds for length 2

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions