Skip to content
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

Increase worflow linting #1463

Merged
merged 29 commits into from
Jul 4, 2024
Merged

Conversation

lldelisle
Copy link
Contributor

I am not sure it is the good way to do it.
For the moment, I cannot make it like for the tools with classes, in order to make it customizable but I think I put everything I thought was missing in the current workflow_lint.
I used sometimes ' and sometimes ". Is this an issue?

@lldelisle
Copy link
Contributor Author

I don't know how to fix:

./planemo/workflow_lint.py:434:1: C901 '_lint_dockstore_workflow_entry' is too complex (15)

@lldelisle
Copy link
Contributor Author

lldelisle commented Jun 29, 2024

I implemented new linting for the .dockstore.yml. I generate a warning if the workflow has no name or no authors as a consequence the test CmdWorkflowLintTestCase is not passing anymore while it is running with --skip best_practices. Edit: Should I integrate these warnings into the best practices? (I cannot because best practices are for workflow files not .dockstore.yml currently).

@lldelisle
Copy link
Contributor Author

Also I am wondering how many tests I should generate following these changes?

Copy link
Contributor

@bernt-matthias bernt-matthias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool. I think adding a test for the --iwc flag would be good.

planemo/commands/cmd_workflow_lint.py Outdated Show resolved Hide resolved
planemo/workflow_lint.py Outdated Show resolved Hide resolved
planemo/workflow_lint.py Outdated Show resolved Hide resolved
@lldelisle
Copy link
Contributor Author

Hi,
Here is a summary of this PR:
I have defined:

  • 2 new linters for directories:
    • required_files: check that there is a CHANGELOG.md, a README.md, a .dockstore.yml
    • changelog: check that there is a version defined in the CHANGELOG.md
  • 1 new linter for .dockstore.yml
    • dockstore_best_practices which requires tests and authors and name
  • 1 new linter for workflow
    • release that checks that the release matches what is in the CHANGELOG.md
      All these new linters are enabled when the argument --iwc is set.
      I have improved the linter dockstore with common errors we identified in iwc.

Importantly, the check for a testParameterFiles in .dockstore has been moved to dockstore_best_practices so in a regular run will not raise a warning anymore.

@mvdbeek
Copy link
Member

mvdbeek commented Jul 1, 2024

You can run black to fix the linting errors

@mvdbeek
Copy link
Member

mvdbeek commented Jul 1, 2024

And isort to fix the importing ... in fact we should add the same make format that we have for galaxy

@lldelisle
Copy link
Contributor Author

@mvdbeek can you help me with the last test. How to assert that the command raise an InputError? and that the exception message contains a given string? Should I test on result.error rather than result.output?

@mvdbeek
Copy link
Member

mvdbeek commented Jul 1, 2024

I'm seeing:

"Unknown linter type(s) [''] in list of linters to be skipped. Known linters ['CitationsMissing', 'CitationsNoText', 'CitationsFound', 'CitationsNoValid', 'CommandMissing', 'CommandEmpty', 'CommandTODO', 'CommandInterpreterDeprecated', 'CommandInfo', 'CWLValid', 'CWLInValid', 'CWLVersionMissing', 'CWLVersionUnknown', 'CWLVersionGood', 'CWLDockerMissing', 'CWLDockerGood', 'CWLDescriptionMissing', 'CWLHelpTODO', 'ToolVersionMissing', 'ToolVersionPEP404', 'ToolVersionWhitespace', 'ToolVersionValid', 'ToolNameMissing', 'ToolNameWhitespace', 'ToolNameValid', 'ToolIDMissing', 'ToolIDWhitespace', 'ToolIDValid', 'ToolProfileInvalid', 'ToolProfileLegacy', 'ToolProfileValid', 'RequirementNameMissing', 'RequirementVersionMissing', 'RequirementVersionWhitespace', 'ResourceRequirementExpression', 'HelpMissing', 'HelpEmpty', 'HelpPresent', 'HelpTODO', 'HelpInvalidRST', 'HelpValidRST', 'InputsNum', 'InputsMissing', 'InputsMissingDataSource', 'InputsDatasourceTags', 'InputsName', 'InputsNameRedundantArgument', 'InputsNameEmpty', 'InputsNameValid', 'InputsNameDuplicate', 'InputsNameDuplicateOutput', 'InputsTypeChildCombination', 'InputsDataFormat', 'InputsDataOptionsMultiple', 'InputsDataOptionsA...lidatorDatasetMetadataEqualValueOrJson', 'ValidatorMetadataCheckSkip', 'ValidatorTableName', 'ValidatorMetadataName', 'ConditionalParamTypeBool', 'ConditionalParamType', 'ConditionalParamIncompatibleAttributes', 'ConditionalWhenMissing', 'ConditionalOptionMissing', 'ConditionalOptionMissingBoolean', 'OutputsMissing', 'OutputsOutput', 'OutputsNameInvalidCheetah', 'OutputsNameDuplicated', 'OutputsLabelDuplicatedFilter', 'OutputsLabelDuplicatedNoFilter', 'OutputsCollectionType', 'OutputsNumber', 'OutputsFormatInput', 'OutputsFormat', 'OutputsFormatSourceIncomp', 'StdIOAbsenceLegacy', 'StdIOAbsence', 'StdIORegex', 'TestsMissing', 'TestsMissingDatasource', 'TestsAssertsMultiple', 'TestsAssertsHasNQuant', 'TestsAssertsHasSizeQuant', 'TestsAssertsHasSizeOrValueQuant', 'TestsExpectNumOutputs', 'TestsParamInInputs', 'TestsOutputName', 'TestsOutputDefined', 'TestsOutputCorresponding', 'TestsOutputCollectionCorresponding', 'TestsOutputCompareAttrib', 'TestsOutputCheckDiscovered', 'TestsOutputCollectionCheckDiscovered', 'TestsOutputCollectionCheckDiscoveredNested', 'TestsOutputFailing', 'TestsExpectNumOutputsFailing', 'TestsHasExpectations', 'TestsNoValid', 'TestsValid', 'XMLOrder', 'XSD']\n"

I would think that probably means we're not correctly handing a default argument in the skip linters case ?

@lldelisle
Copy link
Contributor Author

Yes I wanted to tell @bernt-matthias about this. This is a message I get each time I run planemo workflow_lint but surprisingly it still gives a exit code of 0:

(planemo) (base) ldelisle@HP-EliteBook-840-G8-Notebook-PC:~/Documents/mygit/planemo$ planemo workflow_lint tests/data/wf_repos/basic_format2_dockstore --skip best_practices
Unknown linter type(s) ['best_practices'] in list of linters to be skipped. Known linters []
.. CHECK: Tests appear structurally correct for tests/data/wf_repos/basic_format2_dockstore/basic_format2.gxwf.yml
.. CHECK: All tool ids appear to be valid.
(planemo) (base) ldelisle@HP-EliteBook-840-G8-Notebook-PC:~/Documents/mygit/planemo$ echo $?
0

@lldelisle
Copy link
Contributor Author

And even without skip, the message is very confusing for users:

(planemo) (base) ldelisle@HP-EliteBook-840-G8-Notebook-PC:~/Documents/mygit/planemo$ planemo workflow_lint tests/data/wf_repos/basic_wf_iwc_invalid_version/
Unknown linter type(s) [''] in list of linters to be skipped. Known linters []
.. CHECK: Tests appear structurally correct for tests/data/wf_repos/basic_wf_iwc_invalid_version/Super-simple-workflow.ga
.. CHECK: All tool ids appear to be valid.
(planemo) (base) ldelisle@HP-EliteBook-840-G8-Notebook-PC:~/Documents/mygit/planemo$ echo $?
0

But I don't know if this should be solved in this PR or in another PR.

@mvdbeek
Copy link
Member

mvdbeek commented Jul 1, 2024

That's a different from the one in the test though.

diff --git a/planemo/lint.py b/planemo/lint.py
index 5b85022de4..c5964428aa 100644
--- a/planemo/lint.py
+++ b/planemo/lint.py
@@ -23,7 +23,7 @@ def build_lint_args(ctx, **kwds):
         skip = ctx.global_config.get("lint_skip", "")
         if isinstance(skip, list):
             skip = ",".join(skip)
-    skip_types = [s.strip() for s in skip.split(",")]
+    skip_types = [s.strip() for s in skip.split(",") if s.strip()]

     for skip_file in kwds.get("skip_file", []):
         with open(skip_file) as f:

fixes the odd test output.

@lldelisle
Copy link
Contributor Author

Because this would require a big rearrangement I think and it is more difficult to review.

@lldelisle
Copy link
Contributor Author

fixes the odd test output.

I can integrate this.

@bernt-matthias
Copy link
Contributor

I'm seeing:

"Unknown linter type(s) [''] in list of linters to be skipped. Known linters ['CitationsMissing', 'CitationsNoText', 'CitationsFound', 'CitationsNoValid', 'CommandMissing', 'CommandEmpty', 'CommandTODO', 'CommandInterpreterDeprecated', 'CommandInfo', 'CWLValid', 'CWLInValid', 'CWLVersionMissing', 'CWLVersionUnknown', 'CWLVersionGood', 'CWLDockerMissing', 'CWLDockerGood', 'CWLDescriptionMissing', 'CWLHelpTODO', 'ToolVersionMissing', 'ToolVersionPEP404', 'ToolVersionWhitespace', 'ToolVersionValid', 'ToolNameMissing', 'ToolNameWhitespace', 'ToolNameValid', 'ToolIDMissing', 'ToolIDWhitespace', 'ToolIDValid', 'ToolProfileInvalid', 'ToolProfileLegacy', 'ToolProfileValid', 'RequirementNameMissing', 'RequirementVersionMissing', 'RequirementVersionWhitespace', 'ResourceRequirementExpression', 'HelpMissing', 'HelpEmpty', 'HelpPresent', 'HelpTODO', 'HelpInvalidRST', 'HelpValidRST', 'InputsNum', 'InputsMissing', 'InputsMissingDataSource', 'InputsDatasourceTags', 'InputsName', 'InputsNameRedundantArgument', 'InputsNameEmpty', 'InputsNameValid', 'InputsNameDuplicate', 'InputsNameDuplicateOutput', 'InputsTypeChildCombination', 'InputsDataFormat', 'InputsDataOptionsMultiple', 'InputsDataOptionsA...lidatorDatasetMetadataEqualValueOrJson', 'ValidatorMetadataCheckSkip', 'ValidatorTableName', 'ValidatorMetadataName', 'ConditionalParamTypeBool', 'ConditionalParamType', 'ConditionalParamIncompatibleAttributes', 'ConditionalWhenMissing', 'ConditionalOptionMissing', 'ConditionalOptionMissingBoolean', 'OutputsMissing', 'OutputsOutput', 'OutputsNameInvalidCheetah', 'OutputsNameDuplicated', 'OutputsLabelDuplicatedFilter', 'OutputsLabelDuplicatedNoFilter', 'OutputsCollectionType', 'OutputsNumber', 'OutputsFormatInput', 'OutputsFormat', 'OutputsFormatSourceIncomp', 'StdIOAbsenceLegacy', 'StdIOAbsence', 'StdIORegex', 'TestsMissing', 'TestsMissingDatasource', 'TestsAssertsMultiple', 'TestsAssertsHasNQuant', 'TestsAssertsHasSizeQuant', 'TestsAssertsHasSizeOrValueQuant', 'TestsExpectNumOutputs', 'TestsParamInInputs', 'TestsOutputName', 'TestsOutputDefined', 'TestsOutputCorresponding', 'TestsOutputCollectionCorresponding', 'TestsOutputCompareAttrib', 'TestsOutputCheckDiscovered', 'TestsOutputCollectionCheckDiscovered', 'TestsOutputCollectionCheckDiscoveredNested', 'TestsOutputFailing', 'TestsExpectNumOutputsFailing', 'TestsHasExpectations', 'TestsNoValid', 'TestsValid', 'XMLOrder', 'XSD']\n"

I would think that probably means we're not correctly handing a default argument in the skip linters case ?

Fixed in #1453

@bernt-matthias
Copy link
Contributor

This: Known linters [] is a problem... I will submit a fix in a separate PR.

@bernt-matthias
Copy link
Contributor

#1465

@lldelisle lldelisle changed the title [WIP] increase worflow linting Increase worflow linting Jul 2, 2024
@lldelisle
Copy link
Contributor Author

The only test failing seems unrelated to this PR.

@@ -59,6 +60,12 @@ class WorkflowLintContext(LintContext):
training_topic = None


def build_wf_lint_args(ctx, **kwds):
lint_args = build_lint_args(ctx, **kwds)
lint_args["iwc_grade"] = str(kwds.get("iwc", False))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
lint_args["iwc_grade"] = str(kwds.get("iwc", False))
lint_args["iwc_grade"] = kwds.get("iwc", False)

We should just leave this a boolean.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I keep it as boolean then I get a type violation as lint_args is supposed to be a dict of str -> str

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See

ctx: "PlanemoCliContext", paths: Iterable[str], lint_args: Dict[str, Union[str, List[str]]]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or I change it to : lint_args: Dict[str, Union[str, List[str], bool]] ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dict[str, Any] is probably enough, I'll push a commit to your branch.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, if not I can commit it.

planemo/workflow_lint.py Outdated Show resolved Hide resolved
planemo/workflow_lint.py Outdated Show resolved Hide resolved
planemo/workflow_lint.py Outdated Show resolved Hide resolved
Copy link
Member

@mvdbeek mvdbeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is excellent, thanks everyone!

@mvdbeek mvdbeek merged commit f47965e into galaxyproject:master Jul 4, 2024
13 of 14 checks passed
@lldelisle lldelisle deleted the lint_workflow branch September 24, 2024 07:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants