Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional parts for exporting local_uuid #144

Merged
merged 6 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions case_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,3 @@
# We would appreciate acknowledgement if the software is used.

__version__ = "0.14.1.post0"

from . import local_uuid # noqa: F401
16 changes: 8 additions & 8 deletions case_utils/case_file/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
import typing
import warnings

import cdo_local_uuid
import rdflib
from cdo_local_uuid import local_uuid

import case_utils.inherent_uuid
from case_utils.namespace import (
Expand Down Expand Up @@ -94,7 +96,7 @@ def create_file_node(
node_namespace = rdflib.Namespace(node_prefix)

if node_iri is None:
node_slug = "File-" + case_utils.local_uuid.local_uuid()
node_slug = "File-" + local_uuid()
node_iri = node_namespace[node_slug]
n_file = rdflib.URIRef(node_iri)
graph.add((n_file, NS_RDF.type, NS_UCO_OBSERVABLE.File))
Expand All @@ -110,7 +112,7 @@ def create_file_node(
n_file, NS_UCO_OBSERVABLE.FileFacet, namespace=node_namespace
)
else:
n_file_facet = node_namespace["FileFacet-" + case_utils.local_uuid.local_uuid()]
n_file_facet = node_namespace["FileFacet-" + local_uuid()]

graph.add(
(
Expand Down Expand Up @@ -144,9 +146,7 @@ def create_file_node(
n_file, NS_UCO_OBSERVABLE.ContentDataFacet, namespace=node_namespace
)
else:
n_contentdata_facet = node_namespace[
"ContentDataFacet-" + case_utils.local_uuid.local_uuid()
]
n_contentdata_facet = node_namespace["ContentDataFacet-" + local_uuid()]

graph.add((n_file, NS_UCO_CORE.hasFacet, n_contentdata_facet))
graph.add(
Expand Down Expand Up @@ -248,7 +248,7 @@ def create_file_node(
)
)
else:
hash_uuid = case_utils.local_uuid.local_uuid()
hash_uuid = local_uuid()
n_hash = node_namespace["Hash-" + hash_uuid]

graph.add((n_contentdata_facet, NS_UCO_OBSERVABLE.hash, n_hash))
Expand Down Expand Up @@ -291,7 +291,7 @@ def main() -> None:

logging.basicConfig(level=logging.DEBUG if args.debug else logging.INFO)

case_utils.local_uuid.configure()
cdo_local_uuid.configure()

NS_BASE = rdflib.Namespace(args.base_prefix)

Expand All @@ -314,7 +314,7 @@ def main() -> None:
context_dictionary = {k: v for (k, v) in graph.namespace_manager.namespaces()}
serialize_kwargs["context"] = context_dictionary

node_iri = NS_BASE["File-" + case_utils.local_uuid.local_uuid()]
node_iri = NS_BASE["File-" + local_uuid()]
create_file_node(
graph,
args.in_file,
Expand Down
2 changes: 1 addition & 1 deletion case_utils/inherent_uuid.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
2. A pattern based on inherence generates UUIDv5s based on how an inherent object (a.k.a. UcoInherentCharacterizationThing) structurally relates to the object in which it inheres. For instance, a Facet is understood to only relate to its UcoObject by linking with the uco-core:hasFacet property. So, a Facet's UUID is determined uniquely by (1) the "UUID namespace" of its corresponding UcoObject, and (2) its OWL Class.
A. The term "UUID namespace" is described in RFC 4122 Section 4.3 [#rfc4122s43]_ , and is not intended be confused with `rdflib.term.Namespace`. For any uco-core:UcoThing (or even owl:Thing), the function `inherence_uuid` defines the procedure for either extracting or generating a UUID for use as a namespace.

This module is independent of, and complements, `case_utils.local_uuid`, which provides deterministic UUIDs based on calling process's environment.
This module is independent of, and complements, `cdo_local_uuid.local_uuid`, which provides deterministic UUIDs based on calling process's environment.

References
==========
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ license_files =
[options]
include_package_data = true
install_requires =
cdo-local-uuid >= 0.4.0, < 0.5.0
cdo-local-uuid >= 0.5.0, < 0.6.0
pandas
pyshacl >= 0.24.0
rdflib < 8
Expand Down
12 changes: 4 additions & 8 deletions tests/case_utils/case_file/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,10 @@ sample.txt.json: \
$(tests_srcdir)/src/isomorphic_diff.py \
$(top_srcdir)/case_utils/case_file/__init__.py \
$(top_srcdir)/case_utils/inherent_uuid.py \
$(top_srcdir)/case_utils/local_uuid.py \
$(top_srcdir)/case_utils/namespace.py \
sample.txt-nocompact.json
rm -f $@ _$@ __$@
export CASE_DEMO_NONRANDOM_UUID_BASE="$(top_srcdir)" \
export CDO_DEMO_NONRANDOM_UUID_BASE="$(top_srcdir)" \
&& source $(tests_srcdir)/venv/bin/activate \
&& case_file \
--debug \
Expand Down Expand Up @@ -152,11 +151,10 @@ sample.txt.ttl: \
$(tests_srcdir)/.venv.done.log \
$(top_srcdir)/case_utils/case_file/__init__.py \
$(top_srcdir)/case_utils/inherent_uuid.py \
$(top_srcdir)/case_utils/local_uuid.py \
$(top_srcdir)/case_utils/namespace.py \
sample.txt.done.log
rm -f _$@ __$@
export CASE_DEMO_NONRANDOM_UUID_BASE="$(top_srcdir)" \
export CDO_DEMO_NONRANDOM_UUID_BASE="$(top_srcdir)" \
&& source $(tests_srcdir)/venv/bin/activate \
&& case_file \
--debug \
Expand All @@ -178,11 +176,10 @@ sample.txt-disable_hashes.ttl: \
$(tests_srcdir)/.venv.done.log \
$(top_srcdir)/case_utils/case_file/__init__.py \
$(top_srcdir)/case_utils/inherent_uuid.py \
$(top_srcdir)/case_utils/local_uuid.py \
$(top_srcdir)/case_utils/namespace.py \
sample.txt.done.log
rm -f _$@ __$@
export CASE_DEMO_NONRANDOM_UUID_BASE="$(top_srcdir)" \
export CDO_DEMO_NONRANDOM_UUID_BASE="$(top_srcdir)" \
&& source $(tests_srcdir)/venv/bin/activate \
&& case_file \
--debug \
Expand All @@ -206,11 +203,10 @@ sample.txt-nocompact.json: \
$(tests_srcdir)/src/isomorphic_diff.py \
$(top_srcdir)/case_utils/case_file/__init__.py \
$(top_srcdir)/case_utils/inherent_uuid.py \
$(top_srcdir)/case_utils/local_uuid.py \
$(top_srcdir)/case_utils/namespace.py \
sample.txt.done.log
rm -f _$@
export CASE_DEMO_NONRANDOM_UUID_BASE="$(top_srcdir)" \
export CDO_DEMO_NONRANDOM_UUID_BASE="$(top_srcdir)" \
&& source $(tests_srcdir)/venv/bin/activate \
&& case_file \
--debug \
Expand Down
37 changes: 0 additions & 37 deletions tests/case_utils/test_local_uuid.py

This file was deleted.