Skip to content

Commit eb67c02

Browse files
committed
release: 🔖 version 0.6.0
2 parents 44a03d4 + 00803d9 commit eb67c02

File tree

76 files changed

+3355
-764
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+3355
-764
lines changed

‎docs/0_toc.rst‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@
2020
1_installation
2121
2_usage_cli
2222
3_usage_api
23+
4_how_it_works
2324

2425
.. toctree::
2526
:maxdepth: 5
2627
:caption: Resources
2728

29+
11_writing_a_profile
2830
10_api
2931
genindex
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
Writing a new profile
2+
=====================
3+
4+
This page is about writing a SHACL validation profile for a new or
5+
existing RO-Crate profile. It does *not* offer guidance on creating the
6+
RO-Crate profile itself - for that, see the
7+
`RO-Crate page on Profiles <https://www.researchobject.org/ro-crate/profiles#making-an-ro-crate-profile>`_.
8+
9+
Learning SHACL
10+
--------------
11+
12+
The validator profiles are written in SHACL (Shapes Constraint Language), a
13+
language for validating RDF graphs against a set of conditions.
14+
To use SHACL effectively, you also need some familiarity with RDF
15+
(Resource Description Framework), the technology which underpins
16+
JSON-LD and therefore RO-Crate.
17+
18+
For an RDF introduction, try the `RDF 1.1 Primer <https://www.w3.org/TR/rdf11-primer/>`_ or
19+
`Introduction to the Principles of Linked Open Data <https://programminghistorian.org/en/lessons/intro-to-linked-data>`_.
20+
21+
This `chapter on SHACL <https://book.validatingrdf.com/bookHtml011.html>`_
22+
from the book `Validating RDF Data <https://book.validatingrdf.com>`_
23+
has examples of most of SHACL's features and is a good place
24+
to start learning. Other chapters in that book may provide an understanding
25+
of *why* SHACL is our language of choice for this purpose.
26+
27+
For complex validation, you may also need some knowledge of SPARQL, an RDF
28+
query language. You can learn about SPARQL in the tutorial
29+
`Using SPARQL to access Linked Open Data <https://programminghistorian.org/en/lessons/retired/graph-databases-and-SPARQL>`_.
30+
31+
All these tools are best learned through practice and examples, so when building a
32+
profile, it's encouraged to use the
33+
`other profiles <https://github.com/crs4/rocrate-validator/tree/develop/rocrate_validator/profiles>`_
34+
as a point of reference.
35+
36+
Setting up profile files and tests
37+
----------------------------------
38+
39+
These instructions assume you are familiar with code development using Python and Git.
40+
41+
#. `Install the repository from source <https://rocrate-validator.readthedocs.io/en/latest/1_installation/#installation>`_.
42+
#. From the root folder of the repo, create a folder for the profile under
43+
`rocrate_validator/profiles <https://github.com/crs4/rocrate-validator/tree/develop/rocrate_validator/profiles>`_.
44+
#. To set up the profile metadata, copy across ``profile.ttl`` from another
45+
profile folder to the folder you created
46+
(`example <https://github.com/crs4/rocrate-validator/blob/develop/rocrate_validator/profiles/workflow-ro-crate/profile.ttl>`_)
47+
& update that metadata to reflect your profile. In particular:
48+
49+
#. change the token for the profile to a new and unique name, e.g.
50+
``prof:hasToken "workflow-ro-crate-linkml"``. This is the name which
51+
can be used to select the profile using ``--profile-identifier``
52+
argument (and should also be the name of the folder).
53+
#. Ensure the URI of the profile is unique (the first line after the
54+
``@prefix`` statements), to prevent conflation between this profile
55+
and any other profile in the package.
56+
#. If this profile inherits from another profile in the validator
57+
(including the base specification), set ``prof:isProfileOf`` /
58+
``prof:isTransitiveProfileOf`` to that profile's URI (which can be found
59+
in that profile's own ``profile.ttl``).
60+
61+
#. Create a ``profile-name.ttl`` file in the folder you created - this is
62+
where you will write the SHACL for the validation. If you have a lot of
63+
checks to write, you can create multiple files - the validator will
64+
collect them all automatically at runtime.
65+
66+
* Note: some profiles split the checks into folders called ``must/``,
67+
``should/`` and ``may/`` according to the requirement severity. This
68+
is not mandatory - you can also label individual checks/shapes with
69+
``sh:severity`` in the SHACL code instead.
70+
71+
#. From the root folder of the repo, create a test folder for the profile
72+
under
73+
`tests/integration/profiles <https://github.com/crs4/rocrate-validator/tree/develop/tests/integration/profiles>`_. The name should match the folder you made earlier.
74+
#. Copy the style of other profiles' tests to build up a test suite for the
75+
profile. Add any required RO-Crate test data under
76+
`tests/data/crates/ <https://github.com/crs4/rocrate-validator/tree/develop/tests/data/crates>`_
77+
and create corresponding classes in
78+
`tests/ro_crates.py <https://github.com/crs4/rocrate-validator/blob/develop/tests/ro_crates.py>`_
79+
which can be used to fetch the data during the tests.
80+
#. When your profile & tests are written, open a pull request to contribute
81+
it back to the repository!
82+
83+
Running validator & tests during profile development
84+
----------------------------------------------------
85+
86+
To run the test suite, run ``pytest``. New tests should be picked up automatically for
87+
the new profile.
88+
89+
When running the validator manually, use ``--profile-identifier`` to select the desired profile.
90+
91+
The crates in ``tests/data/crates``` can be used as examples for running the validator. For example: ::
92+
93+
rocrate-validator validate --profile-identifier your-profile-name tests/data/crates/invalid/1_wroc_crate/no_mainentity/

‎docs/4_how_it_works.rst‎

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
..
2+
Copyright (c) 2024 CRS4
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
16+
How It Works
17+
============
18+
19+
The `rocrate-validator` is designed to validate RO-Crates against predefined
20+
*validation profiles*. A validation profile is a set of validation rules, or
21+
*checks*, which are applied to the RO-Crate. If the RO-Crate conforms to all
22+
the rules, then it is deemed *valid*; otherwise, errors will be generated for
23+
each rule that failed to validate.
24+
25+
Non-conformance to a rule will result in an *issue*. On the CLI, issues will
26+
be presented as error messages, with references to the specific rule which
27+
triggered the error. Note that multiple rules may have the same error message,
28+
which can result in output with apparently duplicate errors.
29+
30+
`rocrate-validator` is limited to validating conformance to RO-Crate
31+
profiles for which validation rules have been implemented. In the absence of
32+
any matching validation profiles, `rocrate-validator` may return an error or
33+
request the user to manually select a validation profile to apply.
34+
35+
Validation profiles can be related by inheritance -- i.e., where one validation
36+
profile extends another one. For instance, Workflow Testing RO-Crate extends Workflow RO-Crate.
37+
38+
39+
Validation profile selection
40+
----------------------------
41+
42+
* **Automatic Profile Matching** (default):
43+
By default, `rocrate-validator` will attempt to select the correct validation
44+
profiles for the input RO-Crate based on the `conformsTo` property of the Root Data Entity.
45+
46+
- If a precise match is found for the `conformsTo` property, that profile is selected
47+
for validation.
48+
49+
- If no precise match is found:
50+
51+
- in **Interactive Mode:** (available only through the CLI) the system
52+
will prompt the user to select a profile from the list of
53+
profiles to which the RO-Crate conforms;
54+
55+
- in **Non-Interactive Mode:** the system will validate against all profiles
56+
to which the RO-Crate conforms, and for which validation rules are available.
57+
In all cases, input RO-Crates are validated against the base `ro-crate` profile.
58+
59+
* **Profile Versions**:
60+
- It may happen that the RO-Crate profile version to which the input
61+
RO-Crate `conformsTo` does not match the version of the implemented
62+
validation profile. In this case, the validator will validate against the
63+
*highest available version* of the profile that is lower than the one
64+
requested. Thus, the validator will avoid applying a validation profile
65+
that is newer than the `conformsTo` profile. This behaviour can be
66+
overridden by manually selecting the desired validation profile (see below).
67+
68+
.. note::
69+
Profile versions are identified by matching the trailing version number
70+
in the profile identifier, if present. For instance, the identifier for
71+
the `ro-crate` profile version **1.0** is `ro-crate-1.0`, while the
72+
profile name without a version is simply `ro-crate`.
73+
74+
* **Manual Profile Selection**:
75+
The user can always override the automatic selection of validation profiles
76+
by specifying (via CLI or API) which profile to use.

0 commit comments

Comments
 (0)