Skip to content

Commit

Permalink
Merge pull request #2136 from nf-core/dev
Browse files Browse the repository at this point in the history
Dev -> Master for v2.7.2
  • Loading branch information
mirpedrol authored Dec 19, 2022
2 parents eecf1c7 + 9e6b67f commit 9d7dbee
Show file tree
Hide file tree
Showing 32 changed files with 205 additions and 123 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# nf-core/tools: Changelog

## [v2.7.2 - Mercury Eagle Patch](https://github.com/nf-core/tools/releases/tag/2.7.2) - [2022-12-19]

### Template

- Fix the syntax of github_output in GitHub actions ([#2114](https://github.com/nf-core/tools/pull/2114))
- Fix a bug introduced in 2.7 that made pipelines hang ([#2132](https://github.com/nf-core/tools/issues/2132))

### Linting

- Allow specifying containers in less than three lines ([#2121](https://github.com/nf-core/tools/pull/2121))
- Run prettier after dumping a json schema file ([#2124](https://github.com/nf-core/tools/pull/2124))

### General

- Only check that a pipeline name doesn't contain dashes if the name is provided by prompt of `--name`. Don't check if a template file is used. ([#2123](https://github.com/nf-core/tools/pull/2123))
- Deprecate `--enable_conda` parameter. Use `conda.enable` instead ([#2131](https://github.com/nf-core/tools/pull/2131))
- Handle `json.load()` exceptions ([#2134](https://github.com/nf-core/tools/pull/2134))

## [v2.7.1 - Mercury Eagle Patch](https://github.com/nf-core/tools/releases/tag/2.7.1) - [2022-12-08]

- Patch release to fix pipeline sync ([#2110](https://github.com/nf-core/tools/pull/2110))
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,12 @@ Please refer to the respective documentation for further details to manage packa
### Activate shell completions for nf-core/tools

Auto-completion for the `nf-core` command is available for bash, zsh and fish. To activate it, add the following lines to the respective shell config files.
shell | shell config file | command
--- | --- | ---
bash | ~/.bashrc | `eval "$(_NF_CORE_COMPLETE=bash_source nf-core)"`
Zsh | ~/.zshrc | `eval "$(_NF_CORE_COMPLETE=zsh_source nf-core)"`
fish | ~/.config/fish/completions/nf-core.fish | `eval (env _NF_CORE_COMPLETE=fish_source nf-core)`

| shell | shell config file | command |
| ----- | ----------------------------------------- | -------------------------------------------------- |
| bash | `~/.bashrc` | `eval "$(_NF_CORE_COMPLETE=bash_source nf-core)"` |
| zsh | `~/.zshrc` | `eval "$(_NF_CORE_COMPLETE=zsh_source nf-core)"` |
| fish | `~/.config/fish/completions/nf-core.fish` | `eval (env _NF_CORE_COMPLETE=fish_source nf-core)` |

After a restart of the shell session you should have auto-completion for the `nf-core` command and all its sub-commands and options.

Expand Down
2 changes: 2 additions & 0 deletions nf_core/components/components_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,5 @@ def get_username(author):
f"[violet]GitHub Username:[/]{' (@author)' if author_default is None else ''}",
default=author_default,
)

return author
9 changes: 5 additions & 4 deletions nf_core/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,17 @@ def create_param_dict(self, name, description, author, version, template_yaml_pa
param_dict["logo_dark"] = f"{param_dict['name_noslash']}_logo_dark.png"
param_dict["version"] = version

config_yml = nf_core.utils.load_tools_config()
_, config_yml = nf_core.utils.load_tools_config()
if (
"lint" in config_yml
and "nextflow_config" in config_yml["lint"]
and "manifest.name" in config_yml["lint"]["nextflow_config"]
):
return param_dict, skip_paths
# Check that the pipeline name matches the requirements
if not re.match(r"^[a-z]+$", param_dict["short_name"]):
raise UserWarning("[red]Invalid workflow name: must be lowercase without punctuation.")
if param_dict["prefix"] == "nf-core":
# Check that the pipeline name matches the requirements
if not re.match(r"^[a-z]+$", param_dict["short_name"]):
raise UserWarning("[red]Invalid workflow name: must be lowercase without punctuation.")

return param_dict, skip_paths

Expand Down
5 changes: 2 additions & 3 deletions nf_core/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import nf_core.schema
import nf_core.utils
from nf_core.lint_utils import dump_json_with_prettier

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -700,9 +701,7 @@ def build_command(self):

# Write the user selection to a file and run nextflow with that
if self.use_params_file:
with open(self.params_out, "w") as fp:
json.dump(self.schema_obj.input_params, fp, indent=4)
fp.write("\n")
dump_json_with_prettier(self.params_out, self.schema_obj.input_params)
self.nextflow_cmd += f' -params-file "{os.path.relpath(self.params_out)}"'

# Call nextflow with a list of command line flags
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 @@ -146,6 +146,7 @@ def nextflow_config(self):
"params.singleEnd",
"params.igenomesIgnore",
"params.name",
"params.enable_conda",
]

# Remove field that should be ignored according to the linting config
Expand Down
12 changes: 12 additions & 0 deletions nf_core/lint_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import logging
import subprocess
from pathlib import Path
Expand Down Expand Up @@ -82,3 +83,14 @@ def run_prettier_on_file(file):
"There was an error running the prettier pre-commit hook.\n"
f"STDOUT: {e.stdout.decode()}\nSTDERR: {e.stderr.decode()}"
)


def dump_json_with_prettier(file_name, file_content):
"""Dump a JSON file and run prettier on it.
Args:
file_name (Path | str): A file identifier as a string or pathlib.Path.
file_content (dict): Content to dump into the JSON file
"""
with open(file_name, "w") as fh:
json.dump(file_content, fh, indent=4)
run_prettier_on_file(file_name)
2 changes: 1 addition & 1 deletion nf_core/module-template/modules/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ process {{ tool_name_underscore|upper }} {
// Software MUST be pinned to channel (i.e. "bioconda"), version (i.e. "1.10").
// 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)
conda "{{ bioconda if bioconda else 'YOUR-TOOL-HERE' }}"
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' }}' }"
Expand Down
2 changes: 1 addition & 1 deletion nf_core/modules/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def create(self):
self._get_bioconda_tool()

# Prompt for GitHub username
nf_core.components.components_create.get_username(self.author)
self.author = nf_core.components.components_create.get_username(self.author)

self._get_module_structure_components()

Expand Down
26 changes: 24 additions & 2 deletions nf_core/modules/lint/main_nf.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,15 @@ def check_process_section(self, lines, fix_version, progress_bar):
self.failed.append(("singularity_tag", "Unable to parse singularity tag", self.main_nf))
singularity_tag = None
url = urlparse(l.split("'")[0])
# lint double quotes
if l.count('"') > 2:
self.failed.append(
(
"container_links",
"Too many double quotes found when specifying singularity container",
self.main_nf,
)
)
if _container_type(l) == "docker":
# e.g. "quay.io/biocontainers/krona:2.7.1--pl526_5' }" -> 2.7.1--pl526_5
# e.g. "biocontainers/biocontainers:v1.2.0_cv1' }" -> v1.2.0_cv1
Expand All @@ -282,13 +291,26 @@ 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 = None
url = urlparse(l.split("'")[0])
# lint double quotes
if l.count('"') > 2:
self.failed.append(
("container_links", "Too many double quotes found when specifying docker container", self.main_nf)
)
# lint double quotes
if l.startswith("container"):
container_section = l + lines[i + 1] + lines[i + 2]
if container_section.count('"') > 2:
if l.count('"') > 2:
self.failed.append(
("container_links", "Too many double quotes found when specifying containers", self.main_nf)
)
# lint more than one container in the same line
if ("https://containers" in l or "https://depot" in l) and ("biocontainers/" in l or "quay.io/" in l):
self.warned.append(
(
"container_links",
"Docker and Singularity containers specified in the same line. Only first one checked.",
self.main_nf,
)
)
# Try to connect to container URLs
if url is None:
continue
Expand Down
13 changes: 7 additions & 6 deletions nf_core/modules/modules_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import nf_core.utils
from nf_core.components.components_utils import get_components_to_install
from nf_core.lint_utils import run_prettier_on_file
from nf_core.lint_utils import dump_json_with_prettier
from nf_core.modules.modules_repo import (
NF_CORE_MODULES_NAME,
NF_CORE_MODULES_REMOTE,
Expand Down Expand Up @@ -618,7 +618,11 @@ def load(self):
"""
try:
with open(self.modules_json_path, "r") as fh:
self.modules_json = json.load(fh)
try:
self.modules_json = json.load(fh)
except json.JSONDecodeError as e:
raise UserWarning(f"Unable to load JSON file '{self.modules_json_path}' due to error {e}")

except FileNotFoundError:
raise UserWarning("File 'modules.json' is missing")

Expand Down Expand Up @@ -1023,10 +1027,7 @@ def dump(self):
"""
# Sort the modules.json
self.modules_json["repos"] = nf_core.utils.sort_dictionary(self.modules_json["repos"])
with open(self.modules_json_path, "w") as fh:
json.dump(self.modules_json, fh, indent=4)
fh.write("\n")
run_prettier_on_file(self.modules_json_path)
dump_json_with_prettier(self.modules_json_path, self.modules_json)

def resolve_missing_installation(self, missing_installation, component_type):
missing_but_in_mod_json = [
Expand Down
4 changes: 2 additions & 2 deletions nf_core/pipeline-template/.github/workflows/fix-linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ jobs:
id: prettier_status
run: |
if prettier --check ${GITHUB_WORKSPACE}; then
echo "name=result::pass" >> $GITHUB_OUTPUT
echo "result=pass" >> $GITHUB_OUTPUT
else
echo "name=result::fail" >> $GITHUB_OUTPUT
echo "result=fail" >> $GITHUB_OUTPUT
fi
- name: Run 'prettier --write'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

- name: Get PR number
id: pr_number
run: echo "name=pr_number::$(cat linting-logs/PR_number.txt)" >> $GITHUB_OUTPUT
run: echo "pr_number=$(cat linting-logs/PR_number.txt)" >> $GITHUB_OUTPUT

- name: Post PR comment
uses: marocchino/sticky-pull-request-comment@v2
Expand Down
2 changes: 1 addition & 1 deletion nf_core/pipeline-template/lib/WorkflowMain.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class WorkflowMain {
NfcoreTemplate.checkConfigProvided(workflow, log)

// Check that conda channels are set-up correctly
if (params.enable_conda) {
if (workflow.profile.tokenize(',').intersect(['conda', 'mamba']).size() >= 1) {
Utils.checkCondaChannels(log)
}

Expand Down
6 changes: 3 additions & 3 deletions nf_core/pipeline-template/modules.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
"nf-core": {
"custom/dumpsoftwareversions": {
"branch": "master",
"git_sha": "5e34754d42cd2d5d248ca8673c0a53cdf5624905",
"git_sha": "c8e35eb2055c099720a75538d1b8adb3fb5a464c",
"installed_by": ["modules"]
},
"fastqc": {
"branch": "master",
"git_sha": "5e34754d42cd2d5d248ca8673c0a53cdf5624905",
"git_sha": "c8e35eb2055c099720a75538d1b8adb3fb5a464c",
"installed_by": ["modules"]
},
"multiqc": {
"branch": "master",
"git_sha": "5e34754d42cd2d5d248ca8673c0a53cdf5624905",
"git_sha": "c8e35eb2055c099720a75538d1b8adb3fb5a464c",
"installed_by": ["modules"]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ process SAMPLESHEET_CHECK {
tag "$samplesheet"
label 'process_single'

conda (params.enable_conda ? "conda-forge::python=3.8.3" : null)
conda "conda-forge::python=3.8.3"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/python:3.8.3' :
'quay.io/biocontainers/python:3.8.3' }"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

99 changes: 55 additions & 44 deletions ...ne-template/modules/nf-core/custom/dumpsoftwareversions/templates/dumpsoftwareversions.py
100644 → 100755

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9d7dbee

Please sign in to comment.