Reasoning doesn't work from python application

I tried to run the following query from the python application.
Query: conn.select('PREFIX rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#
PREFIX owl: http://www.w3.org/2002/07/owl#
PREFIX rdfs: http://www.w3.org/2000/01/rdf-schema#
PREFIX xsd: http://www.w3.org/2001/XMLSchema#
PREFIX MDRS: http://www.MRDS.com#
ASK { ?phone a MDRS:Apple_Lover.}', content_type='application/sparql-results+json', reasoning=True)
Return in Python application: {'head': {}, 'boolean': False}
In browser:


It is returning true in the browser.

Hi,

What version of both Stardog and pystardog are you running? The fact that you're using webconsole in the browser points to your Stardog being at least one major release behind, which could potentially explain what you're seeing. I am unable both to reproduce your error and to run the command you provided in the latest pystardog release:

>>> query = """PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
... PREFIX owl: <http://www.w3.org/2002/07/owl#>
... PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
... PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
... PREFIX MDRS: <http://www.MRDS.com#>
... ASK { ?phone a MDRS:Apple_Lover.}"""
>>> conn.ask(query)
False
>>> conn.ask(query, reasoning=True)
True
>>> conn.ask(query, content_type='application/sparql-results+json', reasoning=True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/stephen/.pyenv/versions/3.8.5/lib/python3.8/site-packages/stardog/connection.py", line 331, in ask
    r = self.conn.query(query, self.transaction, content_types.BOOLEAN,
TypeError: query() got multiple values for argument 'content_type'

stardog version was Stardog Version: 6.0.1.
pystardog version is expected to be 0.9.7 since i installed with pip.
I tried again after updating the stardog version to 7 and it works fine now in python application but i can't connect from browser and showing this after logging in with the admin account.
Thank you so much.

This is because we deprecated the web console in Stardog 7. As a replacement you can either download Stardog Studio or use the in-browser version by going to http://stardog.studio

Okay. Thank you so much for fast and easy-to-follow reply. Really appreciate ur effort and time. :smile:

One final question. Why reasoning doesn't work unless u load the data again into the database with the two lines
conn.add(stardog.content.File('./data/mdrs.owl'))
conn.commit()
before running the query?
The query returns when i added the two lines but no result when i don't add this two lines even thought the data is loaded. It doesn't make sense to me that I need to load the data again and again even thought there is no changes.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.