Skip to content

Commit

Permalink
Utils: V2
Browse files Browse the repository at this point in the history
  • Loading branch information
JervenBolleman committed Sep 16, 2024
1 parent 36bce2c commit 23c5ac6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
java-version: '21'

- name: Install tester
run: wget 'https://github.com/sib-swiss/sparql-examples-utils/releases/download/v1.0.0/sparql-examples-util-1.0.0-uber.jar' -O sparql-util.jar
run: wget "https://github.com/sib-swiss/sparql-examples-utils/releases/download/v2.0.0/sparql-examples-utils-2.0.0-uber.jar" -O sparql-examples-utils.jar

- name: Run tests
run: java -cp sparql-util.jar swiss.sib.rdf.sparql.examples.Tester --input-directory=examples/
run: java -jar sparql-examples-utils.jar test --input-directory=examples/
6 changes: 3 additions & 3 deletions .github/workflows/publish_github_pages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ jobs:
java-version: '21'

- name: Install tester
run: wget 'https://github.com/sib-swiss/sparql-examples-utils/releases/download/v1.0.0/sparql-examples-util-1.0.0-uber.jar' -O sparql-examples-util-1.0.0-uber.jar
run: wget "https://github.com/sib-swiss/sparql-examples-utils/releases/download/v2.0.0/sparql-examples-utils-2.0.0-uber.jar" -O sparql-examples-utils-uber.jar

- name: generate markdown
run: java -jar sparql-examples-util-*-uber.jar -i examples/ -m
run: java -jar sparql-examples-utils-uber.jar -i examples/ -m

- name: generate rq files
run: java -jar sparql-examples-util-*-uber.jar -i examples/ -r
run: java -jar sparql-examples-utils-uber.jar -i examples/ -r

- name: Setup Pages
id: pages
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ We use the [SIB SPARQL Examples utils](https://github.com/sib-swiss/sparql-examp
First, download the jar file with:

```bash
wget -O sparql-examples-utils.jar 'https://github.com/sib-swiss/sparql-examples-utils/releases/download/v1.0.0/sparql-examples-util-1.0.0-uber.jar'
wget -O sparql-examples-utils.jar 'https://github.com/sib-swiss/sparql-examples-utils/releases/download/v2.0.0/sparql-examples-utils-2.0.0-uber.jar'
```

### Compile all query files into one file to upload to your endpoint
Expand All @@ -56,38 +56,38 @@ java -jar sparql-examples-utils.jar -i examples/ -p UniProt -f ttl > examples_Un
Or compile for all example folders, as JSON-LD, to the standard output:

```bash
java -jar sparql-examples-utils.jar -i examples/ -p all -f jsonld
java -jar sparql-examples-utils.jar convert -i examples/ -p all -f jsonld
```

### Generate RQ files

For easier use by other tools we can also generate [rq](https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#mediaType) files. Following the syntax of [grlc](https://grlc.io/) allowing to use these queries as APIs.
```bash
java -jar sparql-examples-utils.jar -i examples/ -p all -r
java -jar sparql-examples-utils.jar convert -i examples/ -p all -r
```

### Generate markdown file

Generate markdown files with the query and a mermaid diagram of the queries, to be used to deploy a static website for the query examples.

```bash
java -jar sparql-examples-utils.jar -i examples/ -m
java -jar sparql-examples-utils.jar convert -i examples/ -m
```

### Testing the queries

The queries are parsed and validated but not executed with junit using the Tester

```bash
java -cp sparql-examples-utils.jar swiss.sib.rdf.sparql.examples.Tester --input-directory=./examples
java -jar sparql-examples-utils.jar test --input-directory=./examples
```

should return no test failures. RDF4j and Jena are both a lot stricter than virtuoso.

The queries can be executed automatically on all endpoints they apply to using an extra argument `--also-run-slow-tests`:

```bash
java -cp sparql-examples-utils.jar swiss.sib.rdf.sparql.examples.Tester --input-directory=./examples/MetaNetX --also-run-slow-tests
java -jar sparql-examples-utils.jar test --input-directory=./examples/MetaNetX --also-run-slow-tests
```

> This does change the queries to add a LIMIT 1 if no limit was set in the query. Then check if there is a result it is fetched.
Expand All @@ -112,7 +112,7 @@ WHERE {
This expects the Jena tools to be available in your $PATH. e.g. `export PATH="$JENA_HOME/bin:$PATH"`

```bash
java -jar sparql-examples-utils.jar -i examples/ -p all -f ttl > examples_all.ttl
java -jar sparql-examples-utils.jar convert -i examples/ -p all -f ttl > examples_all.ttl

sparql --data examples_all.ttl "SELECT ?query (GROUP_CONCAT(?target ; separator=', ') AS ?targets) WHERE { ?query <https://schema.org/target> ?target } GROUP BY ?query HAVING (COUNT(DISTINCT ?target) > 1) "
```
Expand Down

0 comments on commit 23c5ac6

Please sign in to comment.