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

Better primer tests (faster, less duplication, more diverse) #5359

Closed
7 of 10 tasks
Pierre-Sassoulas opened this issue Nov 21, 2021 · 24 comments · Fixed by #8612
Closed
7 of 10 tasks

Better primer tests (faster, less duplication, more diverse) #5359

Pierre-Sassoulas opened this issue Nov 21, 2021 · 24 comments · Fixed by #8612
Labels
Documentation 📗 Enhancement ✨ Improvement to a component Maintenance Discussion or action around maintaining pylint or the dev workflow Needs PR This issue is accepted, sufficiently specified and now needs an implementation primer
Milestone

Comments

@Pierre-Sassoulas
Copy link
Member

Pierre-Sassoulas commented Nov 21, 2021

Current problem

Right now the primer tests take more than double the time of the next slower tests. Also the CI configuration is duplicated between primer for stdlib and primer for external tests. The choice of repository to check is also arbitrary.

Desired solution

Additional context

#5173

@Pierre-Sassoulas Pierre-Sassoulas added Enhancement ✨ Improvement to a component Maintenance Discussion or action around maintaining pylint or the dev workflow labels Nov 21, 2021
@cdce8p cdce8p added the primer label Nov 22, 2021
Pierre-Sassoulas added a commit that referenced this issue Nov 24, 2021
* Add changelog and warning about unstable API in testutil

* Add primer tests, (running pylint on external libs during tests)

In order to anticipate crash/fatal messages, false positives are harder
to anticipate. Follow-up will be #5359 and later on #5364 

Add '__tracebackhide__ = True' so the traceback is manageable

Co-authored-by: Daniël van Noord <13665637+DanielNoord@users.noreply.github.com>
@DanielNoord
Copy link
Collaborator

@Pierre-Sassoulas Just something I thought of:
I'm not sure if we get unlimited amount of CI minutes from Github, but if we need to be conservative with them we could consider not running the external primer on all three versions.

@Pierre-Sassoulas
Copy link
Member Author

We definitely need to cache everything we can too. (Setting the hash of the repository we lint would help).

@DanielNoord DanielNoord added this to the 2.13.x milestone Nov 25, 2021
@cdce8p
Copy link
Member

cdce8p commented Nov 27, 2021

I'm not sure if we get unlimited amount of CI minutes from Github

@DanielNoord AFAIK public repos are only limited in the number of concurrent job runners, not the actual time.

@cdce8p
Copy link
Member

cdce8p commented Nov 27, 2021

One suggestion for something I saw recently. If the primer tests are moved to a new workflow, you could also add concurrency control. I.e. it doesn't make sense to continue with primer tests if a new commit has been pushed in the meantime.
https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#concurrency

This is how Home Assistant does it: Home-Assistant -> ci.yaml, although it probably isn't necessary to cancel all other jobs as they are quite fast and even partial feedback could be useful.

@Pierre-Sassoulas
Copy link
Member Author

Huge first step was done in #5425 by @DanielNoord we still can do:

  • Fixing dependency to a specific commit to be able to cache repository
  • Caching of repository for primers
  • Remove duplication in primer jobs by using a job template

@DanielNoord DanielNoord modified the milestones: 2.13.x, 2.13.0 Dec 15, 2021
@Pierre-Sassoulas Pierre-Sassoulas modified the milestones: 2.13.0, 2.14.0 Jan 28, 2022
@Pierre-Sassoulas
Copy link
Member Author

Moving to 2.14 as we have quite a lot to do already for 2.13.

@DanielNoord
Copy link
Collaborator

DanielNoord commented May 28, 2022

With the work on the new primer most of the TODOs in this issue have become redundant.

I think there are a couple more things I would like to do before closing this:

  • Update documentation
  • Re-consider all projects on the list/move all projects to the new linter
  • One more review of all workflow files to check for improvements
  • Re-add home-assistant, see be07298

The last point is mainly because syntax highlighting for yaml (and especially other languages within yaml) is quite poor and I think we might have missed some stuff. I tend to forget to rename steps for example.

@jacobtylerwalls
Copy link
Member

Once again, terrific work @DanielNoord!

@DanielNoord
Copy link
Collaborator

For point 2, I'd like to get 2/3 namespace packages as well. Preferably one that uses and one that doesn't use pylint. I have no good candidates myself, but if anybody can think of one please mention them here!

@hmc-cs-mdrissi
Copy link
Contributor

google packages are a good one. especially google.cloud ones as they have two levels of namespace nesting which is uncommon. Both google is a namespace package and google.cloud is also namespace package.

@Pierre-Sassoulas
Copy link
Member Author

@cdce8p
Copy link
Member

cdce8p commented Jun 7, 2022

Thanks for all the work here @DanielNoord, much appreciated! It will make all our lives easier when working on a new feature or bug fix.

Some question since I didn't follow the discussion closely.

  1. Does the current implementation install project dependencies, too?
  2. Is useless-suppression enabled? I think it would nice to know if those change, e.g. when a PR fixes a bunch of false-positives.
  3. Why was Home Assistant removed / what is necessary to add it back? I saw some mention of performance issues. As a data point, my pylint run usually takes around 8-10min.
  4. Any reason the primer message doesn't use permalinks? They might not look that pretty, but at least they will continue to work if the files change. Example: Emit used-before-assignment for variables only defined under always false tests #6677 (comment) -> check the pytest links which all don't work anymore.

@DanielNoord
Copy link
Collaborator

  1. Does the current implementation install project dependencies, too?

No. This is something we should do, as we're running into issues with this with #6780. Should be fairly easy with some additional caching of environments.

  1. Is useless-suppression enabled? I think it would nice to know if those change, e.g. when a PR fixes a bunch of false-positives.

It should be! We only disable duplicate-code and cyclic-import and enable all other messages and extensions.

  1. Why was Home Assistant removed / what is necessary to add it back? I saw some mention of performance issues. As a data point, my pylint run usually takes around 8-10min.

The full run was taking more than 45 minutes with Home Assistant compared to the 24 minutes it takes now.
However, @jacobtylerwalls also theorised some of the slowdown could be due the size of the dictionary that stores all emitted messages and how we write that to file. Improving this process might also speed up the linting of Home Assistant.

  1. Any reason the primer message doesn't use permalinks? They might not look that pretty, but at least they will continue to work if the files change. Example: Emit used-before-assignment for variables only defined under always false tests #6677 (comment) -> check the pytest links which all don't work anymore.

Oh huh. I thought using main would make them permalinks. What is the correct structure for permalinks then? Commit tag instead of branch name?

@jacobtylerwalls
Copy link
Member

As a data point, my pylint run usually takes around 8-10min.

The new primer enables all extensions. There could be some molasses in there.

the size of the dictionary that stores all emitted messages and how we write that to file.

I doubt that's a big performance impact, but I'll still put together a little refactor; if anything, it would help with more intermediate feedback when using the tool locally.

@jacobtylerwalls
Copy link
Member

I just fired up the primer tool locally and encountered an infinite loop in astroid while linting pandas. I didn't dig in yet.

@cdce8p
Copy link
Member

cdce8p commented Jun 8, 2022

3. Is useless-suppression enabled? I think it would nice to know if those change, e.g. when a PR fixes a bunch of false-positives.

It should be! We only disable duplicate-code and cyclic-import and enable all other messages and extensions.

Not sure it's all that useful to enable all other messages and extensions. At least for Home Assistant, we carefully decided what to and what not. to enable. I would recommend to stick with that, even if we might miss some things then. The only overwrites which makes sense IMO are useless-suppression, and the ones you mentioned duplicated-code and cyclic-import.

7. Any reason the primer message doesn't use permalinks? They might not look that pretty, but at least they will continue to work if the files change. Example: Emit used-before-assignment for variables only defined under always false tests #6677 (comment) -> check the pytest links which all don't work anymore.

Oh huh. I thought using main would make them permalinks. What is the correct structure for permalinks then? Commit tag instead of branch name?

Yes. An example from pylint.

https://github.com/PyCQA/pylint/blob/main/pylint/__main__.py#L7
https://github.com/PyCQA/pylint/blob/e52f3f5bb17984256e6716aa8ca1fd950521105c/pylint/__main__.py#L7

@DanielNoord
Copy link
Collaborator

Not sure it's all that useful to enable all other messages and extensions. At least for Home Assistant, we carefully decided what to and what not. to enable. I would recommend to stick with that, even if we might miss some things then. The only overwrites which makes sense IMO are useless-suppression, and the ones you mentioned duplicated-code and cyclic-import.

I don't think specific disables and enables matter that much. The primer only shows changes between main and PR. So if main emits a warning that is disabled in a configuration file it will also show up in the PR output and thus cancel out. Only differences between main and PR will show up in the final comment.

So we can show that a warning that is disabled in configuration no longer shows up due to a PR fixing a false positive.

Yes. An example from pylint.

Ah, this should be fixed then!

@jacobtylerwalls
Copy link
Member

There are some frequently-disabled messages that are a little opinionated or lead to false positives. I think we still want primer results on those. So we can't just use the project's enable/disable list.

I just noticed the old primer run was also enabling all extensions, so that shouldn't be it. I'll add Home Assistant back to the old primer and we can see what the run time is.

@Pierre-Sassoulas
Copy link
Member Author

There is a very interesting list of possible project that was done for benchmarks.

@Pierre-Sassoulas Pierre-Sassoulas added Documentation 📗 Needs PR This issue is accepted, sufficiently specified and now needs an implementation labels Jul 6, 2022
@DanielNoord
Copy link
Collaborator

DanielNoord commented Aug 23, 2022

Let's close this at some point.

FINAL TODO FOR THIS ISSUE:

  • Update documentation about primer. What is it? Which projects are primed?
  • Do one final check for potential speed ups
  • Move last remaining projects to the new primer as well as home-assistant

@DanielNoord DanielNoord modified the milestones: 2.15.0, 2.16.0 Aug 23, 2022
@mbyrnepr2
Copy link
Member

mbyrnepr2 commented Oct 26, 2022

Sorry if this is not the right place but wanted to ask - could we add coverage to the primer suite? The author opened an issue in our tracker recently so I thought it would be a good one to include since its a popular tool & it is using Pylint.

@DanielNoord
Copy link
Collaborator

Makes sense! Do you want to open the PR?

@mbyrnepr2
Copy link
Member

Sure @DanielNoord. It'll force me to take a closer look at the logic. I'll aim for next couple of days

@Pierre-Sassoulas
Copy link
Member Author

Spoiler, but:

You need to modify this file, or this file.

mbyrnepr2 added a commit to mbyrnepr2/pylint that referenced this issue Oct 27, 2022
mbyrnepr2 added a commit that referenced this issue Oct 27, 2022
* Add the `coverage` package to the primer suite.

Refs #5359

* Update tests/primer/packages_to_prime.json

Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>

* Add a fragment.

* Remove unnecessary fragment.

Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
@Pierre-Sassoulas Pierre-Sassoulas modified the milestones: 2.16.0, 2.17.0 Jan 8, 2023
@Pierre-Sassoulas Pierre-Sassoulas modified the milestones: 2.17.0, 3.0.0 Mar 7, 2023
@Pierre-Sassoulas Pierre-Sassoulas modified the milestones: 3.0.0, 3.0.0a7 Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation 📗 Enhancement ✨ Improvement to a component Maintenance Discussion or action around maintaining pylint or the dev workflow Needs PR This issue is accepted, sufficiently specified and now needs an implementation primer
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants