From 6d3a3063fa1c7436bf4dbbe89f392f0fb9d3d172 Mon Sep 17 00:00:00 2001 From: mashehu Date: Thu, 24 Oct 2024 11:26:22 +0200 Subject: [PATCH 1/7] add `--dir/-d` option to schema commands --- nf_core/__main__.py | 43 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/nf_core/__main__.py b/nf_core/__main__.py index 356b16f7f..50963b662 100644 --- a/nf_core/__main__.py +++ b/nf_core/__main__.py @@ -4,6 +4,7 @@ import logging import os import sys +from pathlib import Path import rich import rich.console @@ -696,12 +697,24 @@ def pipeline_schema(): # nf-core pipelines schema validate @pipeline_schema.command("validate") +@click.option( + "-d", + "--dir", + "directory", + type=click.Path(exists=True), + default=".", + help=r"Pipeline directory. [dim]\[default: current working directory][/]", +) @click.argument("pipeline", required=True, metavar="") @click.argument("params", type=click.Path(exists=True), required=True, metavar="") -def command_pipelines_schema_validate(pipeline, params): +def command_pipelines_schema_validate(directory, pipeline, params): """ Validate a set of parameters against a pipeline schema. """ + if Path(directory, pipeline).exists(): + # this is a local pipeline + pipeline = Path(directory, pipeline) + pipelines_schema_validate(pipeline, params) @@ -740,23 +753,39 @@ def command_pipelines_schema_build(directory, no_prompts, web_only, url): # nf-core pipelines schema lint @pipeline_schema.command("lint") +@click.option( + "-d", + "--dir", + "directory", + type=click.Path(exists=True), + default=".", + help=r"Pipeline directory. [dim]\[default: current working directory][/]", +) @click.argument( - "schema_path", + "schema_file", type=click.Path(exists=True), default="nextflow_schema.json", metavar="", ) -def command_pipelines_schema_lint(schema_path): +def command_pipelines_schema_lint(directory, schema_file): """ Check that a given pipeline schema is valid. """ - pipelines_schema_lint(schema_path) + pipelines_schema_lint(directory / schema_file) # nf-core pipelines schema docs @pipeline_schema.command("docs") +@click.option( + "-d", + "--dir", + "directory", + type=click.Path(exists=True), + default=".", + help=r"Pipeline directory. [dim]\[default: current working directory][/]", +) @click.argument( - "schema_path", + "schema_file", type=click.Path(exists=True), default="nextflow_schema.json", required=False, @@ -785,11 +814,11 @@ def command_pipelines_schema_lint(schema_path): help="CSV list of columns to include in the parameter tables (parameter,description,type,default,required,hidden)", default="parameter,description,type,default,required,hidden", ) -def command_pipelines_schema_docs(schema_path, output, format, force, columns): +def command_pipelines_schema_docs(directory, schema_file, output, format, force, columns): """ Outputs parameter documentation for a pipeline schema. """ - pipelines_schema_docs(schema_path, output, format, force, columns) + pipelines_schema_docs(directory / schema_file, output, format, force, columns) # nf-core modules subcommands From 63153cfb4719bb6af912454242462855596990ab Mon Sep 17 00:00:00 2001 From: nf-core-bot Date: Thu, 24 Oct 2024 09:31:01 +0000 Subject: [PATCH 2/7] [automated] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index eac5adcdd..29400037c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ - Update python:3.12-slim Docker digest to 032c526 ([#3232](https://github.com/nf-core/tools/pull/3232)) - use correct `--profile` options for `nf-core subworkflows test` ([#3233](https://github.com/nf-core/tools/pull/3233)) - Update GitHub Actions ([#3237](https://github.com/nf-core/tools/pull/3237)) +- add `--dir/-d` option to schema commands ([#3247](https://github.com/nf-core/tools/pull/3247)) ## [v3.0.2 - Titanium Tapir Patch](https://github.com/nf-core/tools/releases/tag/3.0.2) - [2024-10-11] From 5099313f0c417c9ba24bf60c92032af5f8c6c585 Mon Sep 17 00:00:00 2001 From: mashehu Date: Thu, 24 Oct 2024 12:39:21 +0200 Subject: [PATCH 3/7] fix test_cli --- nf_core/__main__.py | 4 ++-- tests/test_cli.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/nf_core/__main__.py b/nf_core/__main__.py index 50963b662..bb4c5e708 100644 --- a/nf_core/__main__.py +++ b/nf_core/__main__.py @@ -771,7 +771,7 @@ def command_pipelines_schema_lint(directory, schema_file): """ Check that a given pipeline schema is valid. """ - pipelines_schema_lint(directory / schema_file) + pipelines_schema_lint(Path(directory, schema_file)) # nf-core pipelines schema docs @@ -818,7 +818,7 @@ def command_pipelines_schema_docs(directory, schema_file, output, format, force, """ Outputs parameter documentation for a pipeline schema. """ - pipelines_schema_docs(directory / schema_file, output, format, force, columns) + pipelines_schema_docs(Path(directory, schema_file), output, format, force, columns) # nf-core modules subcommands diff --git a/tests/test_cli.py b/tests/test_cli.py index bea0223f0..8df1e210b 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -358,7 +358,7 @@ def test_schema_lint(self, mock_get_schema_path): with open("nextflow_schema.json", "w") as f: f.write("{}") self.invoke_cli(cmd) - mock_get_schema_path.assert_called_with("nextflow_schema.json") + mock_get_schema_path.assert_called_with(Path("nextflow_schema.json")) @mock.patch("nf_core.pipelines.schema.PipelineSchema.get_schema_path") def test_schema_lint_filename(self, mock_get_schema_path): @@ -368,7 +368,7 @@ def test_schema_lint_filename(self, mock_get_schema_path): with open("some_other_filename", "w") as f: f.write("{}") self.invoke_cli(cmd) - mock_get_schema_path.assert_called_with("some_other_filename") + mock_get_schema_path.assert_called_with(Path("some_other_filename")) @mock.patch("nf_core.pipelines.create_logo.create_logo") def test_create_logo(self, mock_create_logo): From 884cafd5320ee1f3d7bb1f614d2d05ebbc83e928 Mon Sep 17 00:00:00 2001 From: mashehu Date: Thu, 24 Oct 2024 13:40:50 +0200 Subject: [PATCH 4/7] try specifying the coverage output file --- .github/.coveragerc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/.coveragerc b/.github/.coveragerc index 24a419ae0..e9794f691 100644 --- a/.github/.coveragerc +++ b/.github/.coveragerc @@ -2,4 +2,4 @@ omit = nf_core/*-template/* source = nf_core relative_files = True - +data_file = ".coverage" From 0cb8f497b7257d7a5b28222bea29c6197a7b36b5 Mon Sep 17 00:00:00 2001 From: mashehu Date: Thu, 24 Oct 2024 14:45:32 +0200 Subject: [PATCH 5/7] try naming the files directly --- .github/.coveragerc | 1 - .github/workflows/pytest.yml | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/.coveragerc b/.github/.coveragerc index e9794f691..cbdcccdac 100644 --- a/.github/.coveragerc +++ b/.github/.coveragerc @@ -2,4 +2,3 @@ omit = nf_core/*-template/* source = nf_core relative_files = True -data_file = ".coverage" diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index a29a6970e..4aadfd3a0 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -132,7 +132,9 @@ jobs: - name: Test with pytest run: | - python3 -m pytest tests/${{matrix.test}} --color=yes --cov --durations=0 && exit_code=0|| exit_code=$? + python3 -m pytest tests/${{matrix.test}} --color=yes --cov --cov-data-file=.coverage.${{ env.test }} --durations=0 && exit_code=0|| exit_code=$? + echo "Current directory contents:" + ls -la # don't fail if no tests were collected, e.g. for test_licence.py if [ "${exit_code}" -eq 5 ]; then echo "No tests were collected" @@ -158,7 +160,7 @@ jobs: uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4 with: name: coverage_${{ env.test }} - path: .coverage + path: .coverage.${{ env.test }} coverage: needs: test From 103a19600abf3669314abc3030812363486636ee Mon Sep 17 00:00:00 2001 From: mashehu Date: Thu, 24 Oct 2024 15:02:48 +0200 Subject: [PATCH 6/7] fix variable name --- .github/workflows/pytest.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 4aadfd3a0..caf318af8 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -130,6 +130,11 @@ jobs: run: | mv .github/.coveragerc . + - name: remove slashes from test name + run: | + test=$(echo ${{ matrix.test }} | sed 's/\//__/g') + echo "test=${test}" >> $GITHUB_ENV + - name: Test with pytest run: | python3 -m pytest tests/${{matrix.test}} --color=yes --cov --cov-data-file=.coverage.${{ env.test }} --durations=0 && exit_code=0|| exit_code=$? @@ -144,11 +149,6 @@ jobs: exit 1 fi - - name: remove slashes from test name - run: | - test=$(echo ${{ matrix.test }} | sed 's/\//__/g') - echo "test=${test}" >> $GITHUB_ENV - - name: Store snapshot report uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4 if: always() From f49e9cf79d19490edb18505d12e9c0260cd60266 Mon Sep 17 00:00:00 2001 From: mashehu Date: Thu, 24 Oct 2024 16:01:49 +0200 Subject: [PATCH 7/7] add hiddnen files for upload-artifact action v4 --- .github/workflows/pytest.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index caf318af8..2f48e67b5 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -130,16 +130,9 @@ jobs: run: | mv .github/.coveragerc . - - name: remove slashes from test name - run: | - test=$(echo ${{ matrix.test }} | sed 's/\//__/g') - echo "test=${test}" >> $GITHUB_ENV - - name: Test with pytest run: | - python3 -m pytest tests/${{matrix.test}} --color=yes --cov --cov-data-file=.coverage.${{ env.test }} --durations=0 && exit_code=0|| exit_code=$? - echo "Current directory contents:" - ls -la + python3 -m pytest tests/${{matrix.test}} --color=yes --cov --durations=0 && exit_code=0|| exit_code=$? # don't fail if no tests were collected, e.g. for test_licence.py if [ "${exit_code}" -eq 5 ]; then echo "No tests were collected" @@ -149,18 +142,25 @@ jobs: exit 1 fi + - name: remove slashes from test name + run: | + test=$(echo ${{ matrix.test }} | sed 's/\//__/g') + echo "test=${test}" >> $GITHUB_ENV + - name: Store snapshot report uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4 if: always() with: + include-hidden-files: true name: Snapshot Report ${{ env.test }} path: ./snapshot_report.html - name: Upload coverage uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4 with: + include-hidden-files: true name: coverage_${{ env.test }} - path: .coverage.${{ env.test }} + path: .coverage coverage: needs: test