Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: unhashable type: 'list' on nested class description #231

Open
bretelerjmw opened this issue Aug 16, 2024 · 0 comments
Open

TypeError: unhashable type: 'list' on nested class description #231

bretelerjmw opened this issue Aug 16, 2024 · 0 comments

Comments

@bretelerjmw
Copy link
Contributor

When I run python -m pylode example.ttl on the example ontology below, I receive TypeError: unhashable type: 'list'. Here is the full error trace:

INFO:root:Loading background ontologies from a pickle file
DEBUG:asyncio:Using proactor: IocpProactor
Traceback (most recent call last):
  File "C:\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Python310\lib\site-packages\pylode\__main__.py", line 6, in <module>
    main()
  File "C:\Python310\lib\site-packages\pylode\cli.py", line 87, in main
    print(html.make_html(**pylode_kwargs))
  File "C:\Python310\lib\site-packages\pylode\profiles\ontpub.py", line 146, in make_html
    self._make_body()
  File "C:\Python310\lib\site-packages\pylode\profiles\ontpub.py", line 327, in _make_body
    self._make_main_sections()
  File "C:\Python310\lib\site-packages\pylode\profiles\ontpub.py", line 445, in _make_main_sections
    d = section_html(
  File "C:\Python310\lib\site-packages\pylode\utils.py", line 872, in section_html
    _element_html(
  File "C:\Python310\lib\site-packages\pylode\utils.py", line 811, in _element_html
    prop_obj_pair_html(
  File "C:\Python310\lib\site-packages\pylode\utils.py", line 753, in prop_obj_pair_html
    o = rdf_obj_html(ont, back_onts, ns, obj, fids, rdf_type=obj_type, prop=prop_iri)
  File "C:\Python310\lib\site-packages\pylode\utils.py", line 716, in rdf_obj_html
    return _rdf_obj_single_html(
  File "C:\Python310\lib\site-packages\pylode\utils.py", line 709, in _rdf_obj_single_html
    ret = _bn_html(ont_, back_onts_, ns_, fids_, obj_)
  File "C:\Python310\lib\site-packages\pylode\utils.py", line 702, in _bn_html
    return _setclass_html(ont__, obj__, back_onts__, ns__, fids__)
  File "C:\Python310\lib\site-packages\pylode\utils.py", line 684, in _setclass_html
    class_set.add(
TypeError: unhashable type: 'list'

The ontology input contains a class intersection nested inside a class union. I wonder if that's what's causing the trouble here. When I run pyLODE on either the union or the intersection alone, it's fine. I have tried to look at the code around utils.py:684 and I don't see explicit support for nesting, but admittedly, I struggle to follow exactly what is happening within the larger context of _rdf_obj_single_html.

Also, I have been running pyLODE on my actual ontology with this structure for a while, but I only recently started seeing this error. Could be it's related to some changes in pyLODE or its dependencies.

Example ontology

@prefix ex: <http://example.org/> .

@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

ex:onto
  rdf:type owl:Ontology ;
  dcterms:title "Test ontology" ;
  dcterms:description "Test ontology" ;
.
ex:testProp
  rdf:type owl:ObjectProperty ;
  rdfs:range [
    owl:unionOf (
      ex:ClassA
      [
        owl:intersectionOf (
          ex:ClassB
          [
            a owl:Restriction ;
            owl:onProperty ex:propA ;
            owl:hasValue ex:valueA
          ]
        ) ;
      ]
    ) ;
  ] ;
  rdfs:subPropertyOf owl:topObjectProperty ;
.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant