adamant-coat-28831
09/24/2024, 4:49 PMxdist
. It does not appear possible to set xdist_concurrency="auto"
in a pytest target, eg:
python_tests(
name="my_tests",
sources=["test_*.py"],
resolve="main",
xdist_concurrency="auto",
)
However if you remove xdist_concurrency
then you can run this successfully:
pants test test_this: -- -n auto
I wanted to confirm whether or not setting xdist_concurrency="auto"
was possible or not.happy-kitchen-89482
09/25/2024, 7:14 PMint
type, so yeah, auto
will not be accepted. However it also looks like “If pytest-xdist is enabled and this field is unset, Pants will attempt to derive the concurrency for test sources by counting the number of tests in each file.”happy-kitchen-89482
09/25/2024, 7:15 PMhappy-kitchen-89482
09/25/2024, 7:18 PMadamant-coat-28831
09/25/2024, 7:20 PMtarget
, the parallelization is invoked.
I managed to work around this by assigning nproc
to an environmental variable PANTS_XDIST_CONCURRENCY
and and then using that in the BUILD file:
xdist_concurrency=int(env("PANTS_XDIST_CONCURRENCY", 20)),
happy-kitchen-89482
09/25/2024, 8:23 PM[pytest].xdist_enabled = True
?adamant-coat-28831
09/25/2024, 8:30 PM