Skip to content

Commit

Permalink
Merge pull request #3247 from mashehu/add-dir-to-schema-commands
Browse files Browse the repository at this point in the history
add `--dir/-d` option to schema commands
  • Loading branch information
mashehu authored Oct 24, 2024
2 parents 3bc6453 + f49e9cf commit d59ac3f
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 10 deletions.
1 change: 0 additions & 1 deletion .github/.coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
omit = nf_core/*-template/*
source = nf_core
relative_files = True

2 changes: 2 additions & 0 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,14 @@ jobs:
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

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
43 changes: 36 additions & 7 deletions nf_core/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import logging
import os
import sys
from pathlib import Path

import rich
import rich.console
Expand Down Expand Up @@ -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="<pipeline name>")
@click.argument("params", type=click.Path(exists=True), required=True, metavar="<JSON params file>")
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)


Expand Down Expand Up @@ -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="<pipeline schema>",
)
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(Path(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,
Expand Down Expand Up @@ -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(Path(directory, schema_file), output, format, force, columns)


# nf-core modules subcommands
Expand Down
4 changes: 2 additions & 2 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down

0 comments on commit d59ac3f

Please sign in to comment.