Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
4ea729a
Add criteria with no object
francescalb Sep 16, 2025
b62fba7
None in key for criteria
francescalb Sep 16, 2025
d5cb073
Only None accepted as wildcard in search.
francescalb Sep 17, 2025
609acb4
Added option for adding critiera as tuples
francescalb Sep 18, 2025
3526b23
Removed helper function which is not used
francescalb Sep 18, 2025
448be17
Merge branch 'master' into flb/partially_defined_criteria
francescalb Sep 26, 2025
3a1813c
Corrected sorting of tuples with None
francescalb Sep 26, 2025
a985c81
Added test that shows errors in dataset
francescalb Sep 26, 2025
e8c6e76
Added substitute_query() function
jesper-friis Sep 28, 2025
b534768
Update tripper/triplestore.py
jesper-friis Sep 28, 2025
0739fb3
Merge branch 'flb/partially_defined_criteria' into wildcard-search
jesper-friis Sep 28, 2025
3957b8f
Improved warning message
jesper-friis Sep 28, 2025
77f5b64
Added available() method and `check_url` to argument to Triplestore
jesper-friis Sep 28, 2025
bbcc377
Added documentation to session.yaml
jesper-friis Sep 28, 2025
6e7d767
Updated documentation
jesper-friis Sep 28, 2025
cf3c77d
Added argument annotations
jesper-friis Sep 28, 2025
f5b4dda
Merge branch 'check-url' into wildcard-search
jesper-friis Sep 28, 2025
f318c65
Use session to configure test backends
jesper-friis Sep 28, 2025
9dddfb3
Remove documentation of non-existing argument
jesper-friis Sep 28, 2025
36ca3f5
Added test
jesper-friis Sep 28, 2025
7a9e76a
Merge branch 'check-url' into wildcard-search
jesper-friis Sep 28, 2025
865b374
[pre-commit.ci] auto fixes from pre-commit hooks
pre-commit-ci[bot] Sep 29, 2025
5e95c18
Added iriquote argument
jesper-friis Sep 29, 2025
d344d42
Merge branch 'substitute_query' into wildcard-search
jesper-friis Sep 29, 2025
e8b5b48
Merge branch 'wildcard-search' of github.com:EMMC-ASBL/tripper into w…
jesper-friis Sep 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions docs/developers.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@

See [interface.py], which defines the interface of a backend and may serve as a template for creating new backends.

### Developing the sparqlwrapper

## Setting up local GraphDB and Fuseki services for testing
Tripper comes with an inbuilt backend to the SPARQLWrapper. In order
to test this properly a real triplestore is needed. This is not done in the
automatic workflows on github. However, a local graphDB can be setup as described below and tested with test_sparqlwrapper_graphdb.py.
automatic workflows on github. However, local graphDB and Fuseki services
can be setup as described below and tested with
`tests/backends/test_sparqlwrapper_graphdb_fuseki.py`.

The backend configurations corresponding to the local GraphDB and Fuseki services
can be found in `[tests/input/session.yaml]`.


### Setting up GraphDB service
To create the local instance of graphdb:
```bash
docker pull ontotext/graphdb:10.8.3 # latest tag 17.02.2025
Expand All @@ -30,14 +37,15 @@ You can now run the test test_sparqlwrapper_graphdb_fuseki.py with graphdb.
Note that if the graphdb instance is not found the test will just be skipped.


### Setting up Fuseki service
Similarly a jena-fuseki instance can be tested locally as follows:

```bash
docker pull stain/jena-fuseki
docker run -d --name fuseki -p 3030:3030 -e ADMIN_PASSWORD=admin0 -e=FUSEKI_DATASET_1=test_repo stain/jena-fuseki
```

You can now run the test test_sparqlwrapper_graphdb_fuseki.py with fuseki.
You can now run the test `test_sparqlwrapper_graphdb_fuseki.py` with fuseki.

Note that if the fuseki instance is not found the test will just be skipped.

Expand Down Expand Up @@ -75,3 +83,4 @@ Then open http://127.0.0.1:8000/tripper/ in your browser.

[interface.py]: https://github.com/EMMC-ASBL/tripper/blob/master/tripper/interface.py
[mkdocs]: https://www.mkdocs.org/
[tests/input/session.yaml]: https://github.com/EMMC-ASBL/tripper/blob/master/tests/input/session.yaml)
23 changes: 18 additions & 5 deletions docs/session.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,47 @@ The default location of this configuration file depends on the system:
- Windows: `$HOME/AppData/Local/tripper/Config/session.yaml`
- Darwin: `$HOME/Library/Config/tripper/session.yaml`

Add some default
The schema of the YAML file is simple.
A session should have a name that identifies it and should be followed by keyword arguments accepted by the `Triplestore` constructor.

Here is an example of a possible session file:

```
---

RdflibTest:
backend: rdflib

GraphDBTest:
backend: sparqlwrapper
base_iri: http://localhost:7200/repositories/test_repo
update_iri: http://localhost:7200/repositories/test_repo/statements
check_url: http://localhost:7200/repositories

FusekiTest:
backend: sparqlwrapper
base_iri: http://localhost:3030/test_repo
update_iri: http://localhost:3030/test_repo/update
check_url: http://localhost:3030
username: admin
password: admin0

MyKB:
backend: sparqlwrapper
base_iri: https://graphdb.myproject.eu/repositories/test_repo
update_iri: https://graphdb.myproject.eu/repositories/test_repo/statements
check_url: https://graphdb.myproject.eu/repositories
username: myname
password: KEYRING
```

The two first entries correspond to the GraphDB and Fuseki services
that can be started with docker as described in the [developers]
section.
The first entry is an in-memory rdflib backend.

The second and third entries correspond to GraphDB and Fuseki services,
respectively.
These can be started with docker as described in the [developers] section.

The third entry is just a dummy example, showing how to use [keyring].
The fourth entry is just a dummy example, showing how to use [keyring].

Each entry starts with the name identifying the configured triplestore.
The keywords following it, correspond to the keyword arguments passed to the
Expand Down
78 changes: 21 additions & 57 deletions tests/backends/test_sparqlwrapper_graphdb_fuseki.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,57 +5,37 @@
https://emmc-asbl.github.io/tripper/latest/developers/.
"""

from pathlib import Path

import pytest

from tripper import Session

pytest.importorskip("pyld")

# URL to check if GraphDB is running.
GRAPHDB_CHECK_URL = "http://localhost:7200/repositories"
FUSEKI_CHECK_URL = "http://localhost:3030"


def get_triplestore(tsname: str) -> "Triplestore":
"""Help function that returns a new triplestore object."""
from tripper import Triplestore

if tsname == "GraphDB":
ts = Triplestore(
backend="sparqlwrapper",
base_iri="http://localhost:7200/repositories/test_repo",
update_iri=(
"http://localhost:7200/repositories/test_repo/statements"
),
)
elif tsname == "Fuseki":
ts = Triplestore(
backend="sparqlwrapper",
base_iri=f"{FUSEKI_CHECK_URL}/test_repo",
update_iri=f"{FUSEKI_CHECK_URL}/test_repo/update",
username="admin",
password="admin0",
)
else:
raise ValueError(f"Unsupported triplestore name: {tsname}")

return ts
thisdir = Path(__file__).resolve().parent
indir = thisdir.parent / "input"

session = Session(config=indir / "session.yaml")


# if True:
# tsname = "Fuseki"
def populate_and_search(tsname): # pylint: disable=too-many-statements
# sessionName = "GraphDBTest"
# sessionName = "FusekiTest"
def populate_and_search(sessionName): # pylint: disable=too-many-statements
"""Do the test on the desried backend."""
# pylint: disable=too-many-locals

from pathlib import Path

from tripper import Literal
from tripper.datadoc import acquire, save_datadoc, search

thisdir = Path(__file__).resolve().parent
ts = session.get_triplestore(sessionName)
if ts.check_url and not ts.available(timeout=1):
pytest.skip(f"{sessionName} service not available; skipping test.")

datasetinput = thisdir / "datadocumentation_sample.yaml"
datasetinput2 = thisdir / "datadocumentation_sample2.yaml"

ts = get_triplestore(tsname)
EX = ts.bind("ex", "http://www.example.org/")

# Test DELETE query - clear the triplestore
Expand Down Expand Up @@ -194,28 +174,12 @@ def populate_and_search(tsname): # pylint: disable=too-many-statements


def test_graphdb():
"""
Test the sparqlwrapper backend using GraphDB.
"""
# Check if GraphDB is available and write a warning if it is not.
from tripper.utils import check_service_availability

if not check_service_availability(GRAPHDB_CHECK_URL, timeout=1):
pytest.skip("GraphDB instance not available locally; skipping tests.")

print("Testing graphdb")
populate_and_search("GraphDB")
"""Test the sparqlwrapper backend using GraphDB."""
# Use service configured in tests/input/session.yaml
populate_and_search("GraphDBTest")


def test_fuseki():
"""
Test the sparqlwrapper backend using Fuseki.
"""
# Check if Fuseki is available and write a warning if it is not.
from tripper.utils import check_service_availability

if not check_service_availability(FUSEKI_CHECK_URL, timeout=1):
pytest.skip("Fuseki instance not available locally; skipping tests.")

print("Testing fuseki")
populate_and_search("Fuseki")
"""Test the sparqlwrapper backend using Fuseki."""
# Use service configured in tests/input/session.yaml
populate_and_search("FusekiTest")
4 changes: 4 additions & 0 deletions tests/datadoc/dataset_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@

from pathlib import Path

from tripper import Session

testdir = Path(__file__).absolute().parent.parent.resolve()
rootdir = testdir.parent.resolve()
ontodir = testdir / "ontologies"
indir = testdir / "input"
outdir = testdir / "output"

session = Session(config=indir / "session.yaml")
Loading
Loading