From 20b824d3f65fa95a9385b903bbe187ae190a8255 Mon Sep 17 00:00:00 2001 From: Niklas Schandry Date: Fri, 26 Apr 2024 12:04:24 +0200 Subject: [PATCH 01/32] Add charliecloud.registry --- nf_core/pipeline-template/nextflow.config | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/nf_core/pipeline-template/nextflow.config b/nf_core/pipeline-template/nextflow.config index 17e75f18a4..f097cc2ff6 100644 --- a/nf_core/pipeline-template/nextflow.config +++ b/nf_core/pipeline-template/nextflow.config @@ -184,11 +184,11 @@ profiles { // Set default registry for Apptainer, Docker, Podman and Singularity independent of -profile // Will not be used unless Apptainer / Docker / Podman / Singularity are enabled // Set to your registry if you have a mirror of containers -apptainer.registry = 'quay.io' -docker.registry = 'quay.io' -podman.registry = 'quay.io' -singularity.registry = 'quay.io' - +apptainer.registry = 'quay.io' +docker.registry = 'quay.io' +podman.registry = 'quay.io' +singularity.registry = 'quay.io' +charliecloud.registry = 'quay.io' // Nextflow plugins plugins { id 'nf-validation@1.1.3' // Validation of pipeline parameters and creation of an input channel from a sample sheet From 97bfc217fa02fef86c36100331fa8b27a6042c5b Mon Sep 17 00:00:00 2001 From: Niklas Schandry Date: Fri, 26 Apr 2024 13:17:06 +0200 Subject: [PATCH 02/32] Update comment, add newline --- nf_core/pipeline-template/nextflow.config | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nf_core/pipeline-template/nextflow.config b/nf_core/pipeline-template/nextflow.config index f90fc546f6..cbc98cb022 100644 --- a/nf_core/pipeline-template/nextflow.config +++ b/nf_core/pipeline-template/nextflow.config @@ -180,14 +180,15 @@ profiles { test_full { includeConfig 'conf/test_full.config' } } -// Set default registry for Apptainer, Docker, Podman and Singularity independent of -profile -// Will not be used unless Apptainer / Docker / Podman / Singularity are enabled +// Set default registry for Apptainer, Docker, Podman, Charliecloud and Singularity independent of -profile +// Will not be used unless Apptainer / Docker / Podman / Charliecloud / Singularity are enabled // Set to your registry if you have a mirror of containers apptainer.registry = 'quay.io' docker.registry = 'quay.io' podman.registry = 'quay.io' singularity.registry = 'quay.io' charliecloud.registry = 'quay.io' + // Nextflow plugins plugins { id 'nf-validation@1.1.3' // Validation of pipeline parameters and creation of an input channel from a sample sheet From 5e611c8ff68824836b487a9bfd4153e6c2db78fd Mon Sep 17 00:00:00 2001 From: mirpedrol Date: Mon, 13 May 2024 10:42:19 +0200 Subject: [PATCH 03/32] add GHA to post comment about outdated template version --- .../.github/workflows/linting.yml | 8 +++- .../workflows/template_version_comment.yml | 42 +++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 nf_core/pipeline-template/.github/workflows/template_version_comment.yml diff --git a/nf_core/pipeline-template/.github/workflows/linting.yml b/nf_core/pipeline-template/.github/workflows/linting.yml index b2cde075fe..229aa9f652 100644 --- a/nf_core/pipeline-template/.github/workflows/linting.yml +++ b/nf_core/pipeline-template/.github/workflows/linting.yml @@ -41,10 +41,16 @@ jobs: python-version: "3.12" architecture: "x64" + - name: read .nf-core.yml + uses: pietrobolcato/action-read-yaml@1.0.0 + id: read_yml + with: + config: ${{ github.workspace }}/.nf-core.yaml + - name: Install dependencies run: | python -m pip install --upgrade pip - pip install nf-core + pip install nf-core==${{ steps.read_yml.outputs['nf_core_version'] }} - name: Run nf-core lint env: diff --git a/nf_core/pipeline-template/.github/workflows/template_version_comment.yml b/nf_core/pipeline-template/.github/workflows/template_version_comment.yml new file mode 100644 index 0000000000..2f49ab1269 --- /dev/null +++ b/nf_core/pipeline-template/.github/workflows/template_version_comment.yml @@ -0,0 +1,42 @@ +name: nf-core template version comment +# This workflow is triggered on PRs to check if the pipeline template version matches the latest nf-core version. +# It posts a comment to the PR, even if it comes from a fork. + +on: pull_request_target + +jobs: + template_version: + runs-on: ubuntu-latest + steps: + - name: Check out pipeline code + uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4 + + - name: Read template version from .nf-core.yml + uses: pietrobolcato/action-read-yaml@1.0.0 + id: read_yml + with: + config: ${{ github.workspace }}/.nf-core.yml + + - name: Install nf-core + run: | + python -m pip install --upgrade pip + pip install nf-core==${{ steps.read_yml.outputs['nf_core_version'] }} + + - name: Check nf-core outdated + id: nf_core_outdated + run: pip list --outdated | grep nf-core + + - name: Post nf-core template version comment + uses: mshick/add-pr-comment@b8f338c590a895d50bcbfa6c5859251edc8952fc # v2 + if: | + ${{ steps.nf_core_outdated.outputs.stdout }} =~ 'nf-core' + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + allow-repeats: false + message: | + ## :warning: New nf-core template version available + + Your pipeline is using an old version of the nf-core template: ${{ steps.read_yml.outputs['nf_core_version'] }}. + Please update your pipeline to the latest version. + + For more documentation on how to update your pipeline, please see the [nf-core documentation](https://github.com/nf-core/tools?tab=readme-ov-file#sync-a-pipeline-with-the-template) and [Synchronisation documentation](https://nf-co.re/docs/contributing/sync). From 7c1bb8a17ebe4b6e3a8afe27e4c78bdc42df01fb Mon Sep 17 00:00:00 2001 From: nf-core-bot Date: Mon, 13 May 2024 08:45:47 +0000 Subject: [PATCH 04/32] [automated] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f46a265cc..ba1d7da108 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ ### Linting +- Template: Lint pipelines with the nf-core template version and post comment if it is outdated ([#2978](https://github.com/nf-core/tools/pull/2978)) + ### Download ### Components From 940b3841e94b8368b5827aa356010e8700f3ead7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlia=20Mir=20Pedrol?= Date: Mon, 13 May 2024 11:33:16 +0200 Subject: [PATCH 05/32] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Matthias Hörtenhuber --- .../.github/workflows/template_version_comment.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nf_core/pipeline-template/.github/workflows/template_version_comment.yml b/nf_core/pipeline-template/.github/workflows/template_version_comment.yml index 2f49ab1269..e21283309d 100644 --- a/nf_core/pipeline-template/.github/workflows/template_version_comment.yml +++ b/nf_core/pipeline-template/.github/workflows/template_version_comment.yml @@ -31,10 +31,10 @@ jobs: if: | ${{ steps.nf_core_outdated.outputs.stdout }} =~ 'nf-core' with: - repo-token: ${{ secrets.GITHUB_TOKEN }} + repo-token: ${{ secrets.NF_CORE_BOT_AUTH_TOKEN }} allow-repeats: false message: | - ## :warning: New nf-core template version available + ## :warning: Newer version of the nf-core template is available. Your pipeline is using an old version of the nf-core template: ${{ steps.read_yml.outputs['nf_core_version'] }}. Please update your pipeline to the latest version. From e9740b6454df2b238fd2c7a1ab407eee9b193029 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 23 May 2024 12:03:25 +0000 Subject: [PATCH 06/32] Update pre-commit hook astral-sh/ruff-pre-commit to v0.4.5 --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4b1941d81e..01bd13a9e9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.4.4 + rev: v0.4.5 hooks: - id: ruff # linter args: [--fix, --exit-non-zero-on-fix] # sort imports and fix From e7136379bbadd7d3c883a9c80be3d37ce68a307c Mon Sep 17 00:00:00 2001 From: mirpedrol Date: Mon, 27 May 2024 13:06:23 +0200 Subject: [PATCH 07/32] return directory if base_dir is the root directory --- nf_core/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nf_core/utils.py b/nf_core/utils.py index 8c50f0a49f..1a1e8a2a99 100644 --- a/nf_core/utils.py +++ b/nf_core/utils.py @@ -1069,7 +1069,7 @@ def determine_base_dir(directory="."): config_fn = get_first_available_path(base_dir, CONFIG_PATHS) if config_fn: break - return directory if base_dir == start_dir else base_dir + return directory if (base_dir == start_dir or str(base_dir) == base_dir.root) else base_dir def get_first_available_path(directory, paths): From ae47db3608feaa95cb9165a876740fcee96534ac Mon Sep 17 00:00:00 2001 From: nf-core-bot Date: Mon, 27 May 2024 11:07:57 +0000 Subject: [PATCH 08/32] [automated] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 16262bd1c3..a5795245a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ - Update output of generation script for API docs to new structure ([#2988](https://github.com/nf-core/tools/pull/2988)) - Add no clobber and put bash options on their own line ([#2991](https://github.com/nf-core/tools/pull/2991)) - update minimal textual version and snapshots ([#2998](https://github.com/nf-core/tools/pull/2998)) +- return directory if base_dir is the root directory ([#3003](https://github.com/nf-core/tools/pull/3003)) ## [v2.14.1 - Tantalum Toad - Patch](https://github.com/nf-core/tools/releases/tag/2.14.1) - [2024-05-09] From efd397d94ee223f8dd60f1c3a88a04211bc4b27e Mon Sep 17 00:00:00 2001 From: Nicolas Vannieuwkerke Date: Mon, 27 May 2024 14:39:17 +0200 Subject: [PATCH 09/32] add org to main.nf.test tag --- nf_core/components/create.py | 4 ++++ nf_core/module-template/tests/main.nf.test.j2 | 2 +- nf_core/subworkflow-template/tests/main.nf.test.j2 | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/nf_core/components/create.py b/nf_core/components/create.py index 6c9c01b496..e603db3857 100644 --- a/nf_core/components/create.py +++ b/nf_core/components/create.py @@ -157,6 +157,10 @@ def create(self): if self.component_type == "modules": self._get_module_structure_components() + # Add a valid organization name for nf-test tags + not_alphabet = re.compile(r'[^a-zA-Z]') + self.org_alphabet = not_alphabet.sub('', self.org) + # Create component template with jinja2 self._render_template() log.info(f"Created component template: '{self.component_name}'") diff --git a/nf_core/module-template/tests/main.nf.test.j2 b/nf_core/module-template/tests/main.nf.test.j2 index 1f70df64b0..456c989f85 100644 --- a/nf_core/module-template/tests/main.nf.test.j2 +++ b/nf_core/module-template/tests/main.nf.test.j2 @@ -7,7 +7,7 @@ nextflow_process { process "{{ component_name_underscore|upper }}" tag "modules" - tag "modules_nfcore" + tag "modules_{{ org_alphabet }}" {%- if subtool %} tag "{{ component }}" {%- endif %} diff --git a/nf_core/subworkflow-template/tests/main.nf.test.j2 b/nf_core/subworkflow-template/tests/main.nf.test.j2 index c44e19a4e4..8aaf6e0c7c 100644 --- a/nf_core/subworkflow-template/tests/main.nf.test.j2 +++ b/nf_core/subworkflow-template/tests/main.nf.test.j2 @@ -7,7 +7,7 @@ nextflow_workflow { workflow "{{ component_name_underscore|upper }}" tag "subworkflows" - tag "subworkflows_nfcore" + tag "subworkflows_{{ org_alphabet }}" tag "subworkflows/{{ component_name }}" // TODO nf-core: Add tags for all modules used within this subworkflow. Example: tag "samtools" From a446f29d01470e05870552d6bb496236460d46b6 Mon Sep 17 00:00:00 2001 From: Nicolas Vannieuwkerke Date: Mon, 27 May 2024 15:19:50 +0200 Subject: [PATCH 10/32] make sure linting passes this new feature --- nf_core/modules/lint/module_tests.py | 6 +++++- nf_core/subworkflows/lint/subworkflow_tests.py | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/nf_core/modules/lint/module_tests.py b/nf_core/modules/lint/module_tests.py index b2b6c2221f..080fc2bdc8 100644 --- a/nf_core/modules/lint/module_tests.py +++ b/nf_core/modules/lint/module_tests.py @@ -4,6 +4,7 @@ import json import logging +import re from pathlib import Path import yaml @@ -137,7 +138,10 @@ def module_tests(_, module: NFCoreComponent): ) # Verify that tags are correct. main_nf_tags = module._get_main_nf_tags(module.nftest_main_nf) - required_tags = ["modules", "modules_nfcore", module.component_name] + not_alphabet = re.compile(r'[^a-zA-Z]') + org_alp = not_alphabet.sub('', module.org) + org_alphabet = org_alp if org_alp != "" else "nfcore" + required_tags = ["modules", f"modules_{org_alphabet}", module.component_name] if module.component_name.count("/") == 1: required_tags.append(module.component_name.split("/")[0]) chained_components_tags = module._get_included_components_in_chained_tests(module.nftest_main_nf) diff --git a/nf_core/subworkflows/lint/subworkflow_tests.py b/nf_core/subworkflows/lint/subworkflow_tests.py index cfae2d553c..87e850e8fb 100644 --- a/nf_core/subworkflows/lint/subworkflow_tests.py +++ b/nf_core/subworkflows/lint/subworkflow_tests.py @@ -4,6 +4,7 @@ import json import logging +import re from pathlib import Path import yaml @@ -144,10 +145,13 @@ def subworkflow_tests(_, subworkflow: NFCoreComponent): ) # Verify that tags are correct. main_nf_tags = subworkflow._get_main_nf_tags(subworkflow.nftest_main_nf) + not_alphabet = re.compile(r'[^a-zA-Z]') + org_alp = not_alphabet.sub('', subworkflow.org) + org_alphabet = org_alp if org_alp != "" else "nfcore" required_tags = [ "subworkflows", f"subworkflows/{subworkflow.component_name}", - "subworkflows_nfcore", + f"subworkflows_{org_alphabet}", ] included_components = [] if subworkflow.main_nf.is_file(): From 7bae122e1da8fb54511ebdfe02894a602621dbce Mon Sep 17 00:00:00 2001 From: Nicolas Vannieuwkerke Date: Mon, 27 May 2024 15:27:20 +0200 Subject: [PATCH 11/32] update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 16262bd1c3..259982e39f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ ### Components +- The `modules_nfcore` tag in the `main.nf.test` file of modules/subworkflows now displays the organization name in custom modules repositories ([#3005](https://github.com/nf-core/tools/pull/3005)) + ### General - Update pre-commit hook astral-sh/ruff-pre-commit to v0.4.4 ([#2974](https://github.com/nf-core/tools/pull/2974)) From a4ecb70909da3b6986c25d8986ba956391bcd0fc Mon Sep 17 00:00:00 2001 From: Nicolas Vannieuwkerke Date: Mon, 27 May 2024 15:32:45 +0200 Subject: [PATCH 12/32] ruff! --- nf_core/components/create.py | 4 ++-- nf_core/modules/lint/module_tests.py | 4 ++-- nf_core/subworkflows/lint/subworkflow_tests.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/nf_core/components/create.py b/nf_core/components/create.py index e603db3857..78c30b5179 100644 --- a/nf_core/components/create.py +++ b/nf_core/components/create.py @@ -158,8 +158,8 @@ def create(self): self._get_module_structure_components() # Add a valid organization name for nf-test tags - not_alphabet = re.compile(r'[^a-zA-Z]') - self.org_alphabet = not_alphabet.sub('', self.org) + not_alphabet = re.compile(r"[^a-zA-Z]") + self.org_alphabet = not_alphabet.sub("", self.org) # Create component template with jinja2 self._render_template() diff --git a/nf_core/modules/lint/module_tests.py b/nf_core/modules/lint/module_tests.py index 080fc2bdc8..4bf4ea7745 100644 --- a/nf_core/modules/lint/module_tests.py +++ b/nf_core/modules/lint/module_tests.py @@ -138,8 +138,8 @@ def module_tests(_, module: NFCoreComponent): ) # Verify that tags are correct. main_nf_tags = module._get_main_nf_tags(module.nftest_main_nf) - not_alphabet = re.compile(r'[^a-zA-Z]') - org_alp = not_alphabet.sub('', module.org) + not_alphabet = re.compile(r"[^a-zA-Z]") + org_alp = not_alphabet.sub("", module.org) org_alphabet = org_alp if org_alp != "" else "nfcore" required_tags = ["modules", f"modules_{org_alphabet}", module.component_name] if module.component_name.count("/") == 1: diff --git a/nf_core/subworkflows/lint/subworkflow_tests.py b/nf_core/subworkflows/lint/subworkflow_tests.py index 87e850e8fb..fe7b40407a 100644 --- a/nf_core/subworkflows/lint/subworkflow_tests.py +++ b/nf_core/subworkflows/lint/subworkflow_tests.py @@ -145,8 +145,8 @@ def subworkflow_tests(_, subworkflow: NFCoreComponent): ) # Verify that tags are correct. main_nf_tags = subworkflow._get_main_nf_tags(subworkflow.nftest_main_nf) - not_alphabet = re.compile(r'[^a-zA-Z]') - org_alp = not_alphabet.sub('', subworkflow.org) + not_alphabet = re.compile(r"[^a-zA-Z]") + org_alp = not_alphabet.sub("", subworkflow.org) org_alphabet = org_alp if org_alp != "" else "nfcore" required_tags = [ "subworkflows", From 6d9feb3a900db74980bce66523e65f2470cdb507 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 28 May 2024 22:45:25 +0000 Subject: [PATCH 13/32] Update pre-commit hook astral-sh/ruff-pre-commit to v0.4.6 --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 01bd13a9e9..8521c44100 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.4.5 + rev: v0.4.6 hooks: - id: ruff # linter args: [--fix, --exit-non-zero-on-fix] # sort imports and fix From f94ec87ccd246eba4db29609e1b0f5ed44b2fb80 Mon Sep 17 00:00:00 2001 From: nf-core-bot Date: Tue, 28 May 2024 22:46:12 +0000 Subject: [PATCH 14/32] [automated] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae43fd4e7b..63bef50b84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ - Add no clobber and put bash options on their own line ([#2991](https://github.com/nf-core/tools/pull/2991)) - update minimal textual version and snapshots ([#2998](https://github.com/nf-core/tools/pull/2998)) - return directory if base_dir is the root directory ([#3003](https://github.com/nf-core/tools/pull/3003)) +- Update pre-commit hook astral-sh/ruff-pre-commit to v0.4.6 ([#3006](https://github.com/nf-core/tools/pull/3006)) ## [v2.14.1 - Tantalum Toad - Patch](https://github.com/nf-core/tools/releases/tag/2.14.1) - [2024-05-09] From 60b79b156ccd77f369ad174997fdb0284db62682 Mon Sep 17 00:00:00 2001 From: mirpedrol Date: Wed, 29 May 2024 15:35:19 +0200 Subject: [PATCH 15/32] use pydantic validation context on module initialization. use global variable for pipeline type --- nf_core/pipelines/create/__init__.py | 16 +++++----- nf_core/pipelines/create/utils.py | 46 +++++++++++++++++++++++----- 2 files changed, 46 insertions(+), 16 deletions(-) diff --git a/nf_core/pipelines/create/__init__.py b/nf_core/pipelines/create/__init__.py index da6a693220..c118d8520d 100644 --- a/nf_core/pipelines/create/__init__.py +++ b/nf_core/pipelines/create/__init__.py @@ -5,6 +5,7 @@ from textual.app import App from textual.widgets import Button +from nf_core.pipelines.create import utils from nf_core.pipelines.create.basicdetails import BasicDetails from nf_core.pipelines.create.custompipeline import CustomPipeline from nf_core.pipelines.create.finaldetails import FinalDetails @@ -14,15 +15,10 @@ from nf_core.pipelines.create.loggingscreen import LoggingScreen from nf_core.pipelines.create.nfcorepipeline import NfcorePipeline from nf_core.pipelines.create.pipelinetype import ChoosePipelineType -from nf_core.pipelines.create.utils import ( - CreateConfig, - CustomLogHandler, - LoggingConsole, -) from nf_core.pipelines.create.welcome import WelcomeScreen -log_handler = CustomLogHandler( - console=LoggingConsole(classes="log_console"), +log_handler = utils.CustomLogHandler( + console=utils.LoggingConsole(classes="log_console"), rich_tracebacks=True, show_time=False, show_path=False, @@ -36,7 +32,7 @@ log_handler.setLevel("INFO") -class PipelineCreateApp(App[CreateConfig]): +class PipelineCreateApp(App[utils.CreateConfig]): """A Textual app to manage stopwatches.""" CSS_PATH = "create.tcss" @@ -60,7 +56,7 @@ class PipelineCreateApp(App[CreateConfig]): } # Initialise config as empty - TEMPLATE_CONFIG = CreateConfig() + TEMPLATE_CONFIG = utils.CreateConfig() # Initialise pipeline type PIPELINE_TYPE = None @@ -79,9 +75,11 @@ def on_button_pressed(self, event: Button.Pressed) -> None: self.push_screen("choose_type") elif event.button.id == "type_nfcore": self.PIPELINE_TYPE = "nfcore" + utils.PIPELINE_TYPE_GLOBAL = "nfcore" self.push_screen("basic_details") elif event.button.id == "type_custom": self.PIPELINE_TYPE = "custom" + utils.PIPELINE_TYPE_GLOBAL = "custom" self.push_screen("basic_details") elif event.button.id == "continue": self.push_screen("final_details") diff --git a/nf_core/pipelines/create/utils.py b/nf_core/pipelines/create/utils.py index 6006452baf..0754c54b54 100644 --- a/nf_core/pipelines/create/utils.py +++ b/nf_core/pipelines/create/utils.py @@ -1,9 +1,11 @@ import re +from contextlib import contextmanager +from contextvars import ContextVar from logging import LogRecord from pathlib import Path -from typing import Optional, Union +from typing import Any, Dict, Iterator, Optional, Union -from pydantic import BaseModel, ConfigDict, ValidationError, field_validator +from pydantic import BaseModel, ConfigDict, ValidationError, ValidationInfo, field_validator from rich.logging import RichHandler from textual import on from textual._context import active_app @@ -14,6 +16,22 @@ from textual.widget import Widget from textual.widgets import Button, Input, Markdown, RichLog, Static, Switch +# Use ContextVar to define a context on the model initialization +_init_context_var: ContextVar = ContextVar("_init_context_var", default={}) + + +@contextmanager +def init_context(value: Dict[str, Any]) -> Iterator[None]: + token = _init_context_var.set(value) + try: + yield + finally: + _init_context_var.reset(token) + + +# Define a global variable to store the pipeline type +PIPELINE_TYPE_GLOBAL: str | None = None + class CreateConfig(BaseModel): """Pydantic model for the nf-core create config.""" @@ -30,12 +48,25 @@ class CreateConfig(BaseModel): model_config = ConfigDict(extra="allow") + def __init__(self, /, **data: Any) -> None: + """Custom init method to allow using a context on the model initialization.""" + self.__pydantic_validator__.validate_python( + data, + self_instance=self, + context=_init_context_var.get(), + ) + @field_validator("name") @classmethod - def name_nospecialchars(cls, v: str) -> str: + def name_nospecialchars(cls, v: str, info: ValidationInfo) -> str: """Check that the pipeline name is simple.""" - if not re.match(r"^[a-z]+$", v): - raise ValueError("Must be lowercase without punctuation.") + context = info.context + if context and context["is_nfcore"]: + if not re.match(r"^[a-z]+$", v): + raise ValueError("Must be lowercase without punctuation.") + else: + if not re.match(r"^[a-zA-Z-_]+$", v): + raise ValueError("Must not contain special characters. Only '-' or '_' are allowed.") return v @field_validator("org", "description", "author", "version", "outdir") @@ -117,8 +148,9 @@ def validate(self, value: str) -> ValidationResult: If it fails, return the error messages.""" try: - CreateConfig(**{f"{self.key}": value}) - return self.success() + with init_context({"is_nfcore": PIPELINE_TYPE_GLOBAL == "nfcore"}): + CreateConfig(**{f"{self.key}": value}) + return self.success() except ValidationError as e: return self.failure(", ".join([err["msg"] for err in e.errors()])) From 0186535fe3e6a7c8f79fdd379ebc0d2d20f423d1 Mon Sep 17 00:00:00 2001 From: nf-core-bot Date: Wed, 29 May 2024 13:40:21 +0000 Subject: [PATCH 16/32] [automated] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 63bef50b84..af62a6ed55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ - update minimal textual version and snapshots ([#2998](https://github.com/nf-core/tools/pull/2998)) - return directory if base_dir is the root directory ([#3003](https://github.com/nf-core/tools/pull/3003)) - Update pre-commit hook astral-sh/ruff-pre-commit to v0.4.6 ([#3006](https://github.com/nf-core/tools/pull/3006)) +- Create: allow more special characters on the pipeline name for non-nf-core pipelines ([#3008](https://github.com/nf-core/tools/pull/3008)) ## [v2.14.1 - Tantalum Toad - Patch](https://github.com/nf-core/tools/releases/tag/2.14.1) - [2024-05-09] From 6275553f13f948ad76a6ebd0ec6ad2b73fa07cd1 Mon Sep 17 00:00:00 2001 From: mirpedrol Date: Wed, 29 May 2024 15:51:36 +0200 Subject: [PATCH 17/32] use union for typing --- nf_core/pipelines/create/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nf_core/pipelines/create/utils.py b/nf_core/pipelines/create/utils.py index 0754c54b54..d70fea1403 100644 --- a/nf_core/pipelines/create/utils.py +++ b/nf_core/pipelines/create/utils.py @@ -30,7 +30,7 @@ def init_context(value: Dict[str, Any]) -> Iterator[None]: # Define a global variable to store the pipeline type -PIPELINE_TYPE_GLOBAL: str | None = None +PIPELINE_TYPE_GLOBAL: Union[str, None] = None class CreateConfig(BaseModel): From 2b724e0e7f98d8f6b5956eda6b776041728885bd Mon Sep 17 00:00:00 2001 From: mirpedrol Date: Thu, 30 May 2024 13:46:53 +0200 Subject: [PATCH 18/32] use NFCORE_PIPELINE as a boolean instead of a PIPELINE_TYPE string --- nf_core/pipelines/create/__init__.py | 10 +++++----- nf_core/pipelines/create/basicdetails.py | 8 ++++---- nf_core/pipelines/create/utils.py | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/nf_core/pipelines/create/__init__.py b/nf_core/pipelines/create/__init__.py index c118d8520d..56e25bf1d5 100644 --- a/nf_core/pipelines/create/__init__.py +++ b/nf_core/pipelines/create/__init__.py @@ -59,7 +59,7 @@ class PipelineCreateApp(App[utils.CreateConfig]): TEMPLATE_CONFIG = utils.CreateConfig() # Initialise pipeline type - PIPELINE_TYPE = None + NFCORE_PIPELINE = True # Log handler LOG_HANDLER = log_handler @@ -74,12 +74,12 @@ def on_button_pressed(self, event: Button.Pressed) -> None: if event.button.id == "start": self.push_screen("choose_type") elif event.button.id == "type_nfcore": - self.PIPELINE_TYPE = "nfcore" - utils.PIPELINE_TYPE_GLOBAL = "nfcore" + self.NFCORE_PIPELINE = True + utils.NFCORE_PIPELINE_GLOBAL = True self.push_screen("basic_details") elif event.button.id == "type_custom": - self.PIPELINE_TYPE = "custom" - utils.PIPELINE_TYPE_GLOBAL = "custom" + self.NFCORE_PIPELINE = False + utils.NFCORE_PIPELINE_GLOBAL = False self.push_screen("basic_details") elif event.button.id == "continue": self.push_screen("final_details") diff --git a/nf_core/pipelines/create/basicdetails.py b/nf_core/pipelines/create/basicdetails.py index b88ede10d0..09484fa2ea 100644 --- a/nf_core/pipelines/create/basicdetails.py +++ b/nf_core/pipelines/create/basicdetails.py @@ -39,7 +39,7 @@ def compose(self) -> ComposeResult: "GitHub organisation", "nf-core", classes="column", - disabled=self.parent.PIPELINE_TYPE == "nfcore", + disabled=self.parent.NFCORE_PIPELINE, ) yield TextInput( "name", @@ -85,7 +85,7 @@ def on_screen_resume(self): add_hide_class(self.parent, "exist_warn") for text_input in self.query("TextInput"): if text_input.field_id == "org": - text_input.disabled = self.parent.PIPELINE_TYPE == "nfcore" + text_input.disabled = self.parent.NFCORE_PIPELINE @on(Button.Pressed) def on_button_pressed(self, event: Button.Pressed) -> None: @@ -102,9 +102,9 @@ def on_button_pressed(self, event: Button.Pressed) -> None: try: self.parent.TEMPLATE_CONFIG = CreateConfig(**config) if event.button.id == "next": - if self.parent.PIPELINE_TYPE == "nfcore": + if self.parent.NFCORE_PIPELINE: self.parent.push_screen("type_nfcore") - elif self.parent.PIPELINE_TYPE == "custom": + else: self.parent.push_screen("type_custom") except ValueError: pass diff --git a/nf_core/pipelines/create/utils.py b/nf_core/pipelines/create/utils.py index d70fea1403..f1e0bae3ce 100644 --- a/nf_core/pipelines/create/utils.py +++ b/nf_core/pipelines/create/utils.py @@ -30,7 +30,7 @@ def init_context(value: Dict[str, Any]) -> Iterator[None]: # Define a global variable to store the pipeline type -PIPELINE_TYPE_GLOBAL: Union[str, None] = None +NFCORE_PIPELINE_GLOBAL: bool = True class CreateConfig(BaseModel): @@ -148,7 +148,7 @@ def validate(self, value: str) -> ValidationResult: If it fails, return the error messages.""" try: - with init_context({"is_nfcore": PIPELINE_TYPE_GLOBAL == "nfcore"}): + with init_context({"is_nfcore": NFCORE_PIPELINE_GLOBAL}): CreateConfig(**{f"{self.key}": value}) return self.success() except ValidationError as e: From 02017aac324b790d7afedfbaa2edc9ca8fb7fb9f Mon Sep 17 00:00:00 2001 From: Phil Ewels Date: Fri, 31 May 2024 23:13:04 +0200 Subject: [PATCH 19/32] README - absolute image paths Make the logo render on PyPI --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 85b608bf77..58fb708a0d 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@

- - nf-core/tools + + nf-core/tools

From 089264292c7f1430c2e17f0978c1169dfc369ff7 Mon Sep 17 00:00:00 2001 From: nf-core-bot Date: Fri, 31 May 2024 21:13:59 +0000 Subject: [PATCH 20/32] [automated] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a1d7678c45..e8a8d1fbf6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ - return directory if base_dir is the root directory ([#3003](https://github.com/nf-core/tools/pull/3003)) - Update pre-commit hook astral-sh/ruff-pre-commit to v0.4.6 ([#3006](https://github.com/nf-core/tools/pull/3006)) - Create: allow more special characters on the pipeline name for non-nf-core pipelines ([#3008](https://github.com/nf-core/tools/pull/3008)) +- README - absolute image paths ([#3013](https://github.com/nf-core/tools/pull/3013)) ## [v2.14.1 - Tantalum Toad - Patch](https://github.com/nf-core/tools/releases/tag/2.14.1) - [2024-05-09] From b96f56b15d24431fb97382bed7715bccfafd21df Mon Sep 17 00:00:00 2001 From: Phil Ewels Date: Fri, 31 May 2024 23:35:39 +0200 Subject: [PATCH 21/32] Conda module linting: Include package name in log file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tried to do this with GitHub Copilot Workspaces but it failed 😅 As I was looking at the code anyway I could see the fix so figured I would put it manually. Closes https://github.com/nf-core/tools/issues/3009 Untested, done in web browser only. --- nf_core/modules/lint/main_nf.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nf_core/modules/lint/main_nf.py b/nf_core/modules/lint/main_nf.py index fd4d81f7f2..81308ba5c5 100644 --- a/nf_core/modules/lint/main_nf.py +++ b/nf_core/modules/lint/main_nf.py @@ -367,14 +367,14 @@ def check_process_section(self, lines, registry, fix_version, progress_bar): # response = _bioconda_package(bp) response = nf_core.utils.anaconda_package(bp) except LookupError: - self.warned.append(("bioconda_version", "Conda version not specified correctly", self.main_nf)) + self.warned.append(("bioconda_version", f"Conda version not specified correctly: {bp}", self.main_nf)) except ValueError: - self.failed.append(("bioconda_version", "Conda version not specified correctly", self.main_nf)) + self.failed.append(("bioconda_version", f"Conda version not specified correctly: {bp}", self.main_nf)) else: # Check that required version is available at all if bioconda_version not in response.get("versions"): self.failed.append( - ("bioconda_version", f"Conda package had unknown version: `{bioconda_version}`", self.main_nf) + ("bioconda_version", f"Conda package {bp} had unknown version: `{bioconda_version}`", self.main_nf) ) continue # No need to test for latest version, continue linting # Check version is latest available From 93acb91abe8c418ac9a8b9f06b237e2ec2d980e2 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 22:20:54 +0000 Subject: [PATCH 22/32] Update pre-commit hook astral-sh/ruff-pre-commit to v0.4.7 --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8521c44100..0bfe44f870 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.4.6 + rev: v0.4.7 hooks: - id: ruff # linter args: [--fix, --exit-non-zero-on-fix] # sort imports and fix From d4a91832343df619927ed1fdcc776c0daffb5e5a Mon Sep 17 00:00:00 2001 From: nf-core-bot Date: Fri, 31 May 2024 22:21:50 +0000 Subject: [PATCH 23/32] [automated] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a1d7678c45..515189e300 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ - return directory if base_dir is the root directory ([#3003](https://github.com/nf-core/tools/pull/3003)) - Update pre-commit hook astral-sh/ruff-pre-commit to v0.4.6 ([#3006](https://github.com/nf-core/tools/pull/3006)) - Create: allow more special characters on the pipeline name for non-nf-core pipelines ([#3008](https://github.com/nf-core/tools/pull/3008)) +- Update pre-commit hook astral-sh/ruff-pre-commit to v0.4.7 ([#3015](https://github.com/nf-core/tools/pull/3015)) ## [v2.14.1 - Tantalum Toad - Patch](https://github.com/nf-core/tools/releases/tag/2.14.1) - [2024-05-09] From 847a3763d1b67a9e75432bf0c74a0c531891d687 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlia=20Mir=20Pedrol?= Date: Mon, 3 Jun 2024 08:40:07 +0000 Subject: [PATCH 24/32] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a1d7678c45..6b421ba4de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ ### Linting - Fix linting fail on nfcore_external_java_deps if nf_schema is used ([#2976](https://github.com/nf-core/tools/pull/2976)) +- Conda module linting: Include package name in log file ([#3014](https://github.com/nf-core/tools/pull/3014)) ### Download From 005972e33d0d5808791fbcc18a6af914b249babc Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 5 Jun 2024 19:58:25 +0000 Subject: [PATCH 25/32] Update pre-commit hook astral-sh/ruff-pre-commit to v0.4.8 --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0bfe44f870..2e1373904f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.4.7 + rev: v0.4.8 hooks: - id: ruff # linter args: [--fix, --exit-non-zero-on-fix] # sort imports and fix From ee5a22b263ffe926fc4e437adcc45831d13ab4e8 Mon Sep 17 00:00:00 2001 From: nf-core-bot Date: Wed, 5 Jun 2024 19:59:12 +0000 Subject: [PATCH 26/32] [automated] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 996650e00a..1d82830b71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ - Create: allow more special characters on the pipeline name for non-nf-core pipelines ([#3008](https://github.com/nf-core/tools/pull/3008)) - README - absolute image paths ([#3013](https://github.com/nf-core/tools/pull/3013)) - Update pre-commit hook astral-sh/ruff-pre-commit to v0.4.7 ([#3015](https://github.com/nf-core/tools/pull/3015)) +- Update pre-commit hook astral-sh/ruff-pre-commit to v0.4.8 ([#3017](https://github.com/nf-core/tools/pull/3017)) ## [v2.14.1 - Tantalum Toad - Patch](https://github.com/nf-core/tools/releases/tag/2.14.1) - [2024-05-09] From 8ee2040007c222825dc8356a731a024424cc1397 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 8 Jun 2024 01:11:09 +0000 Subject: [PATCH 27/32] Update python:3.12-slim Docker digest to e3ae8cf --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index fe4162b4fe..6fe79d2eba 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.12-slim@sha256:afc139a0a640942491ec481ad8dda10f2c5b753f5c969393b12480155fe15a63 +FROM python:3.12-slim@sha256:e3ae8cf03c4f0abbfef13a8147478a7cd92798a94fa729a36a185d9106cbae32 LABEL authors="phil.ewels@seqera.io,erik.danielsson@scilifelab.se" \ description="Docker image containing requirements for nf-core/tools" From a63a653ab230e6b576d3e1cd952a51433a852ea4 Mon Sep 17 00:00:00 2001 From: nf-core-bot Date: Sun, 9 Jun 2024 03:35:11 +0000 Subject: [PATCH 28/32] [automated] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d82830b71..715bc2dc12 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ - README - absolute image paths ([#3013](https://github.com/nf-core/tools/pull/3013)) - Update pre-commit hook astral-sh/ruff-pre-commit to v0.4.7 ([#3015](https://github.com/nf-core/tools/pull/3015)) - Update pre-commit hook astral-sh/ruff-pre-commit to v0.4.8 ([#3017](https://github.com/nf-core/tools/pull/3017)) +- Update python:3.12-slim Docker digest to e3ae8cf ([#3020](https://github.com/nf-core/tools/pull/3020)) ## [v2.14.1 - Tantalum Toad - Patch](https://github.com/nf-core/tools/releases/tag/2.14.1) - [2024-05-09] From 05f60b440aa3a2b5125ed3cc65ae8b86dc979ef2 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 13:30:29 +0000 Subject: [PATCH 29/32] Update dawidd6/action-download-artifact action to v6 --- nf_core/pipeline-template/.github/workflows/linting_comment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nf_core/pipeline-template/.github/workflows/linting_comment.yml b/nf_core/pipeline-template/.github/workflows/linting_comment.yml index ea408fd6f8..908dcea159 100644 --- a/nf_core/pipeline-template/.github/workflows/linting_comment.yml +++ b/nf_core/pipeline-template/.github/workflows/linting_comment.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Download lint results - uses: dawidd6/action-download-artifact@09f2f74827fd3a8607589e5ad7f9398816f540fe # v3 + uses: dawidd6/action-download-artifact@bf251b5aa9c2f7eeb574a96ee720e24f801b7c11 # v6 with: workflow: linting.yml workflow_conclusion: completed From 90f7e344d7e8d07060701bca0cedd36ce7866bf9 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 13 Jun 2024 18:31:15 +0000 Subject: [PATCH 30/32] Update python:3.12-slim Docker digest to 2fba8e7 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 6fe79d2eba..9ebc7e9853 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.12-slim@sha256:e3ae8cf03c4f0abbfef13a8147478a7cd92798a94fa729a36a185d9106cbae32 +FROM python:3.12-slim@sha256:2fba8e70a87bcc9f6edd20dda0a1d4adb32046d2acbca7361bc61da5a106a914 LABEL authors="phil.ewels@seqera.io,erik.danielsson@scilifelab.se" \ description="Docker image containing requirements for nf-core/tools" From 6f444c96d3292dd3fd9fd4863ec7716de6ed4c1d Mon Sep 17 00:00:00 2001 From: nf-core-bot Date: Fri, 14 Jun 2024 23:01:49 +0000 Subject: [PATCH 31/32] [automated] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 715bc2dc12..9da8c1ab24 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ - Update pre-commit hook astral-sh/ruff-pre-commit to v0.4.7 ([#3015](https://github.com/nf-core/tools/pull/3015)) - Update pre-commit hook astral-sh/ruff-pre-commit to v0.4.8 ([#3017](https://github.com/nf-core/tools/pull/3017)) - Update python:3.12-slim Docker digest to e3ae8cf ([#3020](https://github.com/nf-core/tools/pull/3020)) +- Update python:3.12-slim Docker digest to 2fba8e7 ([#3023](https://github.com/nf-core/tools/pull/3023)) ## [v2.14.1 - Tantalum Toad - Patch](https://github.com/nf-core/tools/releases/tag/2.14.1) - [2024-05-09] From a15a6f0e7f94a6d57e4d35a349b96bd29e7f886e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 15 Jun 2024 04:47:47 +0000 Subject: [PATCH 32/32] Update pre-commit hook astral-sh/ruff-pre-commit to v0.4.9 --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2e1373904f..6d8e34e0b4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.4.8 + rev: v0.4.9 hooks: - id: ruff # linter args: [--fix, --exit-non-zero-on-fix] # sort imports and fix