From d4a868f4b79faa763c902d584db9905955218c7f Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Wed, 13 Dec 2023 13:33:12 -0500 Subject: [PATCH 1/5] Remove exported local_uuid tests Signed-off-by: Alex Nelson --- tests/case_utils/test_local_uuid.py | 37 ----------------------------- 1 file changed, 37 deletions(-) delete mode 100644 tests/case_utils/test_local_uuid.py diff --git a/tests/case_utils/test_local_uuid.py b/tests/case_utils/test_local_uuid.py deleted file mode 100644 index 40969fb..0000000 --- a/tests/case_utils/test_local_uuid.py +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env python3 - -# Portions of this file contributed by NIST are governed by the following -# statement: -# -# 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 within the United States. 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. - -import pytest - -import case_utils.local_uuid - - -def test_local_uuid_deprecation(monkeypatch: pytest.MonkeyPatch) -> None: - monkeypatch.setenv("DEMO_UUID_REQUESTING_NONRANDOM", "NONRANDOM_REQUESTED") - with pytest.warns(FutureWarning): - case_utils.local_uuid.configure() - - -def test_local_uuid_nondirectory(monkeypatch: pytest.MonkeyPatch) -> None: - monkeypatch.setenv("CASE_DEMO_NONRANDOM_UUID_BASE", "/dev/null") - with pytest.warns(RuntimeWarning): - case_utils.local_uuid.configure() - - -def test_local_uuid_nonexistent(monkeypatch: pytest.MonkeyPatch) -> None: - monkeypatch.setenv("CASE_DEMO_NONRANDOM_UUID_BASE", "/dev/nonexistent") - with pytest.warns(RuntimeWarning): - case_utils.local_uuid.configure() From d92c753829b4ae85ec19c24f74cb68777c1c5ada Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Wed, 13 Dec 2023 13:33:29 -0500 Subject: [PATCH 2/5] Fix module reference Signed-off-by: Alex Nelson --- case_utils/inherent_uuid.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/case_utils/inherent_uuid.py b/case_utils/inherent_uuid.py index cdcba73..92c2056 100644 --- a/case_utils/inherent_uuid.py +++ b/case_utils/inherent_uuid.py @@ -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 ========== From d8a8b0816cefc6e47f4316f020252896e29ce5d0 Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Wed, 13 Dec 2023 13:35:28 -0500 Subject: [PATCH 3/5] Replace case_utils.local_uuid usage in case_file Signed-off-by: Alex Nelson --- case_utils/case_file/__init__.py | 16 ++++++++-------- tests/case_utils/case_file/Makefile | 4 ---- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/case_utils/case_file/__init__.py b/case_utils/case_file/__init__.py index 5f797fc..313acc6 100644 --- a/case_utils/case_file/__init__.py +++ b/case_utils/case_file/__init__.py @@ -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 ( @@ -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)) @@ -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( ( @@ -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( @@ -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)) @@ -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) @@ -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, diff --git a/tests/case_utils/case_file/Makefile b/tests/case_utils/case_file/Makefile index d65fb40..58b2b48 100644 --- a/tests/case_utils/case_file/Makefile +++ b/tests/case_utils/case_file/Makefile @@ -117,7 +117,6 @@ 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 $@ _$@ __$@ @@ -152,7 +151,6 @@ 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 _$@ __$@ @@ -178,7 +176,6 @@ 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 _$@ __$@ @@ -206,7 +203,6 @@ 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 _$@ From 65cdcdaedcb9ea09ab4971889279b4a37749be1e Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Wed, 13 Dec 2023 13:45:28 -0500 Subject: [PATCH 4/5] Remove re-export of local_uuid Before this patch, the `pytest` calls in unit testing raise the `DeprecationWarning` from `case_utils.local_uuid`. E.g. both of these test files would raise the warning: (test1.py) ```python def test_foo() -> None: import case_utils ``` ```bash pytest test1.py # Logs deprecation warning. ``` (test2.py) ```python import case_utils def test_foo() -> None: pass ``` ```bash pytest test2.py # Logs deprecation warning. ``` This patch removes the module re-export. Signed-off-by: Alex Nelson --- case_utils/__init__.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/case_utils/__init__.py b/case_utils/__init__.py index 1421b3e..cb6dcc8 100644 --- a/case_utils/__init__.py +++ b/case_utils/__init__.py @@ -15,5 +15,3 @@ # We would appreciate acknowledgement if the software is used. __version__ = "0.14.0" - -from . import local_uuid # noqa: F401 From 6effb639f923d4156322fc4320cb9fb9e888d65e Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Tue, 9 Jan 2024 13:30:00 -0800 Subject: [PATCH 5/5] Bump cdo-local-uuid and update test calls References: * https://github.com/Cyber-Domain-Ontology/CDO-Utility-Local-UUID/pull/2 Signed-off-by: Alex Nelson --- setup.cfg | 2 +- tests/case_utils/case_file/Makefile | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/setup.cfg b/setup.cfg index e40529f..38c1230 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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 diff --git a/tests/case_utils/case_file/Makefile b/tests/case_utils/case_file/Makefile index 58b2b48..742315c 100644 --- a/tests/case_utils/case_file/Makefile +++ b/tests/case_utils/case_file/Makefile @@ -120,7 +120,7 @@ sample.txt.json: \ $(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 \ @@ -154,7 +154,7 @@ sample.txt.ttl: \ $(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 \ @@ -179,7 +179,7 @@ sample.txt-disable_hashes.ttl: \ $(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 \ @@ -206,7 +206,7 @@ sample.txt-nocompact.json: \ $(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 \