-
Notifications
You must be signed in to change notification settings - Fork 14
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
Caching does not work with xdist #37
Comments
The problem seems to be with this line: https://github.com/stephrdev/pytest-isort/blob/master/pytest_isort/__init__.py#L77 It appears that I am not yet sure how to solve this issue properly. Perhaps we can send the mtimes back to the controller and save the values there, but I'm not sure how to do that. |
We can probably do something similar to They're basically using |
Hey @GergelyKalmar, thank you for your detail investigation on the issue. I think you are right. We would need to re-implement the caching similar to the MyPy plugin. Sadly, I won't be able to tackle that before January. If you feel like you want to do it, you have my full support on reviewing and merging asap. |
Hi @stephrdev, no worries! I've ended up building a plugin from scratch because I figured I can create an abstraction above all the plugins which rely on running something against a given source file (such as isort, pylint, pycodestyle or pydocstyle), so this way I've solved the issue with basically all plugins I use at the same time. Unfortunately that code is part of a larger private plugin suite, however, the core of the solution is to use the I think the pytest-mypy plugin works differently – you will notice that it does not skip files but runs mypy against all of them. This is possible because mypy maintains its own cache so subsequent runs are usually quite fast without skipping. |
I tried a solution to this issue and it is merged here already. #48 It is not perfect because you still has a minor race condition, but is a lot better than before. |
It seems that when running
pytest-isort
withpytest-xdist
the cache does not get populated (.pytest_cache/.../v/isort/mtimes
is empty). This means that test are re-run on all files when using distributed test execution, which is not very optimal.Interestingly the same issue appears with
pytest-pylint
too (see carsongee/pytest-pylint#161, it is actually much worse there because all tests are executed on all workers due to the way the linting is done), I suppose because both plugins are based onpytest-flake8
(I haven't tested it but I think that plugin has the same issue too).At the same time
pytest-mypy
works fine because it relies on the built-in cache ofmypy
. I'm not yet sure why does the cache not get populated withxdist
, but it would be awesome if we could figure it out.The text was updated successfully, but these errors were encountered: