Skip to content

Commit

Permalink
Merge pull request #214 from FAIRDataPipeline/bugfix/windows-path/pro…
Browse files Browse the repository at this point in the history
…v-report

Bugfix/windows path/prov report
  • Loading branch information
RyanJField authored Jan 18, 2024
2 parents 5cbffb8 + 598dc48 commit 1ae2b5a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
7 changes: 4 additions & 3 deletions data_management/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import hashlib
from uuid import uuid4, UUID

Expand Down Expand Up @@ -493,9 +494,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()
Expand Down
2 changes: 1 addition & 1 deletion data_management/prov.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion data_management/rocrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,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()}
Expand Down
4 changes: 2 additions & 2 deletions data_management/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 1ae2b5a

Please sign in to comment.