Skip to content

Commit

Permalink
Merge pull request #215 from FAIRDataPipeline/hotfix/ro-crate
Browse files Browse the repository at this point in the history
Hotfix/ro crate
  • Loading branch information
RyanJField authored Oct 23, 2023
2 parents 82a7ad7 + 6424daa commit fcba13a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ license: "BSD-2-Clause"
message: "If you use this software, please cite it using these metadata."
repository-code: "https://github.com/FAIRDataPipeline/data-registry/"
title: "The FAIR Data Registry"
version: "v1.0.9"
version: "v1.0.10"
doi: "10.5281/zenodo.5562750"
date-released: "2023-02-03"
33 changes: 33 additions & 0 deletions data_management/rocrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,17 @@

from data_management.views import external_object

import requests

from . import models
from . import settings


RO_TYPE = "@type"
FILE = "file:"
SHA1 = {"sha1": "https://w3id.org/ro/terms/workflow-run#sha1"}
CLI_URL = "https://github.com/FAIRDataPipeline/FAIR-CLI"
REMOTE_STORAGE_ROOT = "https://data.fairdatapipeline.org/data/"


def _add_authors(authors, crate, entity, registry_url):
Expand Down Expand Up @@ -628,6 +632,7 @@ def _get_local_data_product(crate, data_product, registry_url, output):
@return an RO Crate file entity representing the data product
"""
_fetch_remote = False
if (
data_product.object.storage_location.public is True
and len(str(data_product.object.storage_location).split(FILE)) > 1
Expand All @@ -639,6 +644,20 @@ def _get_local_data_product(crate, data_product, registry_url, output):
else:
dest_path = f"inputs/data/{source_loc.split('/')[-1]}"

elif (
data_product.object.storage_location.public is True
and settings.REMOTE_REGISTRY
):
file_name = str(data_product.object.storage_location).split('/')[-1]
_ext = data_product.object.file_type.extension
source_loc = data_product.object.storage_location.full_uri()

if output:
dest_path = f"outputs/{file_name}.{_ext}"
else:
dest_path = f"inputs/data/{file_name}.{_ext}"
_fetch_remote = True

else:
source_loc = f"{registry_url}api/storage_location/{data_product.object.storage_location.id}"
dest_path = None
Expand All @@ -661,6 +680,7 @@ def _get_local_data_product(crate, data_product, registry_url, output):
source_loc,
dest_path=dest_path,
properties=properties,
fetch_remote = _fetch_remote
)

return crate_data_product
Expand Down Expand Up @@ -695,13 +715,25 @@ def _get_software(crate, software_object, registry_url, software_type):
@return an RO Crate file entity representing the model configuration
"""
_fetch_remote = False
if (
software_object.storage_location.public is True
and len(str(software_object.storage_location).split(FILE)) > 1
):
source_loc = str(software_object.storage_location).split(FILE)[1]
dest_path = f"inputs/{software_type}/{source_loc.split('/')[-1]}"

elif (
software_object.storage_location.public is True
and settings.REMOTE_REGISTRY
):
file_name = str(software_object.storage_location).split('/')[-1]
_ext = software_object.file_type.extension
source_loc = software_object.storage_location.full_uri()

dest_path = f"inputs/{software_type}/{file_name}.{_ext}"
_fetch_remote = True

else:
source_loc = (
f"{registry_url}api/storage_location/{software_object.storage_location.id}"
Expand All @@ -715,6 +747,7 @@ def _get_software(crate, software_object, registry_url, software_type):
RO_TYPE: ["File", "SoftwareSourceCode"],
"name": str(software_object.storage_location).split("/")[-1],
},
fetch_remote = _fetch_remote
)

if software_object.description is not None:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ authors = [
]
description = "Codebase for the FAIR data-registry"
name = "data-registry"
version = "v1.0.9"
version = "v1.0.10"

[tool.poetry.dependencies]
Django = "3.1.13"
Expand Down

0 comments on commit fcba13a

Please sign in to comment.