-
Notifications
You must be signed in to change notification settings - Fork 171
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
No pylint error messages when multiple pylint jobs used #320
Comments
Adding the |
You can also try the |
Tried |
Ok, I'll try reproducing it after putting out the fires caused by the pylint 2.3 release :-) |
Thanks! |
IIRC, we still don't support |
@chocoelho How hard would it be to add Prospector 1.1.6.2 takes just over a minute to run on my codebase in a Python 3.6 venv. Running pylint (2.1.1, astroid 2.0.4) from this same venv on its own takes over 40s. So most of prospector's time must be spent waiting for pylint. With |
I would also like to see jobs support for Pylint under Prospector. I took a look at the code and the reason for Pylint to fail is the following:
Now when the worker process starts, pylint.config.OptionsManagerMixIn.load_configuration_from_config gets called with configuration dict containing, among others, indent-strict-tabs defined by IndentChecker. As PyLint does not know anything about Prospector's IndentChecker, the _all_options member of OptionsManagerMixin does not contain indent-strict-tabs and indexing results in KeyError With a quick look, Prospector seems to do all kind of initialization for for PyLinter in prospector.tools.pylint.init.PylintTool which would need to be done inside PyLint's worker process. This means that getting PyLint's jobs argument to work with Prospector looks quite hard. @chocoelho Did you have a design how to implement jobs support? To me it looks like it would be easier to implement jobs support for PyLint inside Prospector on Prospector's side. |
@jannero as this was a while ago, so I just had the time to only check how Pylint implemented it's jobs settings and play a bit with the current checker implementation on prospector side, I didn't have the time to go further so this kinda got lost in my workspace when I switched machines. I'd really appreciate to review and test a PR for that if you're up to 😃 The configuration inside |
Ok, I had the time to do a proof of concept and it seems to work. I used one of my projects as test and with single core implementation (the original) it took around 110 seconds to run PyLint through Prospector. With the changes in janneronkko@6236ad9 it took about 38 seconds The change is not finished and therefore I did not create PR for this; I wanted to ask if you would be willing to pull this kind of implementation? @chocoelho PyLint also does parallel checks file by file so in that sense this implementation is pretty similar. Some things that should be done before the change is ready
Note about self._args |
I can also check if PyLint could be fixed (easily) so you would not need to use multiprocessing on Prospector's side. That would be a better solution but most likely it requires bigger changes than the one already made. |
@jannero that's awesome! I'm slowly coming back again as my time allows, but I'd more than happy to test it out. I'll probably do it over the weekend and feel free to open a draft PR for the time being, while the feature is developed. |
I created PR for refactoring: pylint-dev/pylint#3015 If you like, I can continue working on top of that commit until linting parallel works also under Prosector or you could just merge that refactoring now and I'll submit more changes as separate PR. |
I closed the original PR and created new one containing the refactoring in the previous PR (3015) and parallel linting refactoring that allow Prospector to run PyLint parallel. Should there be a change in Prospector to run PyLint parallel by default? |
Better to keep it separate. Makes it easier to review. As to the default, keep the current behavior as default, parallels as optional. @carlio feel like this should be part of 1.2.0? |
Ah, noticed now that this involves @PyCQA/pylint-dev as well, once they dealt with it we can see it going into prospector :) hopefully with few changes. |
If the change gets merged into PyLint, there is no required changes to Prospector. It is enough to set jobs option in profile YAML:
So I just asked if I (or someone else) should create PR for changing the default behaviour of PyLint in Prospector to use parallel linting by default. |
Also, in my opinion, there should maybe be an special value auto stating that automatic amount of parallel linters were used. PyLint implements this with a magic value of 0 but that does not work for Prospector out of the box as the magic value is handled in PyLint's Run class that is not used by Prospector. |
Now the PyLint PR 3016 (pylint-dev/pylint#3016) contains changes that also works with spawn method, i.e. parallel linting should work also on Windows. I have tested the change with two of my own projects and the results look to be fine though I have not (yet) checked messages one by one. |
Please, do it. I want to check the changes, and maybe we can change the way it is now no our side to make things easier.
That'd be put into prospector configuration file as an option? |
I will do a PR for these once the changes to PyLint are merged. The auto value would go to Prospector profile file under pylint/options like you suspected:
Or you could just specify the exact number:
Prospector would check if the value is auto and change that to a number (most likely the number of cores on current machine). |
The PyLint PR (pylint-dev/pylint#3016) was merged and the fix is going to be included in PyLint 2.5.0 I already have the configuration changes to support jobs=auto but while testing PyLint from master I got a lot of duplicate messages (I updated the used astroid version to one required by PyLint). Is this expected? How are you testing new PyLint versions? |
There are the required changes to support auto option for PyLint in https://github.com/jannero/prospector/commits/parallel-pylint Add support for auto option: janneronkko@c815091 |
Thanks @jannero, I was trying to keep an eye in that PR from time to time. As I'm back from vacations now, I should be taking a look at it in the next few days. The duplicated messages is not an expected behavior, I'll be taking care of that. |
@jannero I created a branch here and cherry-picked your commits, thanks for that. Meanwhile, I'm adding more tests for the pylint tool in order to improve reliability on how prospector integrates it. |
I looked at the commits on pylint-jobs. Pylint supports passing |
Hmm, turns out the way prospector uses pylint does not allow 0. Traceback (most recent call last):
File "/Users/rik24d/.local/share/virtualenvs/i-make-reviews-sygjxbSg/bin/prospector", line 8, in <module>
sys.exit(main())
File "/Users/rik24d/.local/share/virtualenvs/i-make-reviews-sygjxbSg/lib/python3.7/site-packages/prospector/run.py", line 173, in main
prospector.execute()
File "/Users/rik24d/.local/share/virtualenvs/i-make-reviews-sygjxbSg/lib/python3.7/site-packages/prospector/run.py", line 66, in execute
messages += tool.run(found_files)
File "/Users/rik24d/.local/share/virtualenvs/i-make-reviews-sygjxbSg/lib/python3.7/site-packages/prospector/tools/pylint/__init__.py", line 267, in run
self._linter.check(self._args)
File "/Users/rik24d/.local/share/virtualenvs/i-make-reviews-sygjxbSg/lib/python3.7/site-packages/pylint/lint/pylinter.py", line 878, in check
files_or_modules,
File "/Users/rik24d/.local/share/virtualenvs/i-make-reviews-sygjxbSg/lib/python3.7/site-packages/pylint/lint/check_parallel.py", line 91, in check_parallel
with multiprocessing.Pool(jobs, initializer=initializer, initargs=[linter]) as pool:
File "/Users/rik24d/.pyenv/versions/3.7.7/lib/python3.7/multiprocessing/context.py", line 119, in Pool
context=self.get_context())
File "/Users/rik24d/.pyenv/versions/3.7.7/lib/python3.7/multiprocessing/pool.py", line 169, in __init__
raise ValueError("Number of processes must be at least 1") |
In terms of API, I think we should use |
Closing this issue as this is now fixed in the next release: 1.3.0 |
I see similar behavior with 1.3.1, but only some errors get lost. I can reproduce on this repository on current master
21d20
< prospector/tools/pylint/indent_checker.py -- I have not found any pattern as to what errors get dropped |
I can add
jobs: 8
to thepylint
section of my.prospector.yaml
and it runs much faster but no pylint errors appear in prospector's outputThe text was updated successfully, but these errors were encountered: