You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. After cloning this repository, ensure the CASE submodule is checked out. This can be done with either `git submodule init && git submodule update`, `make .git_submodule_init.done.log`, or `make check`.
7
+
2. Update the CASE submodule pointer to the new tagged release.
8
+
3. The version of CASE is also hard-coded in [`case_utils/ontology/version_info.py`](case_utils/ontology/version_info.py). Edit the variable `CURRENT_CASE_VERSION`.
9
+
4. From the top source directory, run `make clean`. This guarantees a clean state of this repository as well as the ontology submodules.
10
+
5. Still from the top source directory, run `make`.
11
+
6. Any new `.ttl` files will be created under [`case_utils/ontology/`](case_utils/ontology/). Use `git add` to add each of them. (The patch-weight of these files could overshadow manual revisions, so it is fine to commit the built files after the manual changes are committed.)
12
+
13
+
Here is a sample sequence of shell commands to run the build:
14
+
15
+
```bash
16
+
# (Starting from fresh `git clone`.)
17
+
make check
18
+
pushd dependencies/CASE
19
+
git checkout master
20
+
git pull
21
+
popd
22
+
git add dependencies/CASE
23
+
# (Here, edits should be made to case_utils/ontology/version_info.py)
24
+
make
25
+
pushd case_utils/ontology
26
+
git add case-0.6.0.ttl # Assuming CASE 0.6.0 was just released.
27
+
# and/or
28
+
git add uco-0.8.0.ttl # Assuming UCO 0.8.0 was adopted in CASE 0.6.0.
29
+
popd
30
+
make check
31
+
# Assuming `make check` passes:
32
+
git commit -m "Update CASE ontology pointer to version 0.6.0" dependencies/CASE case_utils/ontology/version_info.py
33
+
git commit -m "Build CASE 0.6.0.ttl" case_utils/ontology/case-0.6.0.ttl
Copy file name to clipboardExpand all lines: Makefile
+52-5Lines changed: 52 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -13,9 +13,15 @@
13
13
14
14
SHELL := /bin/bash
15
15
16
-
PYTHON3 ?= $(shell which python3.9 2>/dev/null || which python3.8 2>/dev/null || which python3.7 2>/dev/null || which python3.6 2>/dev/null || which python3)
# Confirm the current monolithic file is in place.
63
+
test -r case_utils/ontology/case-$(case_version).ttl
64
+
test -r case_utils/ontology/case-$(case_version)-subclasses.ttl
38
65
touch $@
39
66
40
67
check: \
41
-
.git_submodule_init.done.log
68
+
.ontology.done.log
42
69
$(MAKE) \
43
70
PYTHON3=$(PYTHON3) \
44
71
--directory tests \
@@ -49,12 +76,32 @@ clean:
49
76
--directory tests \
50
77
clean
51
78
@rm -f \
52
-
.git_submodule_init.done.log
79
+
.*.done.log
80
+
@# 'clean' in the ontology directory should only happen when testing and building new ontology versions. Hence, it is not called from the top-level Makefile.
81
+
@test ! -r dependencies/CASE/README.md \
82
+
||$(MAKE)\
83
+
--directory dependencies/CASE \
84
+
clean
85
+
@# Restore CASE validation output files that do not affect CASE build process.
86
+
@test ! -r dependencies/CASE/README.md \
87
+
|| ( \
88
+
cd dependencies/CASE \
89
+
&& git checkout \
90
+
-- \
91
+
tests/examples \
92
+
||true\
93
+
)
53
94
@#Remove flag files that are normally set after deeper submodules and rdf-toolkit are downloaded.
Copy file name to clipboardExpand all lines: README.md
+31-5Lines changed: 31 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,33 @@ Installation is demonstrated in the `.venv.done.log` target of the [`tests/`](te
20
20
## Usage
21
21
22
22
23
+
### `case_validate`
24
+
25
+
This repository provides `case_validate` as an adaptation of the `pyshacl` command from [RDFLib's pySHACL](https://github.com/RDFLib/pySHACL). The command-line interface is adapted to run as though `pyshacl` were provided the full CASE ontology (and adopted full UCO ontology) as both a shapes and ontology graph. "Compiled" (or, "aggregated") CASE ontologies are in the [`case_utils/ontology/`](case_utils/ontology/) directory, and are installed with `pip`, so data validation can occur without requiring networking after this repository is installed.
26
+
27
+
To see a human-readable validation report of an instance-data file:
28
+
29
+
```bash
30
+
case_validate input.json [input-2.json ...]
31
+
```
32
+
33
+
If `input.json` is not conformant, a report will be emitted, and `case_validate` will exit with status `1`. (This is a `pyshacl` behavior, where `0` and `1` report validation success. Status of >`1` is for other errors.)
34
+
35
+
To produce the validation report as a machine-readable graph output, the `--format` flag can be used to modify the output format:
To use one or more supplementary ontology files, the `--ontology-graph` flag can be used, more than once if desired, to supplement the selected CASE version:
Two commands are provided to generate output from a SPARQL query and one or more input graphs. Input graphs can be any graph, such as instance data or supplementary ontology files that supply custom class definitions or other external ontologies.
41
68
69
+
These commands can be used with any RDF files to run arbitrary SPARQL queries. They have one additional behavior tailored to CASE: If a path query is used for subclasses, the CASE subclass hierarchy will be loaded to supplement the input graph. An expected use case of this feature is subclasses of `ObservableObject`. For instance, if a data graph included an object with only the class `uco-observable:File` specified, the query `?x a/rdfs:subClassOf* uco-observable:ObservableObject` would match `?x` against that object.
Note that `case_sparql_select` is not guaranteed to function with Pythons below version 3.7.
66
-
67
94
68
95
### `local_uuid`
69
96
@@ -86,10 +113,9 @@ This project follows [SEMVER 2.0.0](https://semver.org/) where versions are decl
86
113
87
114
## Ontology versions supported
88
115
89
-
This repository supports the ontology versions that are linked as submodules in the [CASE Examples QC](https://github.com/ajnelson-nist/CASE-Examples-QC) repository. Currently, the ontology versions are:
116
+
This repository supports the CASE ontology version that is linked as a submodule [here](dependencies/CASE). The CASE version is encoded as a variable (and checked in unit tests) in [`case_utils/ontology/version_info.py`](case_utils/ontology/version_info.py), and used throughout this code base, as `CURRENT_CASE_VERSION`.
90
117
91
-
* CASE - 0.4.0
92
-
* UCO - 0.6.0
118
+
For instructions on how to update the CASE version for an ontology release, see [`CONTRIBUTE.md`](CONTRIBUTE.md).
Copy file name to clipboardExpand all lines: case_utils/__init__.py
+11-27Lines changed: 11 additions & 27 deletions
Original file line number
Diff line number
Diff line change
@@ -11,35 +11,19 @@
11
11
#
12
12
# We would appreciate acknowledgement if the software is used.
13
13
14
-
__version__="0.2.1"
14
+
__version__="0.3.0"
15
15
16
-
importrdflib.util
16
+
importtyping
17
+
importwarnings
17
18
18
-
from . importlocal_uuid
19
-
20
-
defguess_format(fpath, fmap=None):
21
-
"""
22
-
This function is a wrapper around rdflib.util.guess_format(), adding that the .json extension should be recognized as JSON-LD.
23
-
24
-
:param fpath: File path.
25
-
:type fpath: string
19
+
importrdflib.util# type: ignore
26
20
27
-
:param fmap: Mapper dictionary; see rdflib.util.guess_format() for further description. Note that as in rdflib 5.0.0, supplying this argument overwrites, not augments, the suffix format map used by rdflib.
28
-
:type fmap: dict
29
-
30
-
:returns: RDF file format, fit for rdflib.Graph.parse() or .serialize(); or, None if file extension not mapped.
warnings.warn("The functionality in case_utils.guess_format is now upstream. Please revise your code to use rdflib.util.guess_format. The function arguments remain the same. case_utils.guess_format will be removed in case_utils 0.4.0.", DeprecationWarning)
0 commit comments