diff --git a/CHANGELOG.md b/CHANGELOG.md index fde3775e70..89d3fe8f8f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - Move registry definitions out of profile scope ([#2286])(https://github.com/nf-core/tools/pull/2286) - Remove `aws_tower` profile ([#2287])(https://github.com/nf-core/tools/pull/2287) - Fixed the Slack report to include the pipeline name ([#2291](https://github.com/nf-core/tools/pull/2291)) + ### Download - Introduce a `--tower` flag for `nf-core download` to obtain pipelines in an offline format suited for [seqeralabs® Nextflow Tower](https://cloud.tower.nf/) ([#2247](https://github.com/nf-core/tools/pull/2247)). diff --git a/nf_core/download.py b/nf_core/download.py index 5d214d2aaf..274132f02b 100644 --- a/nf_core/download.py +++ b/nf_core/download.py @@ -108,10 +108,10 @@ def __init__( self.force = force self.tower = tower self.include_configs = None - self.container = container if not singularity_cache_index else "singularity" - self.singularity_cache = ( - singularity_cache if not singularity_cache_index else "remote" - ) # if a singularity_cache_index is given, use the file and overrule choice. + # force download of containers if a cache index is given or download is meant to be used for Tower. + self.container = "singularity" if singularity_cache_index or bool(tower) else container + # if a singularity_cache_index is given, use the file and overrule choice. + self.singularity_cache = "remote" if singularity_cache_index else singularity_cache self.singularity_cache_index = singularity_cache_index self.parallel_downloads = parallel_downloads @@ -377,7 +377,7 @@ def prompt_config_inclusion(self): def prompt_container_download(self): """Prompt whether to download container images or not""" - if self.container is None and stderr.is_interactive: + if self.container is None and stderr.is_interactive and not self.tower: stderr.print("\nIn addition to the pipeline code, this tool can download software containers.") self.container = questionary.select( "Download software container images:", @@ -722,7 +722,7 @@ def find_container_images(self, workflow_directory): Therefore, we need to repeat the search over the contents, extract the variable name, and use it inside a new regex. To get the variable name ( ${container_id} in above example ), we match the literal word "container" and use lookbehind (reset the match). - Then we skip [^\${}]+ everything that is not $ or curly braces. The next capture group is + Then we skip [^${}]+ everything that is not $ or curly braces. The next capture group is ${ followed by any characters that are not curly braces [^{}]+ and ended by a closing curly brace (}), but only if it's not followed by any other curly braces (?![^{]*}). The latter ensures we capture the innermost variable name. diff --git a/nf_core/modules/lint/main_nf.py b/nf_core/modules/lint/main_nf.py index 8150e7e839..31b8adca3a 100644 --- a/nf_core/modules/lint/main_nf.py +++ b/nf_core/modules/lint/main_nf.py @@ -283,7 +283,7 @@ def check_process_section(self, lines, fix_version, progress_bar): self.failed.append(("docker_tag", "Unable to parse docker tag", self.main_nf)) docker_tag = NoneD if l.startswith("quay.io/"): - l_stripped = re.sub("\W+$", "", l) + l_stripped = re.sub(r"\W+$", "", l) self.failed.append( ( "container_links", diff --git a/tests/test_download.py b/tests/test_download.py index 41fb9c625f..aa2e959f3d 100644 --- a/tests/test_download.py +++ b/tests/test_download.py @@ -190,7 +190,7 @@ def test_remote_container_functionality(self, tmp_dir): download_obj.include_configs = False # suppress prompt, because stderr.is_interactive doesn't. - # test if settings are changed accordingly. + # test if the settings are changed to mandatory defaults, if an external cache index is used. assert download_obj.singularity_cache == "remote" and download_obj.container == "singularity" assert isinstance(download_obj.containers_remote, list) and len(download_obj.containers_remote) == 0 # read in the file @@ -264,9 +264,11 @@ def test_download_workflow_for_tower(self, tmp_dir): # corroborate that the other revisions are inaccessible to the user. assert len(download_obj.workflow_repo.tags) == len(download_obj.revision) - # manually test container image detection for 3.7 revision + # download_obj.download_workflow_tower(location=tmp_dir) will run container image detection for all requested revisions + assert isinstance(download_obj.containers, list) and len(download_obj.containers) == 33 + # manually test container image detection for 3.7 revision only + download_obj.containers = [] # empty container list for the test download_obj.workflow_repo.checkout(download_obj.wf_sha["3.7"]) - assert isinstance(download_obj.containers, list) and len(download_obj.containers) == 0 download_obj.find_container_images(download_obj.workflow_repo.access()) assert len(download_obj.containers) == 30 # 30 containers for 3.7 assert (