Skip to content

Commit d59ac3f

Browse files
authored
Merge pull request #3247 from mashehu/add-dir-to-schema-commands
add `--dir/-d` option to schema commands
2 parents 3bc6453 + f49e9cf commit d59ac3f

File tree

5 files changed

+41
-10
lines changed

5 files changed

+41
-10
lines changed

.github/.coveragerc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@
22
omit = nf_core/*-template/*
33
source = nf_core
44
relative_files = True
5-

.github/workflows/pytest.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,14 @@ jobs:
151151
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
152152
if: always()
153153
with:
154+
include-hidden-files: true
154155
name: Snapshot Report ${{ env.test }}
155156
path: ./snapshot_report.html
156157

157158
- name: Upload coverage
158159
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
159160
with:
161+
include-hidden-files: true
160162
name: coverage_${{ env.test }}
161163
path: .coverage
162164

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
- Update python:3.12-slim Docker digest to 032c526 ([#3232](https://github.com/nf-core/tools/pull/3232))
2828
- use correct `--profile` options for `nf-core subworkflows test` ([#3233](https://github.com/nf-core/tools/pull/3233))
2929
- Update GitHub Actions ([#3237](https://github.com/nf-core/tools/pull/3237))
30+
- add `--dir/-d` option to schema commands ([#3247](https://github.com/nf-core/tools/pull/3247))
3031

3132
## [v3.0.2 - Titanium Tapir Patch](https://github.com/nf-core/tools/releases/tag/3.0.2) - [2024-10-11]
3233

nf_core/__main__.py

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import logging
55
import os
66
import sys
7+
from pathlib import Path
78

89
import rich
910
import rich.console
@@ -696,12 +697,24 @@ def pipeline_schema():
696697

697698
# nf-core pipelines schema validate
698699
@pipeline_schema.command("validate")
700+
@click.option(
701+
"-d",
702+
"--dir",
703+
"directory",
704+
type=click.Path(exists=True),
705+
default=".",
706+
help=r"Pipeline directory. [dim]\[default: current working directory][/]",
707+
)
699708
@click.argument("pipeline", required=True, metavar="<pipeline name>")
700709
@click.argument("params", type=click.Path(exists=True), required=True, metavar="<JSON params file>")
701-
def command_pipelines_schema_validate(pipeline, params):
710+
def command_pipelines_schema_validate(directory, pipeline, params):
702711
"""
703712
Validate a set of parameters against a pipeline schema.
704713
"""
714+
if Path(directory, pipeline).exists():
715+
# this is a local pipeline
716+
pipeline = Path(directory, pipeline)
717+
705718
pipelines_schema_validate(pipeline, params)
706719

707720

@@ -740,23 +753,39 @@ def command_pipelines_schema_build(directory, no_prompts, web_only, url):
740753

741754
# nf-core pipelines schema lint
742755
@pipeline_schema.command("lint")
756+
@click.option(
757+
"-d",
758+
"--dir",
759+
"directory",
760+
type=click.Path(exists=True),
761+
default=".",
762+
help=r"Pipeline directory. [dim]\[default: current working directory][/]",
763+
)
743764
@click.argument(
744-
"schema_path",
765+
"schema_file",
745766
type=click.Path(exists=True),
746767
default="nextflow_schema.json",
747768
metavar="<pipeline schema>",
748769
)
749-
def command_pipelines_schema_lint(schema_path):
770+
def command_pipelines_schema_lint(directory, schema_file):
750771
"""
751772
Check that a given pipeline schema is valid.
752773
"""
753-
pipelines_schema_lint(schema_path)
774+
pipelines_schema_lint(Path(directory, schema_file))
754775

755776

756777
# nf-core pipelines schema docs
757778
@pipeline_schema.command("docs")
779+
@click.option(
780+
"-d",
781+
"--dir",
782+
"directory",
783+
type=click.Path(exists=True),
784+
default=".",
785+
help=r"Pipeline directory. [dim]\[default: current working directory][/]",
786+
)
758787
@click.argument(
759-
"schema_path",
788+
"schema_file",
760789
type=click.Path(exists=True),
761790
default="nextflow_schema.json",
762791
required=False,
@@ -785,11 +814,11 @@ def command_pipelines_schema_lint(schema_path):
785814
help="CSV list of columns to include in the parameter tables (parameter,description,type,default,required,hidden)",
786815
default="parameter,description,type,default,required,hidden",
787816
)
788-
def command_pipelines_schema_docs(schema_path, output, format, force, columns):
817+
def command_pipelines_schema_docs(directory, schema_file, output, format, force, columns):
789818
"""
790819
Outputs parameter documentation for a pipeline schema.
791820
"""
792-
pipelines_schema_docs(schema_path, output, format, force, columns)
821+
pipelines_schema_docs(Path(directory, schema_file), output, format, force, columns)
793822

794823

795824
# nf-core modules subcommands

tests/test_cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ def test_schema_lint(self, mock_get_schema_path):
358358
with open("nextflow_schema.json", "w") as f:
359359
f.write("{}")
360360
self.invoke_cli(cmd)
361-
mock_get_schema_path.assert_called_with("nextflow_schema.json")
361+
mock_get_schema_path.assert_called_with(Path("nextflow_schema.json"))
362362

363363
@mock.patch("nf_core.pipelines.schema.PipelineSchema.get_schema_path")
364364
def test_schema_lint_filename(self, mock_get_schema_path):
@@ -368,7 +368,7 @@ def test_schema_lint_filename(self, mock_get_schema_path):
368368
with open("some_other_filename", "w") as f:
369369
f.write("{}")
370370
self.invoke_cli(cmd)
371-
mock_get_schema_path.assert_called_with("some_other_filename")
371+
mock_get_schema_path.assert_called_with(Path("some_other_filename"))
372372

373373
@mock.patch("nf_core.pipelines.create_logo.create_logo")
374374
def test_create_logo(self, mock_create_logo):

0 commit comments

Comments
 (0)