-
Notifications
You must be signed in to change notification settings - Fork 223
added check for parameter description #1049
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
bf7ec67
added check for parameter description
KevinMenden 74b8f10
update changelog
KevinMenden 4ed2c31
fixed missing things/tests
KevinMenden c1dfd07
Merge branch 'dev' into lint-schema-description
ewels 5178790
Apply suggestions from code review
KevinMenden 2dff23b
add support for ignoring params
KevinMenden 2181487
Merge branch 'dev' into lint-schema-description
ewels 4f75b6a
Apply suggestions from code review
KevinMenden 819f018
Merge branch 'dev' into lint-schema-description
ewels File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| schema_description | ||
| =========== | ||
|
|
||
| .. automethod:: nf_core.lint.PipelineLint.schema_description |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| #!/usr/bin/env python | ||
|
|
||
| from logging import warn | ||
| import nf_core.schema | ||
|
|
||
|
|
||
| def schema_description(self): | ||
| """Check that every parameter in the schema has a description | ||
|
|
||
| The ``nextflow_schema.json`` pipeline schema should describe every flat parameter | ||
| Furthermore warns about parameters outside of groups | ||
|
|
||
| * Warning: Parameters in ``nextflow_schema.json`` without a description | ||
| * Warning: Parameters in ``nextflow_schema.json`` that are defined outside of a group | ||
| """ | ||
| passed = [] | ||
| warned = [] | ||
| ignored = [] | ||
|
|
||
| # First, get the top-level config options for the pipeline | ||
| # Schema object already created in the `schema_lint` test | ||
| self.schema_obj = nf_core.schema.PipelineSchema() | ||
| self.schema_obj.get_schema_path(self.wf_path) | ||
| self.schema_obj.get_wf_params() | ||
| self.schema_obj.no_prompts = True | ||
| self.schema_obj.load_lint_schema() | ||
|
|
||
| # Get parameters that should be ignored according to the linting config | ||
| ignore_params = self.lint_config.get("schema_description", []) | ||
|
|
||
| # Get ungrouped params | ||
| if "properties" in self.schema_obj.schema.keys(): | ||
| ungrouped_params = self.schema_obj.schema["properties"].keys() | ||
| for up in ungrouped_params: | ||
| if up in ignore_params: | ||
| ignored.append(f"Ignored ungrouped param in schema: `{up}`") | ||
| else: | ||
| warned.append(f"Ungrouped param in schema: `{up}`") | ||
|
|
||
| # Iterate over groups and add warning for parameters without a description | ||
| for group_key in self.schema_obj.schema["definitions"].keys(): | ||
| group = self.schema_obj.schema["definitions"][group_key] | ||
| for param_key, param in group["properties"].items(): | ||
| if param_key in ignore_params: | ||
| ignored.append(f"Ignoring description check for param in schema: `{param_key}`") | ||
| continue | ||
| if "description" not in param.keys(): | ||
| warned.append(f"No description provided in schema for parameter: `{param_key}`") | ||
|
|
||
| for ip in ignore_params: | ||
| ignored.append(f"Parameter is ignored: `{ip}`") | ||
|
|
||
| return {"passed": passed, "warned": warned, "ignored": ignored} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.