-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor some common transformations into post_compile
- Loading branch information
Vasu Jaganath
committed
Oct 16, 2024
1 parent
846cec8
commit c37e7e3
Showing
5 changed files
with
57 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import argparse | ||
from pathlib import Path | ||
import subprocess as sub | ||
|
||
from . import plugins | ||
from . import input_output as io | ||
from .wic_types import RoseTree | ||
|
||
|
||
def cwl_docker_extract(args: argparse.Namespace, file_name: str) -> None: | ||
"""Helper function to do the cwl_docker_extract""" | ||
# cwl-docker-extract recursively `docker pull`s all images in all subworkflows. | ||
# This is important because cwltool only uses `docker run` when executing | ||
# workflows, and if there is a local image available, | ||
# `docker run` will NOT query the remote repository for the latest image! | ||
# cwltool has a --force-docker-pull option, but this may cause multiple pulls in parallel. | ||
if args.container_engine == 'singularity': | ||
cmd = ['cwl-docker-extract', '-s', '--dir', | ||
f'{args.singularity_pull_dir}', f'autogenerated/{file_name}.cwl'] | ||
else: | ||
cmd = ['cwl-docker-extract', '--force-download', f'autogenerated/{file_name}.cwl'] | ||
sub.run(cmd, check=True) | ||
|
||
|
||
def cwl_inline_runtag(args: argparse.Namespace, rose_tree: RoseTree) -> None: | ||
"""Transform with cwl inline runtag""" | ||
# this has to happen after at least one write | ||
# so we can copy from local cwl_dapters in autogenerated/ | ||
if args.inline_cwl_runtag: | ||
rose_tree = plugins.cwl_update_inline_runtag_rosetree(rose_tree, Path('autogenerated/'), True) | ||
|
||
|
||
def remove_entrypoints(args: argparse.Namespace, rose_tree: RoseTree) -> None: | ||
"""Remove entry points""" | ||
if args.docker_remove_entrypoints: | ||
# Requires root, so guard behind CLI option | ||
if args.container_engine == 'docker': | ||
plugins.remove_entrypoints_docker() | ||
if args.container_engine == 'podman': | ||
plugins.remove_entrypoints_podman() | ||
|
||
rose_tree = plugins.dockerPull_append_noentrypoint_rosetree(rose_tree) | ||
io.write_to_disk(rose_tree, Path('autogenerated/'), True, args.inputs_file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters