Python module to query triples from the OMNIBENCHMARK triplestore.
Project description
omniSPARQL
omniSparql is a python module to query triples from the OMNIBENCHMARK triplestore. Its main usage is to retrieve lineage information in an OMNIBENCHMARK (see the lineage query file of summary metric projects).
Usage
Minimal usage
The typical use of omniSparql consists in forming a SPARQL based on your need and running it on your triplestore URL:
import omniSparql as omni
## get a query
query = omni.getSparqlQuery.CLASS_METHOD
## run the query
out = omni.query_from_sparql(query, URL = TRIPLESTORE_URL)
Detailled usage
Let's start by getting a query. Several SPARQL queries are available in the getSparqlQuery class, which you can explore with the help page of the page;
import omniSparql as omni
help(omni.getSparqlQuery)
Help on class getSparqlQuery in module omniSparql.sparql:
class getSparqlQuery(builtins.object)
| Available SPARQL queries. One or multiple input to define when called.
|
| Returns:
| A string which contains a SPARQL command to use with `query_from_sparql`.
|
| Methods defined here:
[...]
| imported_datasets_from_project(project_name)
| Retrieves all datasets imported by a project.
|
| Args:
| project_name (str): abbreviated name of the project, e.g. 'omni_batch_processed'
| Returns:
| `query`: the query, `project_name`
| `full_name`: project full name
| `short_name`: project short name
| `keyword`: keyword associated to the dataset
| `creator`: the mail of the author of the dataset
| `dateCreated`
| `descr`: decription of the dataset
| `originID`: ID of dataset
[...]
As an example, we can select the query showed above; imported_datasets_from_project and store it for the next step. As explained in the class method documentation, this function helps to identify which renku datasets were imported by a project, only by providing its name. Let's use it to query all datasets imported by one of the iris omnibenchmark; iris_accuracy metric project.
Prepare the query:
q = omni.getSparqlQuery.imported_datasets_from_project(project_name='iris_accuracy')
q
"\n PREFIX ns1:<http://www.w3.org/ns/prov#>\n PREFIX ns2:<https://swissdatasciencecenter.github.io/renku-ontology#>\n PREFIX ns3 [...]"
The output of any SPARQL query from getSparqlQuery can be used to query a specified triplestore with the query_from_sparql function (you can ask the URL of your benchmark by contacting the dev team)-
out = omni.query_from_sparql(q, URL = "http://imlspenticton.uzh.ch/omni_iris_sparql")
All queries typically return a dictionary or a list of dictionaries with fields describing your output. In this case, the function retrieves the following information about the datasets imported by the specified project:
out[0].keys()
> dict_keys(['query', 'full_name', 'short_name', 'keyword', 'creator', 'dateCreated', 'descr', 'originID'])
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file omniSparql-0.0.3.tar.gz.
File metadata
- Download URL: omniSparql-0.0.3.tar.gz
- Upload date:
- Size: 16.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
26e3887b8d55329a78127491664a8ec728ebdafdbb0aa24101115ed8815c053b
|
|
| MD5 |
8523caee644cd6a15fe7f1d31c32c321
|
|
| BLAKE2b-256 |
70255ee1057a1302ec9574ca961fde68183e2bd15dd2c71b9d000437db31f33e
|
File details
Details for the file omniSparql-0.0.3-py3-none-any.whl.
File metadata
- Download URL: omniSparql-0.0.3-py3-none-any.whl
- Upload date:
- Size: 12.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
297e75c171399bb650cb32028ae7bb6c6c333af6d924ac5b9dd10ccbb3984127
|
|
| MD5 |
72e53284ba4ac63baf131fed31a1dae0
|
|
| BLAKE2b-256 |
2f543b3b67d2f7988cd4ee17178d2845a70a51861bda2b95811c643f04a3fb33
|