linkml / linkml-owl

Extension of LinkML runtime for converting instances of LinkML classes to OWL (classes or instances)
https://linkml.io/linkml-owl
11 stars 1 forks source link

Replace funowl dependencies with py-horned-owl #40

Open cmungall opened 7 months ago

cmungall commented 7 months ago

See:

Which will be in 0.3.0: https://github.com/jannahastings/py-horned-owl/releases/tag/v0.3.0rc1

johardi commented 1 month ago

I wonder if this new dependency will make linkml-data2owl run faster because it's currently slow.

cmungall commented 1 month ago

It should, I am not sure how much.

funowl is particularly slow for reading. But I am not sure the extent to which any slowness you perceive is due to the logic in linkml-owl or in the funowl writer. But I am fairly sure if it's the former we can optimize the code. Do you have examples?

bherr2 commented 1 month ago

Hi Chris! I've attached the schema (ds-graph.yaml) and data (normalized.yaml) Josef and I are running linkml-data2owl cli with (github wasn't happy with just attaching yaml, so attached a zip of the two). It takes hours to run this command. Any ideas?

schema-and-data.zip

bherr2 commented 1 month ago

Oops forgot we normalize the schema. This linkml schema should be better as it brings the imports into it: ds-graph.zip

cmungall commented 1 month ago

Thanks! Yes, this is slow, but I'm confident we can make some changes here that should improve things a lot.

The majority of the time is spent in rendering objects, and switching funowl for py-horned-owl will definitely increase speed here

There are also some inefficiencies in owl_dumper that are upstream. We plan to switch out dataclasses for pydantic or plain json dicts (#44). You also make heavy use of jinja templates - which is fine - but funowl is used to parse the output of these, which adds additional inefficiencies. These will be faster with py-horned-owl based parsing.

But the majority of the slowness is in the rendering of the OWL itself, wow, funowl is really slow here. We need to swap this out soon!

bherr2 commented 1 month ago

Thanks for looking into this. We'll try to tweak a little bit, but it does finish so that's good. We'll be on the lookout for the py-horned-owl update!

cmungall commented 1 month ago

I don't think the conversion should be so hard, but I want to run some more tests first.

One consequence of the change is that ontologies will be exported in OWL/XML, not functional syntax:

https://github.com/jannahastings/py-horned-owl/issues/18

This should not be a limitation, since it can be easily converted with robot (at least for ontologies that are not in multiple millions of classes). We could even have linkml-owl do the conversion on the fly by running robot (but this is awkward). However, there is a certain ergonomic advantage in being able to see the more conventional and readable functional syntax as the default. (OWL/XML is the most useless of OWL serializations IMO)

bherr2 commented 1 month ago

How does that effect the templates, which I believe are all functional syntax? Will we need to update those?

cmungall commented 1 month ago

Good point. We could use funowl to convert to triples, then use rdflib to create rdfxml and parse that using horned owl… but at this stage things may not be any faster!

On Fri, May 31, 2024 at 4:53 AM Bruce W. Herr II @.***> wrote:

How does that effect the templates, which I believe are all functional syntax? Will we need to update those?

— Reply to this email directly, view it on GitHub https://github.com/linkml/linkml-owl/issues/40#issuecomment-2141886401, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAMMOMQ7QW774QE4T7VWITZFBQDZAVCNFSM6AAAAABAGRAZN2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNBRHA4DMNBQGE . You are receiving this because you authored the thread.Message ID: @.***>

bherr2 commented 1 month ago

Yeah, I'm happy to update our templates, but it would be a breaking change for those who have done the same. May need to bump major version (which is justified either way I think).

cmungall commented 1 month ago

I think having to author templates as owx would be a bit of an obstacle, as this is such a verbose representation. Let's see what the py-horned-owl people say, I'm hoping it's not a big lift

On Fri, May 31, 2024 at 8:23 AM Bruce W. Herr II @.***> wrote:

Yeah, I'm happy to update our templates, but it would be a breaking change for those who have done the same. May need to bump major version (which is justified either way I think).

— Reply to this email directly, view it on GitHub https://github.com/linkml/linkml-owl/issues/40#issuecomment-2142494977, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAMMONLGTN26UHS3YVFRSLZFCIXVAVCNFSM6AAAAABAGRAZN2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNBSGQ4TIOJXG4 . You are receiving this because you authored the thread.Message ID: @.***>