Skip to content

Commit

Permalink
Guessing the workflow repository from RO-Crate fixed from regression.
Browse files Browse the repository at this point in the history
In the future, all the method must be completely rewritten in order
to query JSON-LD through rdflib and SPARQL. But for now, the code
uses the trick of parsing it as JSON and finding the linked data
within it.
  • Loading branch information
jmfernandez committed Aug 31, 2023
1 parent 122eb68 commit 18b5569
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions wfexs_backend/wfexs_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -2061,6 +2061,7 @@ def getWorkflowRepoFromROCrateFile(
mainEntityId = None
workflowPID = None
workflowUploadURL = None
workflowRepoURL = None
workflowTypeId = None
for e in roCrateObj.get_entities():
if (
Expand All @@ -2072,6 +2073,7 @@ def getWorkflowRepoFromROCrateFile(
elif e["@id"] == mainEntityIdHolder:
eAsLD = e.as_jsonld()
mainEntityId = eAsLD["mainEntity"]["@id"]
workflowRepoURL = eAsLD.get("isBasedOn")
workflowPID = eAsLD.get("identifier")
elif e["@id"] == mainEntityId:
eAsLD = e.as_jsonld()
Expand Down Expand Up @@ -2140,14 +2142,24 @@ def getWorkflowRepoFromROCrateFile(
# Some RO-Crates might have this value missing or ill-built
remote_repo: "Optional[RemoteRepo]" = None
if workflowUploadURL is not None:
remote_repo = self.guess_repo_params(workflowUploadURL, fail_ok=True)
try:
remote_repo = self.guess_repo_params(workflowUploadURL, fail_ok=True)
except:
self.logger.exception(
f"Unable to use RO-Crate derived {workflowUploadURL} as workflow source"
)

if remote_repo is None:
remote_repo = self.guess_repo_params(
roCrateObj.root_dataset["isBasedOn"], fail_ok=True
)
if workflowRepoURL is not None and (
remote_repo is None or remote_repo.repo_type is None
):
try:
remote_repo = self.guess_repo_params(workflowRepoURL, fail_ok=True)
except:
self.logger.exception(
f"Unable to use RO-Crate derived {workflowRepoURL} as workflow source"
)

if remote_repo is None:
if remote_repo is None or remote_repo.repo_type is None:
raise WfExSBackendException(
"Unable to guess repository from RO-Crate manifest"
)
Expand Down

0 comments on commit 18b5569

Please sign in to comment.