Skip to content

Commit 577b47d

Browse files
committed
Add recipes and instructions to build ontology
References: * [AC-210] Add validation command to CASE-Utilities-Python * [ONT-445] (CP-38) rdf-toolkit base-iri flag degenerates versionIRI when slash IRI form is used Signed-off-by: Alex Nelson <[email protected]>
1 parent 73800db commit 577b47d

File tree

7 files changed

+158
-6
lines changed

7 files changed

+158
-6
lines changed

CONTRIBUTE.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Contributing to CASE-Utilities-Python
2+
3+
4+
## Deploying a new ontology version
5+
6+
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
34+
```

Makefile

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ SHELL := /bin/bash
1515

1616
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)
1717

18-
all:
18+
all: \
19+
.ontology.done.log
1920

2021
.PHONY: \
2122
download
@@ -38,10 +39,24 @@ all:
3839
test -r dependencies/CASE/ontology/master/case.ttl \
3940
|| (git submodule init dependencies/CASE && git submodule update dependencies/CASE)
4041
test -r dependencies/CASE/ontology/master/case.ttl
42+
$(MAKE) \
43+
--directory dependencies/CASE \
44+
.git_submodule_init.done.log \
45+
.lib.done.log
46+
touch $@
47+
48+
.ontology.done.log: \
49+
dependencies/CASE/ontology/master/case.ttl
50+
$(MAKE) \
51+
--directory case_utils/ontology
52+
# Confirm there is at least one versioned monolithic file in place.
53+
/bin/ls \
54+
case_utils/ontology/case-*.ttl \
55+
> /dev/null
4156
touch $@
4257

4358
check: \
44-
.git_submodule_init.done.log
59+
.ontology.done.log
4560
$(MAKE) \
4661
PYTHON3=$(PYTHON3) \
4762
--directory tests \
@@ -52,7 +67,10 @@ clean:
5267
--directory tests \
5368
clean
5469
@rm -f \
55-
.git_submodule_init.done.log
70+
.*.done.log
71+
@$(MAKE) \
72+
--directory case_utils/ontology \
73+
clean
5674
@test ! -r dependencies/CASE/README.md \
5775
|| @$(MAKE) \
5876
--directory dependencies/CASE \
@@ -71,6 +89,12 @@ clean:
7189
dependencies/CASE-Examples-QC/.git_submodule_init.done.log \
7290
dependencies/CASE-Examples-QC/.lib.done.log
7391

92+
# This recipe guarantees timestamp update order, and is otherwise intended to be a no-op.
93+
dependencies/CASE/ontology/master/case.ttl: \
94+
.git_submodule_init.done.log
95+
test -r $@
96+
touch $@
97+
7498
distclean: \
7599
clean
76100
@rm -rf \

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,9 @@ This project follows [SEMVER 2.0.0](https://semver.org/) where versions are decl
8686

8787
## Ontology versions supported
8888

89-
This repository supports the CASE ontology version that is linked as a submodule [here](dependencies/CASE). Currently, the ontology versions are:
89+
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`.
9090

91-
* CASE - 0.5.0
92-
* UCO - 0.7.0
91+
For instructions on how to update the CASE version for an ontology release, see [`CONTRIBUTE.md`](CONTRIBUTE.md).
9392

9493

9594
## Repository locations

case_utils/ontology/Makefile

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/make -f
2+
3+
# This software was developed at the National Institute of Standards
4+
# and Technology by employees of the Federal Government in the course
5+
# of their official duties. Pursuant to title 17 Section 105 of the
6+
# United States Code this software is not subject to copyright
7+
# protection and is in the public domain. NIST assumes no
8+
# responsibility whatsoever for its use by other parties, and makes
9+
# no guarantees, expressed or implied, about its quality,
10+
# reliability, or any other characteristic.
11+
#
12+
# We would appreciate acknowledgement if the software is used.
13+
14+
SHELL := /bin/bash
15+
16+
top_srcdir := $(shell cd ../.. ; pwd)
17+
18+
case_srcdir := $(top_srcdir)/dependencies/CASE
19+
20+
uco_srcdir := $(case_srcdir)/dependencies/UCO
21+
22+
RDF_TOOLKIT_JAR := $(case_srcdir)/lib/rdf-toolkit.jar
23+
24+
case_version := $(shell python3 version_info.py)
25+
26+
all: \
27+
case-$(case_version).ttl
28+
29+
case-$(case_version).ttl: \
30+
$(top_srcdir)/.git_submodule_init.done.log \
31+
$(RDF_TOOLKIT_JAR)
32+
$(MAKE) \
33+
--directory $(case_srcdir)/tests \
34+
case_monolithic.ttl
35+
#TODO This cleanup step should be removed after the 0.3.0 release of CASE-Utility-SHACL-Inheritance-Reviewer.
36+
test ! -d $(uco_srcdir)/dependencies/CASE-Utility-SHACL-Inheritance-Reviewer/build \
37+
|| rm -rf \
38+
$(uco_srcdir)/dependencies/CASE-Utility-SHACL-Inheritance-Reviewer/build
39+
#TODO This normalization step will not be needed after resolution of ONT-445.
40+
java -jar $(RDF_TOOLKIT_JAR) \
41+
--inline-blank-nodes \
42+
--source $(case_srcdir)/tests/case_monolithic.ttl \
43+
--source-format turtle \
44+
--target _$@ \
45+
--target-format turtle
46+
mv _$@ $@
47+
48+
clean:
49+
@rm -f case-$(case_version).ttl

case_utils/ontology/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This software was developed at the National Institute of Standards
2+
# and Technology by employees of the Federal Government in the course
3+
# of their official duties. Pursuant to title 17 Section 105 of the
4+
# United States Code this software is not subject to copyright
5+
# protection and is in the public domain. NIST assumes no
6+
# responsibility whatsoever for its use by other parties, and makes
7+
# no guarantees, expressed or implied, about its quality,
8+
# reliability, or any other characteristic.
9+
#
10+
# We would appreciate acknowledgement if the software is used.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env python3
2+
3+
# This software was developed at the National Institute of Standards
4+
# and Technology by employees of the Federal Government in the course
5+
# of their official duties. Pursuant to title 17 Section 105 of the
6+
# United States Code this software is not subject to copyright
7+
# protection and is in the public domain. NIST assumes no
8+
# responsibility whatsoever for its use by other parties, and makes
9+
# no guarantees, expressed or implied, about its quality,
10+
# reliability, or any other characteristic.
11+
#
12+
# We would appreciate acknowledgement if the software is used.
13+
14+
"""
15+
This program serves two roles:
16+
1. As a module, it houses the hard-coded values for the current CASE version packaged with case_utils.
17+
2. As a script, it prints that version when called.
18+
19+
When preparing to build a new monolithic ontology, please edit this variable to match the new respective version.
20+
"""
21+
22+
__version__ = "0.1.0"
23+
24+
__all__ = [
25+
"CURRENT_CASE_VERSION"
26+
]
27+
28+
# Tested with CI to match versionInfo of <https://ontology.caseontology.org/case/case>.
29+
CURRENT_CASE_VERSION : str = "0.5.0"
30+
31+
def main() -> None:
32+
print(CURRENT_CASE_VERSION)
33+
34+
if __name__ == "__main__":
35+
main()

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ console_scripts =
3232

3333
[options.package_data]
3434
case_utils = py.typed
35+
case_utils.ontology = *.ttl

0 commit comments

Comments
 (0)