You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by "Meckler, Sascha" <sa...@iis.fraunhofer.de> on 2020/04/27 08:49:20 UTC

Fuseki inference not triggered with incoming data

Hi *,
I have a question about Fuseki:

We have a Fuseki server with one dataset for actual data and one dataset with reasoning based on the default union graph (=data from first dataset). When I insert new data into the first dataset, the inference is not always triggered. The reasoning dataset updates only at the first time or when restarting. How can we configurate Fuseki to run the inference every time that new data is inserted into the first dataset? Or is there a better way to do this?

I created a small demo project with an easy example and additional documentation [1]. My student asked on StackOverflow [2] in January but there was no answer.

Thank you very much for your help!
Best regards,
Sascha

[1] https://github.com/smeckler/inference-demo
[2] https://stackoverflow.com/questions/59952945/reasoning-in-apache-jena-fuseki-reload-dataset-or-trigger-inference

______________________________________________________
Sascha Meckler
Data Spaces and IoT Solutions

Fraunhofer-Institut für Integrierte Schaltungen IIS
Nordostpark 93 | 90411 Nürnberg

Phone +49 911 58061-9614


RE: Fuseki inference not triggered with incoming data

Posted by "Meckler, Sascha" <sa...@iis.fraunhofer.de>.
Hi Andy and Nicola,

sending updates to the inference graph effectively triggers the inference. In my example it causes an AddDeniedException, because the UnionGraph is read-only. However, the inference is still executed.

@Nicola: Your solution sounds very interesting. I'm looking forward to your blog post!

Background:
We chose the described approach with two datasets and the UnionGraph because we'd like to separate the ontology, the original data and the reasoning results. By using the UnionGraph from the first dataset as the base graph for the inference dataset, we don't have to manually duplicate the original data. We need to keep track of the original data in different named graphs to be able to easily do CRUD operations at runtime. The inferenced graph is meant for querying. In order to expand the query results, the inference should resolve hierarchical relationships (rdfs:subClassOf, rdfs:subPropertyOf), equality statements (owl:sameAs) and perform classifications based on property restrictions (owl:Restriction). 

Best regards,
Sascha


>-----Original Message-----
>From: Andy Seaborne <an...@apache.org>
>Sent: Wednesday, April 29, 2020 10:09 AM
>To: users@jena.apache.org
>Subject: Re: Fuseki inference not triggered with incoming data
>
>Sascha,
>
>(aside)
>For my general understanding:
>What level of reasoning are you and your student interested in having?
>
>There is a tradeoff between inference expressiveness, performance (CPU
>and RAM costs), how much development effect it would take for future
>improvements.
>
>On 29/04/2020 08:18, Meckler, Sascha wrote:
>> Hello Andy and Marco,
>>
>> the problem also applies to built-in reasoners.
>> I tried Jena's OWLFBRuleReasoner, OWLMicroFBRuleReasoner and the
>RDFSExptRuleReasoner.
>> (See demo project: https://github.com/smeckler/inference-
>demo/blob/master/src/main/resources/fuseki/config.ttl)
>
>Each of which has some forward rules.
>
>If you want to update the inference graph, send updates to the inference
>graph.
>
>     Andy
>
>>
>> Thank you for your help!
>> Best regards,
>> Sascha
>>
>>
>>> -----Original Message-----
>>> From: Marco Neumann <ma...@gmail.com>
>>> Sent: Tuesday, April 28, 2020 7:12 PM
>>> To: users@jena.apache.org
>>> Subject: Re: Fuseki inference not triggered with incoming data
>>>
>>> so Sascha in short try to use one of the Jena build-in reasoners if this is
>>> not bound to a pellet specific task. if it is you will have to bring this
>>> request up with the pellet maintainers.
>>>
>>> On Tue, Apr 28, 2020 at 5:20 PM Andy Seaborne <an...@apache.org>
>wrote:
>>>
>>>>
>>>>
>>>> On 27/04/2020 09:49, Meckler, Sascha wrote:
>>>>> Hi *,
>>>>> I have a question about Fuseki:
>>>>>
>>>>> We have a Fuseki server with one dataset for actual data and one
>dataset
>>>> with reasoning based on the default union graph (=data from first
>dataset).
>>>> When I insert new data into the first dataset, the inference is not always
>>>> triggered. The reasoning dataset updates only at the first time or when
>>>> restarting. How can we configurate Fuseki to run the inference every time
>>>> that new data is inserted into the first dataset? Or is there a better way
>>>> to do this?
>>>>
>>>> For forward rules, I think that the data updates have to go through the
>>>> graph with the inference.  Forward rules keep state so if you bypass
>>>> inference the graph, the state does not get updated.
>>>>
>>>> Backwards rules may notice to some extent - I'm unsure of the details
>here.
>>>>
>>>> Pellet isn't part of the Apache Jena project.
>>>>
>>>>       Andy
>>>>
>>>>>
>>>>> I created a small demo project with an easy example and additional
>>>> documentation [1]. My student asked on StackOverflow [2] in January but
>>>> there was no answer.
>>>>>
>>>>> Thank you very much for your help!
>>>>> Best regards,
>>>>> Sascha
>>>>>
>>>>> [1] https://github.com/smeckler/inference-demo
>>>>> [2]
>>>> https://stackoverflow.com/questions/59952945/reasoning-in-apache-
>jena-
>>> fuseki-reload-dataset-or-trigger-inference
>>>>>
>>>>> ______________________________________________________
>>>>> Sascha Meckler
>>>>> Data Spaces and IoT Solutions
>>>>>
>>>>> Fraunhofer-Institut für Integrierte Schaltungen
>>>>
>>>
><https://www.google.com/maps/search/tut+f%C3%BCr+Integrierte+Schaltun
>>> gen?entry=gmail&source=g>
>>>> IIS
>>>>> Nordostpark 93 | 90411 Nürnberg
>>>>>
>>>>> Phone +49 911 58061-9614
>>>>>
>>>>>
>>>>
>>> --
>>>
>>>
>>> ---
>>> Marco Neumann
>>> KONA

RE: Fuseki inference not triggered with incoming data

Posted by "Meckler, Sascha" <sa...@iis.fraunhofer.de>.
Hello Nicola,

Sorry, I didn't notice that the attached CSV was removed by the ML. I added its content at the bottom of this mail.

For my tests, I used a standalone Fuseki in the version (3.14) with the default configuration. I tried uploading the Turtle data files via the GUI or by using a REST client (Postman) - with the same results. I have no idea why we have different results regarding the sameAs-Triples.

I found two workarounds for my use case:
1) Manually copy all data from the UnionGraph to another dataset with inf model. I implemented a scheduled task that uses the Graph Store protocol.
2) SPARQL Update request to the UnionGraph that triggers the inference but causes an exception because UnionGraph is read-only

Best regards,
Sascha

triplecount.csv

;step 1;step 2-4;step 5;step 6-7;step 8;step 9-11;step 12;;;;;
;start-up;add data1 to mygraph;add data2 to mygraph;add data2 to inf model;restart;add data3 to inf2;restart;;;;;
graph name;triples;;;;;;;;;;;
default graph;644;666;675;675;689;702;710;;;;;
http://www.example.org/id/mygraph;0;5;8;8;8;8;8;;;;;
http://www.example.org/id/inf;644;666;675;680;689;689;689;;;;;
http://www.example.org/id/mygraph2;0;0;0;0;0;3;3;;;;;
http://www.example.org/id/inf2;644;644;644;644;644;661;661;;;;;


>-----Original Message-----
>From: Nicola Vitucci <ni...@gmail.com>
>Sent: Saturday, May 9, 2020 12:26 PM
>To: users@jena.apache.org
>Subject: Re: Fuseki inference not triggered with incoming data
>
>Hi Sascha,
>
>Thanks for taking some time to take a deeper look (although you may have
>skipped the CSV attachment :) ). I acknowledged your help in my post. I've
>rerun my examples, so here are my observations.
>
>* Incomplete inference: It adds some triples to the inf graph (see step 5
>> in the attached CSV file). For example, an owl:sameAs statement appeared
>in
>> the query results. The inference was, however, incomplete because no
>> inferred hierarchical relations were added. Do you mean this by “no, or
>> limited, inference”?
>>
>
>Yes, I think that may be because some (backward?) rules are being triggered
>while the others are not. I did not obtain the owl:sameAs statement that
>you got though.
>
>
>> In step 3, the inference was incomplete. I found no hierarchical relation
>> statements in the id:inf graph (missing: “ont:mySuperProp id:x id:inf“ and
>> “rdf:type ont:MySuperType id:inf”). The two missing statements only
>showed
>> up after a restart.
>>
>
>You are right, I wrote the wrong graph name. The data1.ttl file in step 2
>should be inserted in the <inf> graph, not in <mygraph>, to check that
>inference is working. (Or, as you said, a restart is needed.)
>
>
>> In step 5, the triple “owl:sameAs id:d” was added.
>>
>
>This hasn't happened in neither of my runs, at least until restart. It may
>have been related to the "incomplete inference" issue.
>
>
>> In step 6, I think it was MySubType, not MySuperType.
>>
>
>You are right again. I fixed it.
>
>
>> Again in step 11, one inferred triple was present: owl:sameAs id:XXX.
>> After a restart (step 12), the inference was complete.
>>
>
>Again, I didn't get this until restart.
>
>I wonder whether the overall configuration plays a role in the two
>owl:sameAs triples that you've got while I haven't, or something else comes
>into play. Anyway, I think the overall structure is now more clear to both
>of us, and sorry if it does not help in your use case.
>
>Maybe Andy or other Jena developers may have something to add?
>
>Thanks once again,
>
>Nicola

Re: Fuseki inference not triggered with incoming data

Posted by Nicola Vitucci <ni...@gmail.com>.
Hi Sascha,

Thanks for taking some time to take a deeper look (although you may have
skipped the CSV attachment :) ). I acknowledged your help in my post. I've
rerun my examples, so here are my observations.

* Incomplete inference: It adds some triples to the inf graph (see step 5
> in the attached CSV file). For example, an owl:sameAs statement appeared in
> the query results. The inference was, however, incomplete because no
> inferred hierarchical relations were added. Do you mean this by “no, or
> limited, inference”?
>

Yes, I think that may be because some (backward?) rules are being triggered
while the others are not. I did not obtain the owl:sameAs statement that
you got though.


> In step 3, the inference was incomplete. I found no hierarchical relation
> statements in the id:inf graph (missing: “ont:mySuperProp id:x id:inf“ and
> “rdf:type ont:MySuperType id:inf”). The two missing statements only showed
> up after a restart.
>

You are right, I wrote the wrong graph name. The data1.ttl file in step 2
should be inserted in the <inf> graph, not in <mygraph>, to check that
inference is working. (Or, as you said, a restart is needed.)


> In step 5, the triple “owl:sameAs id:d” was added.
>

This hasn't happened in neither of my runs, at least until restart. It may
have been related to the "incomplete inference" issue.


> In step 6, I think it was MySubType, not MySuperType.
>

You are right again. I fixed it.


> Again in step 11, one inferred triple was present: owl:sameAs id:XXX.
> After a restart (step 12), the inference was complete.
>

Again, I didn't get this until restart.

I wonder whether the overall configuration plays a role in the two
owl:sameAs triples that you've got while I haven't, or something else comes
into play. Anyway, I think the overall structure is now more clear to both
of us, and sorry if it does not help in your use case.

Maybe Andy or other Jena developers may have something to add?

Thanks once again,

Nicola

RE: Fuseki inference not triggered with incoming data

Posted by "Meckler, Sascha" <sa...@iis.fraunhofer.de>.
Hello Nicola,



thank you again for this nice summary about Fuseki configuration with reasoning.

I was able to reproduce your findings:

1) Adding data to the base named graph doesn’t cause a complete inference* for the linked inf model.

2) Adding data to inf model triggers the inference.

3) A restart is required to trigger the complete inference on the default graph that is a UnionGraph of all named graphs.



* Incomplete inference: It adds some triples to the inf graph (see step 5 in the attached CSV file). For example, an owl:sameAs statement appeared in the query results. The inference was, however, incomplete because no inferred hierarchical relations were added. Do you mean this by “no, or limited, inference”?



Your blog post helped me to better understand the design of Fuseki datasets with reasoning. Unfortunately, it didn’t solve our specific use case. Our plan was to store contextual data in separate, named graphs and inference over the UnionGraph aggregation whenever new data is added to one of the named graphs. Using your approach, we would be able to do reasoning on each named graph separately and join the results in the default graph. But this would not automatically evaluate relations between the different graphs; It would still require a restart.



Here are my detailed results for the “Many named graphs” example. I monitored the number of triples in the different named graphs (attached CSV file).

In step 3, the inference was incomplete. I found no hierarchical relation statements in the id:inf graph (missing: “ont:mySuperProp id:x id:inf“ and “rdf:type ont:MySuperType id:inf”). The two missing statements only showed up after a restart.

In step 5, the triple “owl:sameAs id:d” was added.

In step 6, I think it was MySubType, not MySuperType.

Again in step 11, one inferred triple was present: owl:sameAs id:XXX. After a restart (step 12), the inference was complete.



Best regards

Sascha





>-----Original Message-----

>From: Nicola Vitucci <ni...@gmail.com>

>Sent: Friday, May 1, 2020 12:03 AM

>To: users@jena.apache.org

>Subject: Re: Fuseki inference not triggered with incoming data

>

>Hey Sascha, Andy,

>

>Here is my blog post:

>https://apothem.blog/apache-fuseki-adding-reasoning-and-full-text-search-<https://apothem.blog/apache-fuseki-adding-reasoning-and-full-text-search-capabilities-to-a-dataset.html>

>capabilities-to-a-dataset.html<https://apothem.blog/apache-fuseki-adding-reasoning-and-full-text-search-capabilities-to-a-dataset.html>

>

>It may require some polishing but i'd like your feedback, especially if it

>can help Sascha to solve his problem. It would be great if you could

>replicate my results, and/or confirm that my understanding is correct.

>

>For inference, I've been asking what level of inference people are

>> really using. We could have a stateless RDFS-class reasoner that sits on

>> any graph/dataset and always goes back to the base data. No, or very

>> short term, caching.

>>

>> That would be less capable, and slower (but how much? not much in

>> practice?) but it will scale, will fit with transactions and data

>> visibility, and will see changes in the data as they occur.

>>

>

>This can probably be enough for many use cases (rdf4j does something

>similar already, if I understand your suggestion), but what I see more and

>more often, and what sometimes I need as well, is some level of support for

>owl:sameAs and some other OWL constructs such as owl:equivalentClass and

>owl:equivalentProperty. That said, the scalability would make it quite

>appealing though, and a simple switch during the dataset creation phase

>("add RDFS reasoning?") would make it a very useful feature.

>

>

>> Knowing the generation of the data seems to me at the moment to be

>worth

>> adding to the dataset interface itself. A simple "what version am I

>> looking at?" method. It could be a counter (sequential) or give every

>> write transaction a UUID and be able to fetch the generation of the data

>> the current read transaction is acting on.

>>

>

>This would also be quite useful in its own right.

>

>Nicola

Re: Fuseki inference not triggered with incoming data

Posted by Nicola Vitucci <ni...@gmail.com>.
Hi Sascha, Andy,

Did you have a chance to take a look at this? If the solution seems
sensible, I'd like to improve the Jena documentation as well (for instance
here
<https://jena.apache.org/documentation/fuseki2/fuseki-server-protocol.html#datasets-and-services>
and
here
<https://jena.apache.org/documentation/fuseki2/fuseki-configuration.html>).

All the best,

Nicola

Il giorno gio 30 apr 2020 alle ore 23:03 Nicola Vitucci <
nicola.vitucci@gmail.com> ha scritto:

> Hey Sascha, Andy,
>
> Here is my blog post:
> https://apothem.blog/apache-fuseki-adding-reasoning-and-full-text-search-capabilities-to-a-dataset.html
>
> It may require some polishing but i'd like your feedback, especially if it
> can help Sascha to solve his problem. It would be great if you could
> replicate my results, and/or confirm that my understanding is correct.
>
> For inference, I've been asking what level of inference people are
>> really using. We could have a stateless RDFS-class reasoner that sits on
>> any graph/dataset and always goes back to the base data. No, or very
>> short term, caching.
>>
>> That would be less capable, and slower (but how much? not much in
>> practice?) but it will scale, will fit with transactions and data
>> visibility, and will see changes in the data as they occur.
>>
>
> This can probably be enough for many use cases (rdf4j does something
> similar already, if I understand your suggestion), but what I see more and
> more often, and what sometimes I need as well, is some level of support for
> owl:sameAs and some other OWL constructs such as owl:equivalentClass and
> owl:equivalentProperty. That said, the scalability would make it quite
> appealing though, and a simple switch during the dataset creation phase
> ("add RDFS reasoning?") would make it a very useful feature.
>
>
>> Knowing the generation of the data seems to me at the moment to be worth
>> adding to the dataset interface itself. A simple "what version am I
>> looking at?" method. It could be a counter (sequential) or give every
>> write transaction a UUID and be able to fetch the generation of the data
>> the current read transaction is acting on.
>>
>
> This would also be quite useful in its own right.
>
> Nicola
>

Re: Fuseki inference not triggered with incoming data

Posted by Nicola Vitucci <ni...@gmail.com>.
Hey Sascha, Andy,

Here is my blog post:
https://apothem.blog/apache-fuseki-adding-reasoning-and-full-text-search-capabilities-to-a-dataset.html

It may require some polishing but i'd like your feedback, especially if it
can help Sascha to solve his problem. It would be great if you could
replicate my results, and/or confirm that my understanding is correct.

For inference, I've been asking what level of inference people are
> really using. We could have a stateless RDFS-class reasoner that sits on
> any graph/dataset and always goes back to the base data. No, or very
> short term, caching.
>
> That would be less capable, and slower (but how much? not much in
> practice?) but it will scale, will fit with transactions and data
> visibility, and will see changes in the data as they occur.
>

This can probably be enough for many use cases (rdf4j does something
similar already, if I understand your suggestion), but what I see more and
more often, and what sometimes I need as well, is some level of support for
owl:sameAs and some other OWL constructs such as owl:equivalentClass and
owl:equivalentProperty. That said, the scalability would make it quite
appealing though, and a simple switch during the dataset creation phase
("add RDFS reasoning?") would make it a very useful feature.


> Knowing the generation of the data seems to me at the moment to be worth
> adding to the dataset interface itself. A simple "what version am I
> looking at?" method. It could be a counter (sequential) or give every
> write transaction a UUID and be able to fetch the generation of the data
> the current read transaction is acting on.
>

This would also be quite useful in its own right.

Nicola

Re: Fuseki inference not triggered with incoming data

Posted by Andy Seaborne <an...@apache.org>.

On 29/04/2020 12:35, Nicola Vitucci wrote:
> Hi all,
> 
> I am writing a blog post on this very subject (adding reasoning capabilities to Fuseki datasets and more) and I got a similar behaviour when updating a named graph. I've also used all the supported reasoners.

I look forward to reading it.

> My solution is kind of intermediate: creating an RDFDataset with a default graph that reasons on the special union graph, then several named graphs containing my data, each one with its (named) inference graph. In this way it's possible to add triples to the named inference graphs (as Andy suggested too) and have them reasoned upon in real time, plus the default graph can reason cross-graph (but it can only be updated with a restart anyway). I know it's not ideal, but it can probably get what you need. I'll add more details as I put things together.
> 
> @Andy: it would be nice if a dataset "reload" was supported via API as the change of state (active/offline) is. Any thoughts on this?

The issue is when changes go in via one route but inference in a graph 
is a different route. It's bypassing the rule machinery that exists that 
already exists and works.

Where that breaks down is when the base graph is some kind of composite, 
default union graph is one example but there could be other 
combinations.  The problem here is that the update coming through the 
inference graph can not be directed to the right place.  Which graph in 
a union should be updated? Jena's union graph have one distinguished 
graph to update (base data and inference deductions) but when using 
named graphs for data management there isn't a distinguished single 
place to pass on the updates to.

Currently, it is possible to intercept every update (see 
DatasetGraphMonitor). This is how RDF Delta works; there's a class 
called DatasetGraphChanges that logs every change and also hook itself 
into the transaction lifecycle so changes are batched into transactions.

For inference, I've been asking what level of inference people are 
really using. We could have a stateless RDFS-class reasoner that sits on 
any graph/dataset and always goes back to the base data. No, or very 
short term, caching.

That would be less capable, and slower (but how much? not much in 
practice?) but it will scale, will fit with transactions and data 
visibility, and will see changes in the data as they occur.

Another case is eTags which would help query caching. This is a simpler 
test - adding a monitoring wrapper to a dataset is a rather heavy and 
inflexible way to do it.  Wrapping (layering) is all very well until the 
order matters and two different wrappers want to be "first".

Knowing the generation of the data seems to me at the moment to be worth 
adding to the dataset interface itself. A simple "what version am I 
looking at?" method. It could be a counter (sequential) or give every 
write transaction a UUID and be able to fetch the generation of the data 
the current read transaction is acting on.

     Andy

> 
> Any comments are welcome.
> 
> Nicola
> 
> On 2020/04/29 08:08:43, Andy Seaborne <an...@apache.org> wrote:
>> Sascha,
>>
>> (aside)
>> For my general understanding:
>> What level of reasoning are you and your student interested in having?
>>
>> There is a tradeoff between inference expressiveness, performance (CPU
>> and RAM costs), how much development effect it would take for future
>> improvements.
>>
>> On 29/04/2020 08:18, Meckler, Sascha wrote:
>>> Hello Andy and Marco,
>>>
>>> the problem also applies to built-in reasoners.
>>> I tried Jena's OWLFBRuleReasoner, OWLMicroFBRuleReasoner and the RDFSExptRuleReasoner.
>>> (See demo project: https://github.com/smeckler/inference-demo/blob/master/src/main/resources/fuseki/config.ttl)
>>
>> Each of which has some forward rules.
>>
>> If you want to update the inference graph, send updates to the inference
>> graph.
>>
>>       Andy
>>
>>>
>>> Thank you for your help!
>>> Best regards,
>>> Sascha
>>>
>>>
>>>> -----Original Message-----
>>>> From: Marco Neumann <ma...@gmail.com>
>>>> Sent: Tuesday, April 28, 2020 7:12 PM
>>>> To: users@jena.apache.org
>>>> Subject: Re: Fuseki inference not triggered with incoming data
>>>>
>>>> so Sascha in short try to use one of the Jena build-in reasoners if this is
>>>> not bound to a pellet specific task. if it is you will have to bring this
>>>> request up with the pellet maintainers.
>>>>
>>>> On Tue, Apr 28, 2020 at 5:20 PM Andy Seaborne <an...@apache.org> wrote:
>>>>
>>>>>
>>>>>
>>>>> On 27/04/2020 09:49, Meckler, Sascha wrote:
>>>>>> Hi *,
>>>>>> I have a question about Fuseki:
>>>>>>
>>>>>> We have a Fuseki server with one dataset for actual data and one dataset
>>>>> with reasoning based on the default union graph (=data from first dataset).
>>>>> When I insert new data into the first dataset, the inference is not always
>>>>> triggered. The reasoning dataset updates only at the first time or when
>>>>> restarting. How can we configurate Fuseki to run the inference every time
>>>>> that new data is inserted into the first dataset? Or is there a better way
>>>>> to do this?
>>>>>
>>>>> For forward rules, I think that the data updates have to go through the
>>>>> graph with the inference.  Forward rules keep state so if you bypass
>>>>> inference the graph, the state does not get updated.
>>>>>
>>>>> Backwards rules may notice to some extent - I'm unsure of the details here.
>>>>>
>>>>> Pellet isn't part of the Apache Jena project.
>>>>>
>>>>>        Andy
>>>>>
>>>>>>
>>>>>> I created a small demo project with an easy example and additional
>>>>> documentation [1]. My student asked on StackOverflow [2] in January but
>>>>> there was no answer.
>>>>>>
>>>>>> Thank you very much for your help!
>>>>>> Best regards,
>>>>>> Sascha
>>>>>>
>>>>>> [1] https://github.com/smeckler/inference-demo
>>>>>> [2]
>>>>> https://stackoverflow.com/questions/59952945/reasoning-in-apache-jena-
>>>> fuseki-reload-dataset-or-trigger-inference
>>>>>>
>>>>>> ______________________________________________________
>>>>>> Sascha Meckler
>>>>>> Data Spaces and IoT Solutions
>>>>>>
>>>>>> Fraunhofer-Institut für Integrierte Schaltungen
>>>>>
>>>> <https://www.google.com/maps/search/tut+f%C3%BCr+Integrierte+Schaltun
>>>> gen?entry=gmail&source=g>
>>>>> IIS
>>>>>> Nordostpark 93 | 90411 Nürnberg
>>>>>>
>>>>>> Phone +49 911 58061-9614
>>>>>>
>>>>>>
>>>>>
>>>> --
>>>>
>>>>
>>>> ---
>>>> Marco Neumann
>>>> KONA
>>

Re: Fuseki inference not triggered with incoming data

Posted by Nicola Vitucci <ni...@gmail.com>.
Hi all,

I am writing a blog post on this very subject (adding reasoning capabilities to Fuseki datasets and more) and I got a similar behaviour when updating a named graph. I've also used all the supported reasoners.

My solution is kind of intermediate: creating an RDFDataset with a default graph that reasons on the special union graph, then several named graphs containing my data, each one with its (named) inference graph. In this way it's possible to add triples to the named inference graphs (as Andy suggested too) and have them reasoned upon in real time, plus the default graph can reason cross-graph (but it can only be updated with a restart anyway). I know it's not ideal, but it can probably get what you need. I'll add more details as I put things together.

@Andy: it would be nice if a dataset "reload" was supported via API as the change of state (active/offline) is. Any thoughts on this?

Any comments are welcome.

Nicola

On 2020/04/29 08:08:43, Andy Seaborne <an...@apache.org> wrote: 
> Sascha,
> 
> (aside)
> For my general understanding:
> What level of reasoning are you and your student interested in having?
> 
> There is a tradeoff between inference expressiveness, performance (CPU 
> and RAM costs), how much development effect it would take for future 
> improvements.
> 
> On 29/04/2020 08:18, Meckler, Sascha wrote:
> > Hello Andy and Marco,
> > 
> > the problem also applies to built-in reasoners.
> > I tried Jena's OWLFBRuleReasoner, OWLMicroFBRuleReasoner and the RDFSExptRuleReasoner.
> > (See demo project: https://github.com/smeckler/inference-demo/blob/master/src/main/resources/fuseki/config.ttl)
> 
> Each of which has some forward rules.
> 
> If you want to update the inference graph, send updates to the inference 
> graph.
> 
>      Andy
> 
> > 
> > Thank you for your help!
> > Best regards,
> > Sascha
> > 
> > 
> >> -----Original Message-----
> >> From: Marco Neumann <ma...@gmail.com>
> >> Sent: Tuesday, April 28, 2020 7:12 PM
> >> To: users@jena.apache.org
> >> Subject: Re: Fuseki inference not triggered with incoming data
> >>
> >> so Sascha in short try to use one of the Jena build-in reasoners if this is
> >> not bound to a pellet specific task. if it is you will have to bring this
> >> request up with the pellet maintainers.
> >>
> >> On Tue, Apr 28, 2020 at 5:20 PM Andy Seaborne <an...@apache.org> wrote:
> >>
> >>>
> >>>
> >>> On 27/04/2020 09:49, Meckler, Sascha wrote:
> >>>> Hi *,
> >>>> I have a question about Fuseki:
> >>>>
> >>>> We have a Fuseki server with one dataset for actual data and one dataset
> >>> with reasoning based on the default union graph (=data from first dataset).
> >>> When I insert new data into the first dataset, the inference is not always
> >>> triggered. The reasoning dataset updates only at the first time or when
> >>> restarting. How can we configurate Fuseki to run the inference every time
> >>> that new data is inserted into the first dataset? Or is there a better way
> >>> to do this?
> >>>
> >>> For forward rules, I think that the data updates have to go through the
> >>> graph with the inference.  Forward rules keep state so if you bypass
> >>> inference the graph, the state does not get updated.
> >>>
> >>> Backwards rules may notice to some extent - I'm unsure of the details here.
> >>>
> >>> Pellet isn't part of the Apache Jena project.
> >>>
> >>>       Andy
> >>>
> >>>>
> >>>> I created a small demo project with an easy example and additional
> >>> documentation [1]. My student asked on StackOverflow [2] in January but
> >>> there was no answer.
> >>>>
> >>>> Thank you very much for your help!
> >>>> Best regards,
> >>>> Sascha
> >>>>
> >>>> [1] https://github.com/smeckler/inference-demo
> >>>> [2]
> >>> https://stackoverflow.com/questions/59952945/reasoning-in-apache-jena-
> >> fuseki-reload-dataset-or-trigger-inference
> >>>>
> >>>> ______________________________________________________
> >>>> Sascha Meckler
> >>>> Data Spaces and IoT Solutions
> >>>>
> >>>> Fraunhofer-Institut für Integrierte Schaltungen
> >>>
> >> <https://www.google.com/maps/search/tut+f%C3%BCr+Integrierte+Schaltun
> >> gen?entry=gmail&source=g>
> >>> IIS
> >>>> Nordostpark 93 | 90411 Nürnberg
> >>>>
> >>>> Phone +49 911 58061-9614
> >>>>
> >>>>
> >>>
> >> --
> >>
> >>
> >> ---
> >> Marco Neumann
> >> KONA
> 

Re: Fuseki inference not triggered with incoming data

Posted by Andy Seaborne <an...@apache.org>.
Sascha,

(aside)
For my general understanding:
What level of reasoning are you and your student interested in having?

There is a tradeoff between inference expressiveness, performance (CPU 
and RAM costs), how much development effect it would take for future 
improvements.

On 29/04/2020 08:18, Meckler, Sascha wrote:
> Hello Andy and Marco,
> 
> the problem also applies to built-in reasoners.
> I tried Jena's OWLFBRuleReasoner, OWLMicroFBRuleReasoner and the RDFSExptRuleReasoner.
> (See demo project: https://github.com/smeckler/inference-demo/blob/master/src/main/resources/fuseki/config.ttl)

Each of which has some forward rules.

If you want to update the inference graph, send updates to the inference 
graph.

     Andy

> 
> Thank you for your help!
> Best regards,
> Sascha
> 
> 
>> -----Original Message-----
>> From: Marco Neumann <ma...@gmail.com>
>> Sent: Tuesday, April 28, 2020 7:12 PM
>> To: users@jena.apache.org
>> Subject: Re: Fuseki inference not triggered with incoming data
>>
>> so Sascha in short try to use one of the Jena build-in reasoners if this is
>> not bound to a pellet specific task. if it is you will have to bring this
>> request up with the pellet maintainers.
>>
>> On Tue, Apr 28, 2020 at 5:20 PM Andy Seaborne <an...@apache.org> wrote:
>>
>>>
>>>
>>> On 27/04/2020 09:49, Meckler, Sascha wrote:
>>>> Hi *,
>>>> I have a question about Fuseki:
>>>>
>>>> We have a Fuseki server with one dataset for actual data and one dataset
>>> with reasoning based on the default union graph (=data from first dataset).
>>> When I insert new data into the first dataset, the inference is not always
>>> triggered. The reasoning dataset updates only at the first time or when
>>> restarting. How can we configurate Fuseki to run the inference every time
>>> that new data is inserted into the first dataset? Or is there a better way
>>> to do this?
>>>
>>> For forward rules, I think that the data updates have to go through the
>>> graph with the inference.  Forward rules keep state so if you bypass
>>> inference the graph, the state does not get updated.
>>>
>>> Backwards rules may notice to some extent - I'm unsure of the details here.
>>>
>>> Pellet isn't part of the Apache Jena project.
>>>
>>>       Andy
>>>
>>>>
>>>> I created a small demo project with an easy example and additional
>>> documentation [1]. My student asked on StackOverflow [2] in January but
>>> there was no answer.
>>>>
>>>> Thank you very much for your help!
>>>> Best regards,
>>>> Sascha
>>>>
>>>> [1] https://github.com/smeckler/inference-demo
>>>> [2]
>>> https://stackoverflow.com/questions/59952945/reasoning-in-apache-jena-
>> fuseki-reload-dataset-or-trigger-inference
>>>>
>>>> ______________________________________________________
>>>> Sascha Meckler
>>>> Data Spaces and IoT Solutions
>>>>
>>>> Fraunhofer-Institut für Integrierte Schaltungen
>>>
>> <https://www.google.com/maps/search/tut+f%C3%BCr+Integrierte+Schaltun
>> gen?entry=gmail&source=g>
>>> IIS
>>>> Nordostpark 93 | 90411 Nürnberg
>>>>
>>>> Phone +49 911 58061-9614
>>>>
>>>>
>>>
>> --
>>
>>
>> ---
>> Marco Neumann
>> KONA

RE: Fuseki inference not triggered with incoming data

Posted by "Meckler, Sascha" <sa...@iis.fraunhofer.de>.
Hello Andy and Marco,

the problem also applies to built-in reasoners. 
I tried Jena's OWLFBRuleReasoner, OWLMicroFBRuleReasoner and the RDFSExptRuleReasoner.
(See demo project: https://github.com/smeckler/inference-demo/blob/master/src/main/resources/fuseki/config.ttl)

Thank you for your help!
Best regards,
Sascha


>-----Original Message-----
>From: Marco Neumann <ma...@gmail.com>
>Sent: Tuesday, April 28, 2020 7:12 PM
>To: users@jena.apache.org
>Subject: Re: Fuseki inference not triggered with incoming data
>
>so Sascha in short try to use one of the Jena build-in reasoners if this is
>not bound to a pellet specific task. if it is you will have to bring this
>request up with the pellet maintainers.
>
>On Tue, Apr 28, 2020 at 5:20 PM Andy Seaborne <an...@apache.org> wrote:
>
>>
>>
>> On 27/04/2020 09:49, Meckler, Sascha wrote:
>> > Hi *,
>> > I have a question about Fuseki:
>> >
>> > We have a Fuseki server with one dataset for actual data and one dataset
>> with reasoning based on the default union graph (=data from first dataset).
>> When I insert new data into the first dataset, the inference is not always
>> triggered. The reasoning dataset updates only at the first time or when
>> restarting. How can we configurate Fuseki to run the inference every time
>> that new data is inserted into the first dataset? Or is there a better way
>> to do this?
>>
>> For forward rules, I think that the data updates have to go through the
>> graph with the inference.  Forward rules keep state so if you bypass
>> inference the graph, the state does not get updated.
>>
>> Backwards rules may notice to some extent - I'm unsure of the details here.
>>
>> Pellet isn't part of the Apache Jena project.
>>
>>      Andy
>>
>> >
>> > I created a small demo project with an easy example and additional
>> documentation [1]. My student asked on StackOverflow [2] in January but
>> there was no answer.
>> >
>> > Thank you very much for your help!
>> > Best regards,
>> > Sascha
>> >
>> > [1] https://github.com/smeckler/inference-demo
>> > [2]
>> https://stackoverflow.com/questions/59952945/reasoning-in-apache-jena-
>fuseki-reload-dataset-or-trigger-inference
>> >
>> > ______________________________________________________
>> > Sascha Meckler
>> > Data Spaces and IoT Solutions
>> >
>> > Fraunhofer-Institut für Integrierte Schaltungen
>>
><https://www.google.com/maps/search/tut+f%C3%BCr+Integrierte+Schaltun
>gen?entry=gmail&source=g>
>> IIS
>> > Nordostpark 93 | 90411 Nürnberg
>> >
>> > Phone +49 911 58061-9614
>> >
>> >
>>
>--
>
>
>---
>Marco Neumann
>KONA

Re: Fuseki inference not triggered with incoming data

Posted by Marco Neumann <ma...@gmail.com>.
so Sascha in short try to use one of the Jena build-in reasoners if this is
not bound to a pellet specific task. if it is you will have to bring this
request up with the pellet maintainers.

On Tue, Apr 28, 2020 at 5:20 PM Andy Seaborne <an...@apache.org> wrote:

>
>
> On 27/04/2020 09:49, Meckler, Sascha wrote:
> > Hi *,
> > I have a question about Fuseki:
> >
> > We have a Fuseki server with one dataset for actual data and one dataset
> with reasoning based on the default union graph (=data from first dataset).
> When I insert new data into the first dataset, the inference is not always
> triggered. The reasoning dataset updates only at the first time or when
> restarting. How can we configurate Fuseki to run the inference every time
> that new data is inserted into the first dataset? Or is there a better way
> to do this?
>
> For forward rules, I think that the data updates have to go through the
> graph with the inference.  Forward rules keep state so if you bypass
> inference the graph, the state does not get updated.
>
> Backwards rules may notice to some extent - I'm unsure of the details here.
>
> Pellet isn't part of the Apache Jena project.
>
>      Andy
>
> >
> > I created a small demo project with an easy example and additional
> documentation [1]. My student asked on StackOverflow [2] in January but
> there was no answer.
> >
> > Thank you very much for your help!
> > Best regards,
> > Sascha
> >
> > [1] https://github.com/smeckler/inference-demo
> > [2]
> https://stackoverflow.com/questions/59952945/reasoning-in-apache-jena-fuseki-reload-dataset-or-trigger-inference
> >
> > ______________________________________________________
> > Sascha Meckler
> > Data Spaces and IoT Solutions
> >
> > Fraunhofer-Institut für Integrierte Schaltungen
> <https://www.google.com/maps/search/tut+f%C3%BCr+Integrierte+Schaltungen?entry=gmail&source=g>
> IIS
> > Nordostpark 93 | 90411 Nürnberg
> >
> > Phone +49 911 58061-9614
> >
> >
>
-- 


---
Marco Neumann
KONA

Re: Fuseki inference not triggered with incoming data

Posted by Andy Seaborne <an...@apache.org>.

On 27/04/2020 09:49, Meckler, Sascha wrote:
> Hi *,
> I have a question about Fuseki:
> 
> We have a Fuseki server with one dataset for actual data and one dataset with reasoning based on the default union graph (=data from first dataset). When I insert new data into the first dataset, the inference is not always triggered. The reasoning dataset updates only at the first time or when restarting. How can we configurate Fuseki to run the inference every time that new data is inserted into the first dataset? Or is there a better way to do this?

For forward rules, I think that the data updates have to go through the 
graph with the inference.  Forward rules keep state so if you bypass 
inference the graph, the state does not get updated.

Backwards rules may notice to some extent - I'm unsure of the details here.

Pellet isn't part of the Apache Jena project.

     Andy

> 
> I created a small demo project with an easy example and additional documentation [1]. My student asked on StackOverflow [2] in January but there was no answer.
> 
> Thank you very much for your help!
> Best regards,
> Sascha
> 
> [1] https://github.com/smeckler/inference-demo
> [2] https://stackoverflow.com/questions/59952945/reasoning-in-apache-jena-fuseki-reload-dataset-or-trigger-inference
> 
> ______________________________________________________
> Sascha Meckler
> Data Spaces and IoT Solutions
> 
> Fraunhofer-Institut für Integrierte Schaltungen IIS
> Nordostpark 93 | 90411 Nürnberg
> 
> Phone +49 911 58061-9614
> 
>