Skip to content

Commit

Permalink
update dependencies and template
Browse files Browse the repository at this point in the history
  • Loading branch information
muddymudskipper committed Nov 13, 2024
1 parent dd6088c commit cc1de3a
Show file tree
Hide file tree
Showing 13 changed files with 524 additions and 73 deletions.
2 changes: 1 addition & 1 deletion .copier-answers.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Changes here will be overwritten by Copier
project_slug=pyshacl
package_dir=cmem_plugin_pyshacl

5 changes: 3 additions & 2 deletions .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Changes here will be overwritten by Copier
_commit: v6.3.1
_commit: v7.0.0
_src_path: gh:eccenca/cmem-plugin-template
author_mail: cmempy-developer@eccenca.com
author_name: eccenca GmbH
github_page: https://github.com/eccenca/cmem-plugin-pyshacl
project_description: Validate your Knowledge Graphs based on tests generated from
SHACL shapes.
project_slug: pyshacl
pypi: false
project_type: plugin
pypi: true

4 changes: 2 additions & 2 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ jobs:
uses: actions/checkout@v4

- name: Install Task
uses: arduino/setup-task@v1
uses: arduino/setup-task@v2

- name: Set up python
id: setup-python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.11'

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ jobs:
uses: actions/checkout@v4

- name: Install Task
uses: arduino/setup-task@v1
uses: arduino/setup-task@v2

- name: Set up python
id: setup-python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.11'

Expand Down
19 changes: 19 additions & 0 deletions .tasks-plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# https://taskfile.dev
---
version: '3'

tasks:

install:
desc: Install plugin package in Corporate Memory
cmds:
- task build
- poetry run cmemc admin workspace python install dist/cmem_plugin_pyshacl*.tar.gz
- poetry run cmemc admin workspace python list-plugins

uninstall:
desc: Unnstall plugin package in Corporate Memory
cmds:
- task build
- poetry run cmemc admin workspace python uninstall cmem-plugin-pyshacl
- poetry run cmemc admin workspace python list-plugins
119 changes: 116 additions & 3 deletions README-public.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,125 @@

Validate your Knowledge Graphs based on tests generated from SHACL shapes.

This is a plugin for [eccenca](https://eccenca.com) [Corporate Memory](https://documentation.eccenca.com).
[![eccenca Corporate Memory][cmem-shield]][cmem-link]

You can install it with the [cmemc](https://eccenca.com/go/cmemc) command line
clients like this:
This is a plugin for [eccenca](https://eccenca.com) [Corporate Memory](https://documentation.eccenca.com). You can install it with the [cmemc](https://eccenca.com/go/cmemc) command line clients like this:

```
cmemc admin workspace python install cmem-plugin-pyshacl
```


## Parameters

### Data graph URI

The URI of the data graph to be validated. The graph URI is selected from a list of graphs of types:
- `di:Dataset`
- `dsm:ThesaurusProject`
- `owl:Ontology`
- `shui:ShapeCatalog`
- `void:Dataset`

### SHACL graph URI

The URI of the graph containing the SHACL shapes to be validated against. The graph URI is selected from a list of graphs of type `shui:ShapeCatalog`

### Generate validation graph

If enabled, the validation graph is posted to the CMEM instance with the graph URI specified with the *validation graph URI* option. Default value: *false*

### Validation graph URI

If the *generate validation graph* option is enabled the validation graph is posted to the CMEM instance with this graph URI

### Output entities

If enabled, the plugin outputs the validation results and can be connected to, for instance, a CSV dataset to produce a results table. Default value: *false*

### Clear validation graph

If enabled, the validation graph is cleared before workflow execution. Default value: *true*.

## Advanced Options

### Resolve owl:imports

If enabled, the graph tree defined with `owl:imports` in the data graph is resolved. Default value: *true*

### Blank node skolemization

If enabled, blank nodes in the validation graph are skolemized into URIs. Default value: *true*

### Add labels

If enabled, `rdfs:label` triples are added to the validation graph for instances of `sh:ValidationReport` and `sh:ValidationResult`. Default value: *true*

### Add labels from data and SHACL graphs

If enabled along with the *add labels* option, `rdfs:label` triples are added for the focus nodes, values and SHACL shapes in the validation graph. The labels are taken from the specified data and SHACL graphs. Default value: *false*

### Add shui:conforms flag to focus node resources

If enabled, `shui:conforms false` triples are added to the focus nodes in the validation graph. Default value: *false*

### Meta-SHACL

If enabled, the SHACL shapes graph is validated against the SHACL-SHACL shapes graph before validating the data graph. Default value: *false*

### Ontology graph URI

The URI of a graph containing extra ontological information. RDFS and OWL definitions from this are used to inoculate the data graph. The graph URI is selected from a list of graphs of type `owl:Ontology`

### Inference

If enabled, OWL inferencing expansion of the data graph is performed before validation. Options are *RDFS*, *OWLRL*, *Both*, *None*. Default value: *None*

### Advanced

Enable SHACL Advanced Features. Default value: *false*.

### Maximum evaluation depth

The maximum number of SHACL shapes "deep" that the validator can go before reaching an "endpoint" constraint (1-999). Default value: 15


## Parameter Input

In order to set options via the input the following parameter names can be used:

| Option | Name |
|------------------------------------------------|------------------------|
| Data graph URI | data_graph_uri |
| SHACL graph URI | shacl_graph_uri |
| Generate validation graph | generate_graph |
| Validation graph URI | validation_graph_uri |
| Output entities | output_entities |
| Clear validation graph | clear_validation_graph |
| Resolve owl:imports | owl_imports |
| Blank node skolemization | skolemize |
| Add labels | add_labels |
| Add labels from data and SHACL graphs | include_graphs_labels |
| Add shui:conforms flag to focus node resources | add_shui_conforms |
| Meta-SHACL | meta_shacl |
| Ontology graph URI | ontology_graph_uri |
| Inference | inference |
| Advanced | advanced |
| Maximum evaluation depth | max_evaluation_depth |



[![workflow](https://github.com/eccenca/cmem-plugin-pyshacl/actions/workflows/check.yml/badge.svg)](https://github.com/eccenca/cmem-plugin-pyshacl/actions) [![pypi version](https://img.shields.io/pypi/v/cmem-plugin-pyshacl)](https://pypi.org/project/cmem-plugin-pyshacl) [![license](https://img.shields.io/pypi/l/cmem-plugin-pyshacl)](https://pypi.org/project/cmem-plugin-pyshacl)
[![poetry][poetry-shield]][poetry-link] [![ruff][ruff-shield]][ruff-link] [![mypy][mypy-shield]][mypy-link] [![copier][copier-shield]][copier]

[cmem-link]: https://documentation.eccenca.com
[cmem-shield]: https://img.shields.io/endpoint?url=https://dev.documentation.eccenca.com/badge.json
[poetry-link]: https://python-poetry.org/
[poetry-shield]: https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json
[ruff-link]: https://docs.astral.sh/ruff/
[ruff-shield]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json&label=Code%20Style
[mypy-link]: https://mypy-lang.org/
[mypy-shield]: https://www.mypy-lang.org/static/mypy_badge.svg
[copier]: https://copier.readthedocs.io/
[copier-shield]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/copier-org/copier/master/img/badge/badge-grayscale-inverted-border-purple.json

25 changes: 12 additions & 13 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# https://taskfile.dev
#
# This is a generated file. We dot not suggest to edit it.
# Instead, create a file `TaskfileCustom.yml` and add your additions there.
---
version: '3'

Expand All @@ -10,13 +13,16 @@ dotenv: ['.copier-answers.env', '.env']
- check:prepare

vars:
PACKAGE: cmem_plugin_$project_slug
PACKAGE: $package_dir
DIST_DIR: dist

includes:
custom:
taskfile: ./TaskfileCustom.yaml
optional: true
plugin:
taskfile: .tasks-plugin.yml
optional: true

tasks:

Expand All @@ -43,6 +49,10 @@ tasks:
Check poetry versioning plugin. Currently not under Windows
run: once
preconditions:
- sh: '[ -d .git ]'
msg: >
Your newly created project directory needs to be initialized
as a git repository.
- sh: '[[ {{.PDV_VERSION}} > {{.PDV_VERSION_MIN}} ]]'
msg: >
This project needs the poetry-dynamic-versioning
Expand Down Expand Up @@ -152,22 +162,13 @@ tasks:
<<: *preparation
cmds:
- poetry run ruff check --exit-zero tests {{.PACKAGE}} {{.XML_PARAMS}}
- poetry run ruff check --show-source tests {{.PACKAGE}}
- poetry run ruff check --output-format=concise tests {{.PACKAGE}}
- poetry run ruff format --check tests {{.PACKAGE}}
vars:
JUNIT_FILE: ./{{.DIST_DIR}}/junit-ruff.xml
XML_PARAMS: --output-format junit --output-file {{.JUNIT_FILE}}

# }}}
# {{{ build and deploy tasks

deploy:
desc: Install plugin package in Corporate Memory
deps:
- build
cmds:
- cmemc admin workspace python install dist/*.tar.gz
- cmemc admin workspace python list-plugins

build:
desc: Build a tarball and a wheel package
Expand All @@ -178,5 +179,3 @@ tasks:
cmds:
- poetry build

# }}}

2 changes: 1 addition & 1 deletion cmem_plugin_pyshacl/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"""pyshacl - main package"""
"""cmem-plugin-pyshacl"""
2 changes: 1 addition & 1 deletion cmem_plugin_pyshacl/plugin_pyshacl.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ def post_graph(self, validation_graph: Graph) -> None:
if res.status_code != 204: # noqa: PLR2004
raise OSError(f"Error posting SHACL validation graph (status code {res.status_code}).")

def check_object( # noqa: C901 PLR0912 PLR0913
def check_object( # noqa: C901 PLR0912
self, graph: Graph, subj: Node, pred: URIRef, data_graph: Graph, shacl_graph: Graph
) -> str:
"""Format RDF objects for entities output"""
Expand Down
Loading

0 comments on commit cc1de3a

Please sign in to comment.