https://pantsbuild.org/ logo
#general
Title
# general
g

gentle-dentist-72404

07/20/2022, 9:09 PM
Hey folks! We are running into an issue attempting to switch from pytest-xdist to pants for our tests.
pytest-xdist
runs individual tests in parallel but pants seems to only run test files in parallel. We have some big files with a lot of tests, so pants is much worse performance-wise. Am I missing any configuration options, or is this just the way pants works?
b

bitter-ability-32190

07/20/2022, 9:11 PM
For now thats how pants works πŸ™‚ If there isn't already an issue feel free to make one with tons of info. Otherwise you might lightly suggest splitting those test files, unless you think engineers will lob objects and boo in your direction πŸ™‚
w

witty-crayon-22786

07/20/2022, 9:23 PM
this issue covers implementing something like that: https://github.com/pantsbuild/pants/issues/15026 … it’s definitely possible, but would require shipping that change as well as improving our process-internal parallelism
f

fresh-cat-90827

07/20/2022, 9:41 PM
I agree with Joshua -- I'd also suggest splitting large files into multiple ones. I find it to be very difficult to navigate around tests if there are more than a few hundred lines. It would also help if the unit tests are not stored in the same file(s) with integration tests so that the slower system tests are not causing the delay.
βž• 1
h

happy-kitchen-89482

07/21/2022, 2:27 AM
Hi @gentle-dentist-72404, your comments on https://github.com/pantsbuild/pants/issues/15026 would be helpful in understanding your use case and prioritizing the issue
a

ambitious-actor-36781

07/21/2022, 5:18 AM
Is there anything stopping someone from creating a
test-xdist
goal that collects all the sources for the selected targets and their dependencies and runs pytest on them w/ xdist installed?
you'd lose caching I guess. But you'd gain speed. And nothing stopping you from running the regular
test
goal against changed targets in dev, and your test-xdist goal in CICD
h

happy-kitchen-89482

07/21/2022, 5:54 AM
Nothing stops that per se, certainly nothing that implements it as a separate plugin, just questions about whether that's the right design, vs baking it into
test
and getting caching right
@gentle-dentist-72404 you should still be able to run with pytest-xdist under Pants, but then you may want to tweak the concurrency that Pants uses
5 Views