|
1 | | -import argparse |
2 | 1 | from pathlib import Path |
3 | 2 | import subprocess as sub |
4 | 3 | from typing import Dict, Union |
|
8 | 7 |
|
9 | 8 | def find_output_dirs(data: Union[RoseTree, Dict, list]) -> list: |
10 | 9 | """ |
11 | | - Recursively searches through a nested structure and finds all dictionaries |
| 10 | + Recursively searches through a nested structure and finds all dictionaries |
12 | 11 | that contain the key 'location', and a key 'class' with a value of 'Directory'. |
13 | 12 |
|
14 | 13 | Args: |
15 | | - data (any): The data to search through, which can be a dictionary, list, |
| 14 | + data (any): The data to search through, which can be a dictionary, list, |
16 | 15 | or any other structure. |
17 | 16 |
|
18 | 17 | Returns: |
@@ -53,38 +52,33 @@ def find_and_create_output_dirs(rose_tree: RoseTree, basepath: str = 'autogenera |
53 | 52 | create_output_dirs(output_dirs, basepath) |
54 | 53 |
|
55 | 54 |
|
56 | | -def cwl_docker_extract(args: argparse.Namespace, file_name: str) -> None: |
| 55 | +def cwl_docker_extract(container_engine: str, pull_dir: str, file_name: str) -> None: |
57 | 56 | """Helper function to do the cwl_docker_extract""" |
58 | 57 | # cwl-docker-extract recursively `docker pull`s all images in all subworkflows. |
59 | 58 | # This is important because cwltool only uses `docker run` when executing |
60 | 59 | # workflows, and if there is a local image available, |
61 | 60 | # `docker run` will NOT query the remote repository for the latest image! |
62 | 61 | # cwltool has a --force-docker-pull option, but this may cause multiple pulls in parallel. |
63 | | - if args.container_engine == 'singularity': |
| 62 | + if container_engine == 'singularity': |
64 | 63 | cmd = ['cwl-docker-extract', '-s', '--dir', |
65 | | - f'{args.singularity_pull_dir}', f'autogenerated/{file_name}.cwl'] |
| 64 | + f'{pull_dir}', f'autogenerated/{file_name}.cwl'] |
66 | 65 | else: |
67 | 66 | cmd = ['cwl-docker-extract', '--force-download', f'autogenerated/{file_name}.cwl'] |
68 | 67 | sub.run(cmd, check=True) |
69 | 68 |
|
70 | 69 |
|
71 | | -def cwl_inline_runtag(args: argparse.Namespace, rose_tree: RoseTree) -> RoseTree: |
| 70 | +def cwl_inline_runtag(rose_tree: RoseTree) -> RoseTree: |
72 | 71 | """Transform with cwl inline runtag""" |
73 | 72 | # this has to happen after at least one write |
74 | 73 | # so we can copy from local cwl_dapters in autogenerated/ |
75 | | - if args.cwl_inline_runtag: |
76 | | - rose_tree = plugins.cwl_update_inline_runtag_rosetree(rose_tree, Path('autogenerated/'), True) |
77 | | - return rose_tree |
| 74 | + return plugins.cwl_update_inline_runtag_rosetree(rose_tree, Path('autogenerated/'), True) |
78 | 75 |
|
79 | 76 |
|
80 | | -def remove_entrypoints(args: argparse.Namespace, rose_tree: RoseTree) -> RoseTree: |
| 77 | +def remove_entrypoints(container_engine: str, rose_tree: RoseTree) -> RoseTree: |
81 | 78 | """Remove entry points""" |
82 | | - if args.docker_remove_entrypoints: |
83 | | - # Requires root, so guard behind CLI option |
84 | | - if args.container_engine == 'docker': |
85 | | - plugins.remove_entrypoints_docker() |
86 | | - if args.container_engine == 'podman': |
87 | | - plugins.remove_entrypoints_podman() |
88 | | - |
89 | | - rose_tree = plugins.dockerPull_append_noentrypoint_rosetree(rose_tree) |
90 | | - return rose_tree |
| 79 | + # Requires root, so guard behind CLI option |
| 80 | + if container_engine == 'docker': |
| 81 | + plugins.remove_entrypoints_docker() |
| 82 | + if container_engine == 'podman': |
| 83 | + plugins.remove_entrypoints_podman() |
| 84 | + return plugins.dockerPull_append_noentrypoint_rosetree(rose_tree) |
0 commit comments