From b8f4dc0bb5d4708bac90504b59d7779046218cc5 Mon Sep 17 00:00:00 2001 From: Antony Wilson Date: Thu, 13 Jul 2023 10:52:22 +0100 Subject: [PATCH 1/5] #207 Fix issue with windows paths When generating a `full_uri` a `\` was used to join the storage_root and the path. ``` if (self.storage_root.root.startswith('/') or self.storage_root.root.startswith('file://')) and not self.storage_root.root.endswith('/'): return self.storage_root.root + '/' + self.path return self.storage_root.root + self.path ``` This has been replaced with: ``` relative_path = self.path.lstrip("/").lstrip("\\") return os.path.join(self.storage_root.root, relative_path) ``` --- data_management/models.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/data_management/models.py b/data_management/models.py index 3b9b520..f75b351 100644 --- a/data_management/models.py +++ b/data_management/models.py @@ -1,3 +1,4 @@ +import os import hashlib from uuid import uuid4, UUID @@ -494,9 +495,9 @@ class Meta: ] def full_uri(self): - if (self.storage_root.root.startswith('/') or self.storage_root.root.startswith('file://')) and not self.storage_root.root.endswith('/'): - return self.storage_root.root + '/' + self.path - return self.storage_root.root + self.path + # ensure we use a relative path before we do the join + relative_path = self.path.lstrip("/").lstrip("\\") + return os.path.join(self.storage_root.root, relative_path) def __str__(self): return self.full_uri() From 6ae671fe0472eac563b409f79dc9d828a3c47bec Mon Sep 17 00:00:00 2001 From: Antony Wilson Date: Thu, 13 Jul 2023 10:59:43 +0100 Subject: [PATCH 2/5] #210 fix link in prov report to `users` Update the link from `user` to `users` --- data_management/prov.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data_management/prov.py b/data_management/prov.py index 8424c2c..5fa548f 100644 --- a/data_management/prov.py +++ b/data_management/prov.py @@ -235,7 +235,7 @@ def _add_code_run(dp_entity, doc, code_run, reg_uri_prefix, vocab_namespaces): user_authors = models.UserAuthor.objects.filter(user=code_run.updated_by) if len(user_authors) == 0: run_agent = doc.agent( - f'{reg_uri_prefix}:api/user/{code_run.updated_by.id}', + f'{reg_uri_prefix}:api/users/{code_run.updated_by.id}', { QualifiedName( vocab_namespaces[RDF_VOCAB_PREFIX], 'type' From 4d2ac7e3a84eef4c9bca4f4ca9cd8068222918c9 Mon Sep 17 00:00:00 2001 From: Antony Wilson Date: Thu, 13 Jul 2023 11:15:48 +0100 Subject: [PATCH 3/5] fix prov tests --- data_management/tests/test_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data_management/tests/test_api.py b/data_management/tests/test_api.py index 1d234b6..e00c99c 100644 --- a/data_management/tests/test_api.py +++ b/data_management/tests/test_api.py @@ -971,7 +971,7 @@ def test_get_json(self): ) expected_result = { - self.PROV_AT_LOCATION: "https://github.comScottishCovidResponse/SCRCdata repository", + self.PROV_AT_LOCATION: "https://github.com/ScottishCovidResponse/SCRCdata repository", self.DCTERMS_TITLE: "ScottishCovidResponse/SCRCdata", self.DCAT_HAS_VERSION: "0.1.0", "fair:website": "https://github.com/ScottishCovidResponse/SCRCdata", From 5f24727aef8a05edfb8ef9515db0e64ee0bae2a1 Mon Sep 17 00:00:00 2001 From: Antony Wilson Date: Thu, 13 Jul 2023 11:25:46 +0100 Subject: [PATCH 4/5] fix prov test --- data_management/tests/test_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data_management/tests/test_api.py b/data_management/tests/test_api.py index e00c99c..15e6d2d 100644 --- a/data_management/tests/test_api.py +++ b/data_management/tests/test_api.py @@ -852,7 +852,7 @@ class ProvAPITests(TestCase): LREG_CODE_RUN = "lreg:api/code_run/" LREG_DATA_PRODUCT = "lreg:api/data_product/" LREG_OBJECT = "lreg:api/object/" - LREG_USER = "lreg:api/user/" + LREG_USER = "lreg:api/users/" FAIR_INPUT_DATA = "fair:input_data" FAIR_NAMESPACE = "fair:namespace" PROV_AGENT = "prov:agent" From 598dc48615acc7559912e70f2dca8b7279b54efe Mon Sep 17 00:00:00 2001 From: Antony Wilson Date: Thu, 13 Jul 2023 11:29:26 +0100 Subject: [PATCH 5/5] Fix link in ROCrate to `users` The link in ROCrate now points to `users` instead of `user` --- data_management/rocrate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data_management/rocrate.py b/data_management/rocrate.py index 6f196ab..8561238 100644 --- a/data_management/rocrate.py +++ b/data_management/rocrate.py @@ -457,7 +457,7 @@ def _get_code_run(crate_data_product, crate, code_run, registry_url): user_authors = models.UserAuthor.objects.filter(user=code_run.updated_by) if len(user_authors) == 0: - agent_id = f"{registry_url}api/user/{code_run.updated_by.id}" + agent_id = f"{registry_url}api/users/{code_run.updated_by.id}" crate.add( Person( crate, agent_id, properties={"name": code_run.updated_by.full_name()}