Skip to content

Handle multi-valued slots that are None when serializing to RDF#636

Merged
cthoyt merged 3 commits into
masterfrom
fix-unhandled-node
Mar 31, 2026
Merged

Handle multi-valued slots that are None when serializing to RDF#636
cthoyt merged 3 commits into
masterfrom
fix-unhandled-node

Conversation

@cthoyt
Copy link
Copy Markdown
Member

@cthoyt cthoyt commented Nov 25, 2025

Since pandas implements missing values as floats, this can give exceptions like

Traceback (most recent call last):
  File "/Users/cthoyt/.virtualenvs/biopragmatics/bin/biomappings", line 10, in <module>
    sys.exit(main())
             ~~~~^^
  File "/Users/cthoyt/.virtualenvs/biopragmatics/lib/python3.14/site-packages/click/core.py", line 1462, in __call__
    return self.main(*args, **kwargs)
           ~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/Users/cthoyt/.virtualenvs/biopragmatics/lib/python3.14/site-packages/click/core.py", line 1383, in main
    rv = self.invoke(ctx)
  File "/Users/cthoyt/.virtualenvs/biopragmatics/lib/python3.14/site-packages/click/core.py", line 1850, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/Users/cthoyt/.virtualenvs/biopragmatics/lib/python3.14/site-packages/click/core.py", line 1246, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cthoyt/.virtualenvs/biopragmatics/lib/python3.14/site-packages/click/core.py", line 814, in invoke
    return callback(*args, **kwargs)
  File "/Users/cthoyt/.virtualenvs/biopragmatics/lib/python3.14/site-packages/click/decorators.py", line 46, in new_func
    return f(get_current_context().obj, *args, **kwargs)
  File "/Users/cthoyt/dev/sssom-curator/src/sssom_curator/repository.py", line 458, in main
    merge(obj, directory=sssom_directory)
    ~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cthoyt/dev/sssom-curator/src/sssom_curator/export/merge.py", line 90, in merge
    write_owl(msdf, file)
    ~~~~~~~~~^^^^^^^^^^^^
  File "/Users/cthoyt/dev/sssom-py/src/sssom/writers.py", line 235, in write_owl
    graph = to_owl_graph(msdf)
  File "/Users/cthoyt/dev/sssom-py/src/sssom/writers.py", line 280, in to_owl_graph
    graph = to_rdf_graph(msdf=msdf)
  File "/Users/cthoyt/dev/sssom-py/src/sssom/writers.py", line 374, in to_rdf_graph
    return MappingSetRDFConverter(hydrate=hydrate, ccp=msdf.converter).msdf_to_rdf(
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        msdf, hydrate=hydrate
        ^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/Users/cthoyt/dev/sssom-py/src/sssom/rdf_internal.py", line 879, in msdf_to_rdf
    self._mapping_to_rdf(graph, ms_node, row, hydrate)
    ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cthoyt/dev/sssom-py/src/sssom/rdf_internal.py", line 915, in _mapping_to_rdf
    mapping_node = self.mapping_converter.dict_to_rdf(graph, mapping)
  File "/Users/cthoyt/dev/sssom-py/src/sssom/rdf_internal.py", line 583, in dict_to_rdf
    for value in self._get_multi_values(v):
                 ~~~~~~~~~~~~~~~~~~~~~~^^^
  File "/Users/cthoyt/dev/sssom-py/src/sssom/rdf_internal.py", line 974, in _get_multi_values
    return cast(List[Any], value.split("|"))
                           ^^^^^^^^^^^
AttributeError: 'float' object has no attribute 'split'

i have to put more time to understand how all these calls are made so I can write a unit test

@matentzn
Copy link
Copy Markdown
Collaborator

@cthoyt is this still needed?

@cthoyt cthoyt marked this pull request as ready for review March 31, 2026 06:46
@cthoyt
Copy link
Copy Markdown
Member Author

cthoyt commented Mar 31, 2026

@matentzn yes, I just added a test in 72523bd that fails without this fix. ready for merge now.

@cthoyt cthoyt changed the title Catch missing value Handle multi-valued slots that are None when serializing to RDF Mar 31, 2026
@cthoyt cthoyt enabled auto-merge (squash) March 31, 2026 06:48
@cthoyt cthoyt requested a review from matentzn March 31, 2026 06:58
Copy link
Copy Markdown
Collaborator

@matentzn matentzn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, thank you!

@cthoyt cthoyt merged commit 2870825 into master Mar 31, 2026
6 checks passed
@matentzn matentzn deleted the fix-unhandled-node branch March 31, 2026 10:19
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

Successfully merging this pull request may close these issues.

2 participants