From 6558c1b7cbb90e5c92dbd0b27894a29c78f78092 Mon Sep 17 00:00:00 2001 From: Manabu ISHII Date: Thu, 30 Sep 2021 00:22:14 +0900 Subject: [PATCH 1/2] Support for subworkflows If workflow has subworkflow, current version can not resolve relative path for step workflow. --- cwl_utils/docker_extract.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cwl_utils/docker_extract.py b/cwl_utils/docker_extract.py index 8f3fdc18..47949900 100755 --- a/cwl_utils/docker_extract.py +++ b/cwl_utils/docker_extract.py @@ -14,7 +14,7 @@ ) ProcessType = Union[cwl.Workflow, cwl.CommandLineTool, cwl.ExpressionTool] - +WorkflowDir = "" def parse_args() -> argparse.Namespace: """Argument parser.""" @@ -34,9 +34,11 @@ def parse_args() -> argparse.Namespace: def main(args: argparse.Namespace) -> None: """Extract the docker reqs and download them using Singularity or docker.""" + global WorkflowDir os.makedirs(args.dir, exist_ok=True) top = cwl.load_document(args.input) + WorkflowDir = str(Path(args.input).parent)+"/" for req in traverse(top): if not req.dockerPull: @@ -86,7 +88,7 @@ def traverse(process: ProcessType) -> Iterator[cwl.DockerRequirement]: def get_process_from_step(step: cwl.WorkflowStep) -> ProcessType: """Return the process for this step, loading it if necessary.""" if isinstance(step.run, str): - return cast(ProcessType, cwl.load_document(step.run)) + return cast(ProcessType, cwl.load_document(WorkflowDir+step.run)) return cast(ProcessType, step.run) From 8a130c905b0bd086bc3fdf06e4fa685c8ca6b1a7 Mon Sep 17 00:00:00 2001 From: Manabu ISHII Date: Thu, 30 Sep 2021 00:24:32 +0900 Subject: [PATCH 2/2] Fix missing global --- cwl_utils/docker_extract.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cwl_utils/docker_extract.py b/cwl_utils/docker_extract.py index 47949900..50d39256 100755 --- a/cwl_utils/docker_extract.py +++ b/cwl_utils/docker_extract.py @@ -87,6 +87,7 @@ def traverse(process: ProcessType) -> Iterator[cwl.DockerRequirement]: def get_process_from_step(step: cwl.WorkflowStep) -> ProcessType: """Return the process for this step, loading it if necessary.""" + global WorkflowDir if isinstance(step.run, str): return cast(ProcessType, cwl.load_document(WorkflowDir+step.run)) return cast(ProcessType, step.run)