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

Broken examples #165

Open
DougalW opened this issue Jul 6, 2022 · 9 comments
Open

Broken examples #165

DougalW opened this issue Jul 6, 2022 · 9 comments
Labels
bug Something isn't working

Comments

@DougalW
Copy link

DougalW commented Jul 6, 2022

Hi

The DBPedia Music example is now broken - it returns this error if I search for the Beatles

2022-07-06 07:14:49,310 - werkzeug - INFO - 172.17.0.1 - - [06/Jul/2022 07:14:49] "GET /v1.3.0/bands?label=Beatles&page=1&per_page=100 HTTP/1.1" 200 -
2022-07-06 07:15:11,329 - oba - INFO - #+ summary: Return the query to a resource by the resource_iri
PREFIX rdfs: http://www.w3.org/2000/01/rdf-schema#
CONSTRUCT {
http://dbpedia.org/resource/beatles ?predicate ?prop .
?prop a ?type .
?prop rdfs:label ?label
}
WHERE {
http://dbpedia.org/resource/beatles ?predicate ?prop
OPTIONAL {
?prop a ?type
OPTIONAL {
?prop rdfs:label ?label
}
}
}
2022-07-06 07:16:20,671 - grlc - ERROR - json serialize failed
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/obasparql/query_manager.py", line 455, in frame_results
response_dict = json.loads(response)
File "/usr/local/lib/python3.10/json/init.py", line 339, in loads
raise TypeError(f'the JSON object must be str, bytes or bytearray, '
TypeError: the JSON object must be str, bytes or bytearray, not tuple
2022-07-06 07:16:20,672 - werkzeug - INFO - 172.17.0.1 - - [06/Jul/2022 07:16:20] "GET /v1.3.0/bands/beatles HTTP/1.1" 200 -

Also Model Catalog fails to generate an OpenAPI server docker image.

cheers

Dougal

@dgarijo dgarijo added the bug Something isn't working label Jul 6, 2022
@dgarijo
Copy link
Contributor

dgarijo commented Jul 6, 2022

I will have a look when I have the chance. At least the generation of the API should work. The server generation is a little more tricky, with a lot of changing dependencies.

@DougalW
Copy link
Author

DougalW commented Jul 6, 2022

Thanks. The API generation works fine.

@DougalW
Copy link
Author

DougalW commented Jul 6, 2022

Another quick question egarding the design of OBA and how it constructs paths and queries on those paths.... (I sent you an email a few minutes ago but not sure if you're at that address any more)

When OBA generates the openapi.yaml file, are these query parameters (in bold below) reserved words?

paths:
/accountcategorys:
get:
description: Gets a list of all instances of AccountCategory (more information
in https://businessontology.com/ontology/AccountCategory)
parameters:
- description: Filter by label
in: query
name: label
required: false
schema:
type: string
- description: Page number
in: query
name: page
required: false
schema:
default: 1
format: int32
type: integer
- description: Items per page
in: query
name: per_page
required: false
schema:
default: 100
format: int32
maximum: 200
minimum: 1
type: integer

It sort of looks like ‘label’ corresponds to rdfs:label class annotations, but I want to be able to query on skos:label so how would I set that?

Also, how would I construct an API that can query based on the name of an instance? e.g. I have an instance _creditcard123213213 a creditcard so I want to be able to search on the actual name of the instance.

@dgarijo
Copy link
Contributor

dgarijo commented Jul 6, 2022

Hello,
yes, from what I remember these are reserved words.

To query on skos labels, you would have to modify the get_one.rq and get_one_user.rq files to expand rdfs:label with skos:label
For the credit card case, I think the easiest way forward is to add a label with the name, so you can reuse the existing API calls.

@DougalW
Copy link
Author

DougalW commented Jul 6, 2022

Thanks for your reply.

Another quick question - reading through Rhys commit: 6686b8c

The query manager has been updated to use ' named_graph_base=ENDPOINT_GRAPH_BASE' instead of the old 'graph_base=ENDPOINT_GRAPH_BASE'

Does this mean that for graph databases using a named graph, that the config.yaml file should now use the Endpoint option like this?

endpoint:
url: http://localhost:7200/sparql
prefix: https://www.mygraph.org/
named_graph_base: http://www.mygraph.org/data/

@dgarijo
Copy link
Contributor

dgarijo commented Jul 6, 2022

It looks like it's how you are suggesting. However, I haven't run OBA for a while. Maybe @mosoriob knows better these options (I know best the mapping part)

@DougalW
Copy link
Author

DougalW commented Jul 7, 2022

Thanks Daniel. BTW, is there an option to turn on detailed logging in OBA to see submitted URL's?

I'm trying to access GraphDB at this endpoint address:

endpoint:
url: http://localhost:7200/repositories/test
prefix: https://businessontology.com/ontology
graph_base: https://businessontology.com/ontology

But when I submit something in my OBA generated API it returns this error:

2022-07-07 01:59:53,387 - oba - INFO - #+ summary: Given a rdf type, returns all the resources related to the type
CONSTRUCT {
?item ?predicate ?prop .
?prop a ?type
}
WHERE {
GRAPH https://businessontology.com/ontology/None {
{
SELECT DISTINCT ?item where {
?item a https://businessontology.com/ontology/AccountCategory .
}
LIMIT 100
OFFSET 0
}
?item ?predicate ?prop
OPTIONAL {
?prop a ?type
}
}
}
2022-07-07 01:59:53,387 - oba - ERROR - <urlopen error [Errno 99] Address not available>
Traceback (most recent call last):
File "/usr/local/lib/python3.10/urllib/request.py", line 1348, in do_open
h.request(req.get_method(), req.selector, req.data, headers,
File "/usr/local/lib/python3.10/http/client.py", line 1282, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/local/lib/python3.10/http/client.py", line 1328, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/local/lib/python3.10/http/client.py", line 1277, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/local/lib/python3.10/http/client.py", line 1037, in _send_output
self.send(msg)
File "/usr/local/lib/python3.10/http/client.py", line 975, in send
self.connect()
File "/usr/local/lib/python3.10/http/client.py", line 941, in connect
self.sock = self._create_connection(
File "/usr/local/lib/python3.10/socket.py", line 845, in create_connection
raise err
File "/usr/local/lib/python3.10/socket.py", line 833, in create_connection
sock.connect(sa)
OSError: [Errno 99] Address not available

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/obasparql/query_manager.py", line 286, in request_all
return self.obtain_query(query_directory=owl_class_name,
File "/usr/local/lib/python3.10/site-packages/obasparql/query_manager.py", line 422, in obtain_query
raise e
File "/usr/local/lib/python3.10/site-packages/obasparql/query_manager.py", line 419, in obtain_query
result = self.dispatch_sparql_query(
File "/usr/local/lib/python3.10/site-packages/obasparql/query_manager.py", line 784, in dispatch_sparql_query
return self.sparql.query(rewritten_query)
File "/usr/local/lib/python3.10/site-packages/obasparql/sparqlconnector.py", line 115, in query
res = urlopen(
File "/usr/local/lib/python3.10/urllib/request.py", line 216, in urlopen
return opener.open(url, data, timeout)
File "/usr/local/lib/python3.10/urllib/request.py", line 519, in open
response = self._open(req, data)
File "/usr/local/lib/python3.10/urllib/request.py", line 536, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
File "/usr/local/lib/python3.10/urllib/request.py", line 496, in _call_chain
result = func(*args)
File "/usr/local/lib/python3.10/urllib/request.py", line 1377, in http_open
return self.do_open(http.client.HTTPConnection, req)
File "/usr/local/lib/python3.10/urllib/request.py", line 1351, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 99] Address not available>
2022-07-07 01:59:53,388 - werkzeug - INFO - 172.17.0.1 - - [07/Jul/2022 01:59:53] "GET /accountcategorys?label=account123&page=1&per_page=100 HTTP/1.1" 500 -

@dgarijo
Copy link
Contributor

dgarijo commented Jul 7, 2022

Hmm, I do not think so, as far as I remember. We do have logging, but I don't think we enabled detailed logging :(

@DougalW
Copy link
Author

DougalW commented Jul 10, 2022

Hi - this issue

I will have a look when I have the chance. At least the generation of the API should work. The server generation is a little more tricky, with a lot of changing dependencies.

This seems to be caused in OBA Sparql Query Manager not handling the JSON-LD @content processing correctly for payloads returned from a graph in JSON-LD Expanded format. I've raised an issue in KnowledgeCaptureAndDiscovery/OBA_sparql#43

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants