Skip to content

Commit

Permalink
Trying a better handling of cases where the workflow is a single file…
Browse files Browse the repository at this point in the history
… with no origin in a repository
  • Loading branch information
jmfernandez committed Jul 10, 2023
1 parent df7a68c commit df23753
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions wfexs_backend/wfexs_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -1488,6 +1488,7 @@ def cacheWorkflow(
(
i_workflow,
cached_putative_path,
metadata_array,
) = self.getWorkflowBundleFromURI(
cast("URIType", workflow_id),
offline=offline,
Expand All @@ -1498,11 +1499,16 @@ def cacheWorkflow(
self.cacheROCrateFilename = cached_putative_path
else:
repoDir = cached_putative_path
if len(parsedRepoURL.fragment) > 0:
frag_qs = urllib.parse.parse_qs(parsedRepoURL.fragment)
subDirArr = frag_qs.get("subdirectory", [])
if len(subDirArr) > 0:
repoRelPath = subDirArr[0]
if os.path.isdir(repoDir):
if len(parsedRepoURL.fragment) > 0:
frag_qs = urllib.parse.parse_qs(parsedRepoURL.fragment)
subDirArr = frag_qs.get("subdirectory", [])
if len(subDirArr) > 0:
repoRelPath = subDirArr[0]
elif len(metadata_array) > 0:
# Let's try getting a pretty filename
# when the workflow is a single file
repoRelPath = metadata_array[0].preferredName
putative = True

if i_workflow is not None:
Expand Down Expand Up @@ -1778,6 +1784,7 @@ def getWorkflowRepoFromTRS(
(
i_workflow,
self.cacheROCrateFilename,
metadata_array,
) = self.getWorkflowBundleFromURI(
roCrateURL,
expectedEngineDesc=WF.RECOGNIZED_TRS_DESCRIPTORS[chosenDescriptorType],
Expand Down Expand Up @@ -1961,7 +1968,7 @@ def getWorkflowBundleFromURI(
offline: "bool" = False,
ignoreCache: "bool" = False,
registerInCache: "bool" = True,
) -> "Tuple[Optional[IdentifiedWorkflow], AbsPath]":
) -> "Tuple[Optional[IdentifiedWorkflow], AbsPath, Sequence[URIWithMetadata]]":
try:
cached_content = self.cacheFetch(
remote_url,
Expand Down Expand Up @@ -2003,11 +2010,13 @@ def getWorkflowBundleFromURI(
cast("AbsPath", roCrateFile), expectedEngineDesc
),
cast("AbsPath", roCrateFile),
cached_content.metadata_array,
)
else:
return (
None,
cached_content.path,
cached_content.metadata_array,
)

def getWorkflowRepoFromROCrateFile(
Expand Down

0 comments on commit df23753

Please sign in to comment.