cylc-flow icon indicating copy to clipboard operation
cylc-flow copied to clipboard

cylc lint - site/workflow specific rules?

Open ColemanTom opened this issue 2 years ago • 4 comments

Problem

A site or workflow itself may have specific lint requirements that are very specific and not really suitable for the standard set of rules. Is there a way to add your own as plugins (e.g. via entry_points or similar)?

Proposed Solution

Allow site specific rules be added and used via entry_points or similar.

ColemanTom avatar Dec 06 '23 04:12 ColemanTom

Sounds reasonable to load rulesets via entry points.

oliver-sanders avatar Dec 08 '23 13:12 oliver-sanders

Would it be sane (and easier to implement?) to allow regex based rules to be defined in the pyproject TOML file?

@ColemanTom - What sort of rules do you want to implement?

My thought would be:

[cylc-lint]
rulesets.P.name = "My Custom Rulez" 
rulesets.P.letter = "P"      # The letter for your rule-set
rulesets.P.1.rule = "(.*)"   # A regex
rulesets.P.1.description = "What the problem is"

Equally, I don't see why we can't allow entry points - but why make it more complex than necessary?

wxtim avatar Dec 08 '23 13:12 wxtim

Entry points are pretty easy to implement, they allow the provision of lint functions which more closely matches the implementation and would allow cylc lint rulesets to be developed and shared as packages whereas pyproject.toml extensions would be workflow specific with no capability for sharing.

oliver-sanders avatar Dec 08 '23 13:12 oliver-sanders

@ColemanTom - What sort of rules do you want to implement?

Honestly, I'm not 100% certain at this point as I've not kept up to date with what is inside cylc lint, and perhaps it would be more logical for local things to be their own tool, distinct from cylc itself. But, I do think it is a reasonable feature to have available. Similar to flake8 which allows extensive plugins to be used

Equally, I don't see why we can't allow entry points - but why make it more complex than necessary?

I think entry points give a lot more flexibility. A regex pattern would apply to everything, but perhaps a rule a site has may be something like if rose opt conf files are there for installation, make sure no environment variables are referenced - so a regex but only only specific files. Also, entry points are used in other linters that allow plugins, for example flake8 uses entry points, see flake8-bugbear for example.

ColemanTom avatar Dec 10 '23 22:12 ColemanTom

Ok, entry points seem reasonable.

I've opened a new issue for entry-point support in cylc line, closing this discussion.

https://github.com/cylc/cylc-flow/issues/6028

oliver-sanders avatar Mar 19 '24 17:03 oliver-sanders