Skip to content

Commit

Permalink
Merge pull request #67 from casework/release-0.7.0
Browse files Browse the repository at this point in the history
Release 0.7.0
  • Loading branch information
kchason authored Apr 4, 2023
2 parents 7179c54 + 95c971d commit ee10dc6
Show file tree
Hide file tree
Showing 23 changed files with 1,160 additions and 1,047 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
strategy:
matrix:
python-version:
- '3.7'
- '3.8'
- '3.11'

steps:
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/supply-chain.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# This software was developed at the National Institute of Standards
# and Technology by employees of the Federal Government in the course
# of their official duties. Pursuant to title 17 Section 105 of the
# United States Code this software is not subject to copyright
# protection and is in the public domain. NIST assumes no
# responsibility whatsoever for its use by other parties, and makes
# no guarantees, expressed or implied, about its quality,
# reliability, or any other characteristic.
#
# We would appreciate acknowledgement if the software is used.

# This workflow uses Make to review direct dependencies of this
# repository.

name: Continuous Integration

on:
schedule:
- cron: '15 5 * * 1,2,3,4,5'

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- '3.8'
- '3.11'

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Review dependencies
run: make check-supply-chain
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@

repos:
- repo: https://github.com/psf/black
rev: 22.10.0
rev: 23.3.0
hooks:
- id: black
- repo: https://github.com/pycqa/flake8
rev: 5.0.4
rev: 6.0.0
hooks:
- id: flake8
- repo: https://github.com/pycqa/isort
rev: 5.10.1
rev: 5.12.0
hooks:
- id: isort
name: isort (python)
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ all: \
--directory figures

.PHONY: \
check-supply-chain \
check-supply-chain-pre-commit \
clean-figures \
clean-tests

Expand Down Expand Up @@ -72,6 +74,18 @@ check: \
--directory tests \
check

# This target's dependencies potentially modify the working directory's Git state, so it is intentionally not a dependency of check.
check-supply-chain: \
check-supply-chain-pre-commit

check-supply-chain-pre-commit: \
.venv-pre-commit/var/.pre-commit-built.log
source .venv-pre-commit/bin/activate \
&& pre-commit autoupdate
git diff \
--exit-code \
.pre-commit-config.yaml

clean: \
clean-figures \
clean-tests
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ This project follows [SEMVER 2.0.0](https://semver.org/) where versions are decl

This repository supports the CASE and UCO ontology versions that are distributed with the [CASE-Utilities-Python repository](https://github.com/casework/CASE-Utilities-Python), at the newest version below a ceiling-pin in [setup.cfg](setup.cfg). Currently, those ontology versions are:

* CASE 1.0.0
* UCO 1.0.0
* CASE 1.2.0
* UCO 1.2.0


## Repository locations
Expand Down
2 changes: 1 addition & 1 deletion case_prov/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
#
# We would appreciate acknowledgement if the software is used.

__version__ = "0.6.0"
__version__ = "0.7.0"
127 changes: 89 additions & 38 deletions case_prov/case_prov_dot.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# get quoted. This turns out to be a dot syntax error. Need to report
# this upstream to pydot.

__version__ = "0.4.0"
__version__ = "0.4.1"

import argparse
import collections
Expand Down Expand Up @@ -170,7 +170,7 @@ def main() -> None:
?nEntity prov:wasDerivedFrom prov:EmptyCollection .
}
"""
for (select_query_label, select_query_text) in [
for select_query_label, select_query_text in [
("activities", select_query_actions_text),
("agents", select_query_agents_text),
("entities", select_query_entities_text),
Expand All @@ -180,7 +180,9 @@ def main() -> None:
select_query_text, initNs=nsdict
)
for record in graph.query(select_query_object):
(n_include,) = record
assert isinstance(record, rdflib.query.ResultRow)
assert isinstance(record[0], rdflib.term.IdentifiedNode)
n_include = record[0]
filter_iri = n_include.toPython()
filter_iris.add(filter_iri)
_logger.debug("len(filter_iris) = %d.", len(filter_iris))
Expand All @@ -200,6 +202,7 @@ def main() -> None:
query_ancestry_text, initNs=nsdict
)
for result in graph.query(query_ancestry_object):
assert isinstance(result, rdflib.query.ResultRow)
for result_member in result:
if not isinstance(result_member, rdflib.URIRef):
raise ValueError(
Expand Down Expand Up @@ -245,7 +248,7 @@ def main() -> None:
?nEndIRI prov:wasDerivedFrom* ?nPrecedingEntity .
}
"""
for (select_query_label, select_query_text) in [
for select_query_label, select_query_text in [
("activities", select_query_actions_text),
("agents", select_query_agents_text),
("entities", select_query_entities_text),
Expand All @@ -260,7 +263,9 @@ def main() -> None:
select_query_object,
initBindings={"nEndIRI": rdflib.URIRef(terminal_iri)},
):
(n_include,) = record
assert isinstance(record, rdflib.query.ResultRow)
assert isinstance(record[0], rdflib.term.IdentifiedNode)
n_include = record[0]
filter_iri = n_include.toPython()
filter_iris.add(filter_iri)
_logger.debug("len(filter_iris) = %d.", len(filter_iris))
Expand Down Expand Up @@ -316,8 +321,14 @@ def main() -> None:
select_query_object = rdflib.plugins.sparql.processor.prepareQuery(
select_query_text, initNs=nsdict
)
for record in graph.query(select_query_object):
(n_agent, l_label, l_comment) = record
for result in graph.query(select_query_object):
assert isinstance(result, rdflib.query.ResultRow)
assert isinstance(result[0], rdflib.term.IdentifiedNode)
assert result[1] is None or isinstance(result[1], rdflib.Literal)
assert result[2] is None or isinstance(result[2], rdflib.Literal)
n_agent = result[0]
l_label = result[1]
l_comment = result[2]
agent_iri = n_agent.toPython()
dot_label = "ID - " + graph.namespace_manager.qname(agent_iri)
if l_label is not None:
Expand All @@ -327,9 +338,9 @@ def main() -> None:
kwargs = clone_style(prov.constants.PROV_AGENT)
kwargs["label"] = dot_label
# _logger.debug("Agent %r.", agent_iri)
record = (iri_to_gv_node_id(agent_iri), kwargs)
nodes[agent_iri] = record
nodes_agents[agent_iri] = record
node_record = (iri_to_gv_node_id(agent_iri), kwargs)
nodes[agent_iri] = node_record
nodes_agents[agent_iri] = node_record
# _logger.debug("nodes = %s." % pprint.pformat(nodes))

# Find Collections, to adjust Entity rendering in the next block.
Expand All @@ -344,7 +355,9 @@ def main() -> None:
select_query_text, initNs=nsdict
)
for record in graph.query(select_query_object):
(n_collection,) = record
assert isinstance(record, rdflib.query.ResultRow)
assert isinstance(record[0], rdflib.term.IdentifiedNode)
n_collection = record[0]
collection_iri = n_collection.toPython()
collection_iris.add(collection_iri)
# _logger.debug("len(collection_iris) = %d.", len(collection_iris))
Expand All @@ -354,9 +367,9 @@ def main() -> None:
entity_iri_to_label_comment: typing.Dict[
str,
typing.Tuple[
typing.Optional[str],
typing.Optional[str],
typing.Optional[str],
typing.Optional[rdflib.Literal],
typing.Optional[rdflib.Literal],
typing.Optional[rdflib.Literal],
],
] = dict()
if not args.omit_empty_set:
Expand Down Expand Up @@ -386,28 +399,48 @@ def main() -> None:
select_query_object = rdflib.plugins.sparql.processor.prepareQuery(
select_query_text, initNs=nsdict
)
l_entity_label: typing.Optional[rdflib.Literal]
l_entity_comment: typing.Optional[rdflib.Literal]
l_entity_exhibit_number: typing.Optional[rdflib.Literal]
for record in graph.query(select_query_object):
(n_entity, l_label, l_comment, l_exhibit_number) = record
assert isinstance(record, rdflib.query.ResultRow)
assert isinstance(record[0], rdflib.term.IdentifiedNode)
assert record[1] is None or isinstance(record[1], rdflib.Literal)
assert record[2] is None or isinstance(record[2], rdflib.Literal)
assert record[3] is None or isinstance(record[3], rdflib.Literal)
n_entity = record[0]
l_entity_label = record[1]
l_entity_comment = record[2]
l_entity_exhibit_number = record[3]

entity_iri = n_entity.toPython()
entity_iri_to_label_comment[entity_iri] = (l_label, l_comment, l_exhibit_number)
entity_iri_to_label_comment[entity_iri] = (
l_entity_label,
l_entity_comment,
l_entity_exhibit_number,
)
for entity_iri in sorted(entity_iri_to_label_comment):
(l_label, l_comment, l_exhibit_number) = entity_iri_to_label_comment[entity_iri]
(
l_entity_label,
l_entity_comment,
l_entity_exhibit_number,
) = entity_iri_to_label_comment[entity_iri]
dot_label = "ID - " + graph.namespace_manager.qname(entity_iri)
if l_exhibit_number is not None:
dot_label += "\nExhibit - " + l_exhibit_number.toPython()
if l_label is not None:
dot_label += "\n" + l_label.toPython()
if l_comment is not None:
dot_label += "\n\n" + "\n".join(wrapper.wrap((l_comment.toPython())))
if l_entity_exhibit_number is not None:
dot_label += "\nExhibit - " + l_entity_exhibit_number.toPython()
if l_entity_label is not None:
dot_label += "\n" + l_entity_label.toPython()
if l_entity_comment is not None:
dot_label += "\n\n" + "\n".join(wrapper.wrap((l_entity_comment.toPython())))
if entity_iri in collection_iris:
kwargs = clone_style(PROV_COLLECTION)
else:
kwargs = clone_style(prov.constants.PROV_ENTITY)
kwargs["label"] = dot_label
# _logger.debug("Entity %r.", entity_iri)
record = (iri_to_gv_node_id(entity_iri), kwargs)
nodes[entity_iri] = record
nodes_entities[entity_iri] = record
entity_record = (iri_to_gv_node_id(entity_iri), kwargs)
nodes[entity_iri] = entity_record
nodes_entities[entity_iri] = entity_record

# Render Activities.
select_query_text = """\
Expand Down Expand Up @@ -436,7 +469,18 @@ def main() -> None:
select_query_text, initNs=nsdict
)
for record in graph.query(select_query_object):
(n_activity, l_label, l_comment, l_start_time, l_end_time) = record
assert isinstance(record, rdflib.query.ResultRow)
assert isinstance(record[0], rdflib.term.IdentifiedNode)
assert record[1] is None or isinstance(record[1], rdflib.Literal)
assert record[2] is None or isinstance(record[2], rdflib.Literal)
assert record[3] is None or isinstance(record[3], rdflib.Literal)
assert record[4] is None or isinstance(record[4], rdflib.Literal)
n_activity = record[0]
l_label = record[1]
l_comment = record[2]
l_start_time = record[3]
l_end_time = record[4]

activity_iri = n_activity.toPython()
dot_label = "ID - " + graph.namespace_manager.qname(activity_iri)
if l_label is not None:
Expand All @@ -455,9 +499,9 @@ def main() -> None:
kwargs = clone_style(prov.constants.PROV_ACTIVITY)
kwargs["label"] = dot_label
# _logger.debug("Activity %r.", activity_iri)
record = (iri_to_gv_node_id(activity_iri), kwargs)
nodes[activity_iri] = record
nodes_activities[activity_iri] = record
activity_record = (iri_to_gv_node_id(activity_iri), kwargs)
nodes[activity_iri] = activity_record
nodes_activities[activity_iri] = activity_record

def _render_edges(
select_query_text: str,
Expand All @@ -469,15 +513,22 @@ def _render_edges(
select_query_text, initNs=nsdict
)
for record in graph.query(select_query_object):
(n_thing_1, n_thing_2) = record
assert isinstance(record, rdflib.query.ResultRow)
assert isinstance(record[0], rdflib.term.IdentifiedNode)
assert isinstance(record[1], rdflib.term.IdentifiedNode)
n_thing_1 = record[0]
n_thing_2 = record[1]

thing_1_iri = n_thing_1.toPython()
thing_2_iri = n_thing_2.toPython()
gv_node_id_1 = iri_to_gv_node_id(thing_1_iri)
gv_node_id_2 = iri_to_gv_node_id(thing_2_iri)
record = (gv_node_id_1, gv_node_id_2, kwargs)
edges[thing_1_iri][thing_2_iri][short_edge_label] = record
edge_record = (gv_node_id_1, gv_node_id_2, kwargs)
edges[thing_1_iri][thing_2_iri][short_edge_label] = edge_record
if supplemental_dict is not None:
supplemental_dict[thing_1_iri][thing_2_iri][short_edge_label] = record
supplemental_dict[thing_1_iri][thing_2_iri][
short_edge_label
] = edge_record

# Render actedOnBehalfOf.
select_query_text = """\
Expand Down Expand Up @@ -772,10 +823,10 @@ def _render_edges(
continue
for short_edge_label in sorted(edges[iri_1][iri_2]):
# short_edge_label is intentionally not used aside from as a selector. Edge labelling is left to pydot.
record = edges[iri_1][iri_2][short_edge_label]
node_id_1 = record[0]
node_id_2 = record[1]
kwargs = record[2]
edge_record = edges[iri_1][iri_2][short_edge_label]
node_id_1 = edge_record[0]
node_id_2 = edge_record[1]
kwargs = edge_record[2]
dot_edge = pydot.Edge(node_id_1, node_id_2, **kwargs)
dot_graph.add_edge(dot_edge)

Expand Down
8 changes: 5 additions & 3 deletions case_prov/case_prov_rdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
This script executes CONSTRUCT queries, returning a supplemental graph.
"""

__version__ = "0.3.0"
__version__ = "0.3.1"

import argparse
import importlib.resources
Expand Down Expand Up @@ -86,11 +86,13 @@ def main() -> None:
# https://rdfextras.readthedocs.io/en/latest/working_with.html
construct_query_result = in_graph.query(construct_query_object)
_logger.debug("len(construct_query_result) = %d." % len(construct_query_result))
for (row_no, row) in enumerate(construct_query_result):
for row_no, row in enumerate(construct_query_result):
if row_no == 0:
_logger.debug("row[0] = %r." % (row,))
tally = row_no + 1
out_graph.add(row)
# TODO: Handle type review with implementation to RDFLib Issue 2283.
# https://github.com/RDFLib/rdflib/issues/2283
out_graph.add(row) # type: ignore
if tally == 0:
if not args.allow_empty_results:
raise ValueError("Failed to construct any results.")
Expand Down
2 changes: 1 addition & 1 deletion case_prov/shapes/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ all: \
.%.ttl-check: \
%.ttl \
$(top_srcdir)/.git_submodule_init.done.log
java -jar $(top_srcdir)/dependencies/CASE-Examples-QC/dependencies/CASE-Examples/dependencies/UCO-develop/lib/rdf-toolkit.jar \
java -jar $(top_srcdir)/dependencies/CASE-Examples-QC/dependencies/CASE-Examples/dependencies/CASE-develop/dependencies/UCO/lib/rdf-toolkit.jar \
--inline-blank-nodes \
--source $< \
--source-format turtle \
Expand Down
2 changes: 1 addition & 1 deletion dependencies/CASE-Examples-QC
Submodule CASE-Examples-QC updated 43 files
+38 −0 .github/workflows/supply-chain.yml
+3 −0 .gitmodules
+2 −2 .pre-commit-config.yaml
+37 −1 Makefile
+1 −1 dependencies/CASE-Corpora
+1 −1 dependencies/CASE-Examples
+1 −1 dependencies/casework.github.io
+11 −6 src/confirm_singular_definitions.py
+7 −3 src/data_relationship_literals_tsv.py
+0 −131 src/import_closure.py
+1 −1 src/issue_430_conformance_sed.py
+7 −3 src/ontologies.py
+5 −3 src/ontology_classes_properties.py
+7 −3 src/ontology_relationship_literals_tsv.py
+2 −0 src/review_hashes.py
+1 −1 src/single_namespace_corrections_sed.py
+4 −2 src/vocabulary_used.py
+2 −2 tests/CASE-Corpora/catalog/README.md
+40 −0 tests/CASE-Corpora/catalog/undefined_concepts.txt
+1 −0 tests/CASE-Corpora/catalog/undefined_kindOfRelationships.tsv
+87 −8 tests/CASE-Corpora/catalog/used_concepts.txt
+1 −0 tests/CASE-Corpora/catalog/used_kindOfRelationships.tsv
+1 −1 tests/CASE-Corpora/catalog/wc_l_undefined_concepts.txt
+1 −1 tests/CASE-Corpora/catalog/wc_l_undefined_kindOfRelationships.txt
+1 −1 tests/CASE-Examples/examples/illustrations/src/review.mk
+3 −3 tests/casework.github.io/examples/README.md
+1 −1 tests/casework.github.io/examples/crossover_heist/README.md
+0 −6 tests/casework.github.io/examples/crossover_heist/undefined_concepts.txt
+6 −6 tests/casework.github.io/examples/crossover_heist/used_concepts.txt
+1 −1 tests/casework.github.io/examples/hardware_duplicator/README.md
+0 −7 tests/casework.github.io/examples/hardware_duplicator/undefined_concepts.txt
+7 −7 tests/casework.github.io/examples/hardware_duplicator/used_concepts.txt
+1 −1 tests/casework.github.io/examples/src/review.mk
+3 −10 tests/casework.github.io/examples/undefined_concepts.txt
+3 −3 tests/casework.github.io/examples/urgent_evidence/undefined_concepts.txt
+3 −3 tests/casework.github.io/examples/urgent_evidence/used_concepts.txt
+3 −10 tests/casework.github.io/examples/used_concepts.txt
+1 −1 tests/postvisit.mk
+5 −4 tests/rdfs/test_rdfs_terms.py
+43 −10 tests/undefined_concepts.txt
+1 −0 tests/undefined_kindOfRelationships.tsv
+50 −18 tests/used_concepts.txt
+1 −0 tests/used_kindOfRelationships.tsv
Loading

0 comments on commit ee10dc6

Please sign in to comment.