Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update module template to support container registries #1991

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
c7f7920
feat(module-template): Introduce new container registry format
edmundmiller Oct 18, 2022
76efdd4
feat(pipeline-template): Add container_registry support
edmundmiller Oct 18, 2022
562714c
feat(lint): Add container_registry to nextflow.config checks
edmundmiller Oct 19, 2022
3979e27
refactor(modules/lint): Create seperate check_container_section
edmundmiller Oct 19, 2022
63e86a3
test(modules): Update name of test
edmundmiller Oct 27, 2022
ba5ba58
test(modules): Add lint step to creation of new module
edmundmiller Oct 27, 2022
7df4e91
fix(#1979): Add local modules to single linting
edmundmiller Oct 27, 2022
4b48f7b
test: Fresh module should have no warnings
edmundmiller Oct 28, 2022
359c434
feat(modules): Add container to deprecated syntax
edmundmiller Oct 28, 2022
08c2bfa
refactor(utils): Update get_biocontainer_tag to use quay api
edmundmiller Nov 1, 2022
5ccce4f
test(biocontainers): Use a mock
edmundmiller Nov 1, 2022
2bd465b
test: Add an util to check if a PR has been merged
edmundmiller Nov 1, 2022
da1dc33
fix(modules/lint): Remove container versions do not match
edmundmiller Nov 2, 2022
d9b3f8f
refactor: Join singularity and docker into container tag
edmundmiller Nov 2, 2022
47d6ef7
refactor: Move bioconda_package into it's own function
edmundmiller Nov 2, 2022
e638bc5
test: Add test for _check_bioconda_package
edmundmiller Nov 2, 2022
0fc7cb1
chore: Update CHANGELOG
edmundmiller Nov 2, 2022
799682b
style: Fix typo
edmundmiller Nov 2, 2022
984283e
Apply suggestions from code review
edmundmiller Nov 3, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@

- Fix lint warnings for `samplesheet_check.nf` module
- Check that the workflow name provided with a template doesn't contain dashes ([#1822](https://github.com/nf-core/tools/pull/1822))
- Add `container_registry` parameter to support biocontainers on ECR ([#1991](https://github.com/nf-core/tools/pull/1991))

### Linting

- Lint for `container_registry` ([#1991](https://github.com/nf-core/tools/pull/1991))
- Lint for old container logic and warn ([#1991](https://github.com/nf-core/tools/pull/1991))

### General

- Fix error in tagging GitPod docker images during releases
Expand All @@ -29,6 +33,7 @@
### Modules

- Update patch file paths if the modules directory has the old structure ([#1878](https://github.com/nf-core/tools/pull/1878))
- Update module container logic to handle container registries ([#1991](https://github.com/nf-core/tools/pull/1991) & [modules #2291](https://github.com/nf-core/modules/pull/2291))

## [v2.6 - Tin Octopus](https://github.com/nf-core/tools/releases/tag/2.6) - [2022-10-04]

Expand Down
1 change: 1 addition & 0 deletions nf_core/lint/nextflow_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def nextflow_config(self):
["params.input"],
["params.show_hidden_params"],
["params.schema_ignore_params"],
["params.container_registry"],
]
# Throw a warning if these are missing
config_warn = [
Expand Down
5 changes: 2 additions & 3 deletions nf_core/module-template/modules/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ process {{ tool_name_underscore|upper }} {
// For Conda, the build (i.e. "h9402c20_2") must be EXCLUDED to support installation on different operating systems.
// TODO nf-core: See section in main README for further information regarding finding and adding container addresses to the section below.
conda (params.enable_conda ? "{{ bioconda if bioconda else 'YOUR-TOOL-HERE' }}" : null)
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'{{ singularity_container if singularity_container else 'https://depot.galaxyproject.org/singularity/YOUR-TOOL-HERE' }}':
'{{ docker_container if docker_container else 'quay.io/biocontainers/YOUR-TOOL-HERE' }}' }"
def container_image = "{{ container if container else 'YOUR-TOOL-HERE' }}"
container [ params.container_registry ?: 'quay.io/biocontainers' , container_image ].join('/')

input:
// TODO nf-core: Where applicable all sample-specific information e.g. "id", "single_end", "read_group"
Expand Down
15 changes: 5 additions & 10 deletions nf_core/modules/bump_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ def bump_versions(self, module=None, all_modules=False, show_uptodate=False):
Bump the container and conda version of single module or all modules

Looks for a bioconda tool version in the `main.nf` file of the module and checks whether
are more recent version is available. If yes, then tries to get docker/singularity
container links and replace the bioconda version and the container links in the main.nf file
of the respective module.
a more recent version is available. If yes, then tries to get container links and replace
the bioconda version and the container links in the main.nf file of the respective module.

Args:
module: a specific module to update
Expand Down Expand Up @@ -165,20 +164,16 @@ def bump_module_version(self, module):

if last_ver is not None and last_ver != bioconda_version:
log.debug(f"Updating version for {module.module_name}")
# Get docker and singularity container links
# Get container tag
try:
docker_img, singularity_img = nf_core.utils.get_biocontainer_tag(bioconda_tool_name, last_ver)
container_img = nf_core.utils.get_biocontainer_tag(bioconda_tool_name)
except LookupError as e:
self.failed.append((f"Could not download container tags: {e}", module.module_name))
return False

patterns = [
(bioconda_packages[0], f"'bioconda::{bioconda_tool_name}={last_ver}'"),
(rf"quay.io/biocontainers/{bioconda_tool_name}:[^'\"\s]+", docker_img),
(
rf"https://depot.galaxyproject.org/singularity/{bioconda_tool_name}:[^'\"\s]+",
singularity_img,
),
(rf"quay.io/biocontainers/{bioconda_tool_name}:[^'\"\s]+", container_img),
]

with open(module.main_nf, "r") as fh:
Expand Down
18 changes: 7 additions & 11 deletions nf_core/modules/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ def __init__(
self.tool_doc_url = ""
self.tool_dev_url = ""
self.bioconda = None
self.singularity_container = None
self.docker_container = None
self.container = None
self.file_paths = {}

def create(self):
Expand All @@ -81,7 +80,7 @@ def create(self):
tests/config/pytest_modules.yml

The function will attempt to automatically find a Bioconda package called <tool>
and matching Docker / Singularity images from BioContainers.
and matching container images from BioContainers.
"""

# Check modules directory structure
Expand Down Expand Up @@ -210,17 +209,14 @@ def _get_bioconda_tool(self):
if self.bioconda:
try:
if self.tool_conda_name:
self.docker_container, self.singularity_container = nf_core.utils.get_biocontainer_tag(
self.tool_conda_name, version
self.container = (
f"{self.tool_conda_name}:{nf_core.utils.get_biocontainer_tag(self.tool_conda_name)}"
)
else:
self.docker_container, self.singularity_container = nf_core.utils.get_biocontainer_tag(
self.tool, version
)
log.info(f"Using Docker container: '{self.docker_container}'")
log.info(f"Using Singularity container: '{self.singularity_container}'")
self.container = f"{self.tool}:{nf_core.utils.get_biocontainer_tag(self.tool)}"
log.info(f"Using container tag: '{self.container}'")
except (ValueError, LookupError) as e:
log.info(f"Could not find a Docker/Singularity container ({e})")
log.info(f"Could not find a container ({e})")

def _get_module_structure_components(self):
process_label_defaults = ["process_single", "process_low", "process_medium", "process_high", "process_long"]
Expand Down
12 changes: 9 additions & 3 deletions nf_core/modules/lint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ def lint(
the passed, warned and failed tests
"""

choices = []
if local == True:
choices = [m.module_name for m in self.all_local_modules]
else:
choices = [m.module_name for m in self.all_remote_modules] + [m.module_name for m in self.all_local_modules]

# Prompt for module or all
if module is None and not all_modules:
questions = [
Expand All @@ -177,7 +183,7 @@ def lint(
"name": "tool_name",
"message": "Tool name:",
"when": lambda x: x["all_modules"] == "Named module",
"choices": [m.module_name for m in self.all_remote_modules],
"choices": choices,
},
]
answers = questionary.unsafe_prompt(questions, style=nf_core.utils.nfcore_question_style)
Expand All @@ -188,9 +194,9 @@ def lint(
if module:
if all_modules:
raise ModuleLintException("You cannot specify a tool and request all tools to be linted.")
local_modules = []
local_modules = [m for m in self.all_local_modules if m.module_name == module]
remote_modules = [m for m in self.all_remote_modules if m.module_name == module]
if len(remote_modules) == 0:
if len(remote_modules) == 0 and len(local_modules) == 0:
raise ModuleLintException(f"Could not find the specified module: '{module}'")
else:
local_modules = self.all_local_modules
Expand Down
Loading