https://pantsbuild.org/ logo
a

ambitious-xylophone-5772

10/21/2022, 3:37 PM
Hi all, have some questions on the list of targets that are generated by the pants build. I have a BUILD file for my pytests as such:
Copy code
python_sources()

python_tests(
    name="tests0",
    sources=["test_a.py"],
)

python_tests(
    name="tests1",
    sources=["test_b.py"],
)

python_tests(
    name="tests2",
    sources=["test_c.py"],
)
and
./pants list
returns the following:
Copy code
repo/test:tests0
repo/test:tests1
repo/test:tests2
repo/test/test_a.py:test0
repo/test/test_b.py:test1
repo/test/test_c.py:test2
âś… 1
đź‘€ 1
Why are there two targets for my tests?
w

witty-crayon-22786

10/21/2022, 4:17 PM
python_tests
is a “target generator”, which generates a target per file: the generator itself has a name, and each generated
python_test
target does too. see https://www.pantsbuild.org/docs/targets#target-generation
đź‘€ 1
why are you creating three test targets in this case? it should be fine to create one
python_tests
target (which
tailor
will do by default)
(this is a big difference from pants v1: pants 2 operates at the file level)
a

ambitious-xylophone-5772

10/21/2022, 4:19 PM
Oh interesting, I assumed I needed to create a separate target to run things in parallel
w

witty-crayon-22786

10/21/2022, 4:22 PM
no need.
a

ambitious-xylophone-5772

10/21/2022, 6:08 PM
This was super helpful. Thanks @witty-crayon-22786
đź‘Ť 1
w

witty-crayon-22786

10/21/2022, 6:16 PM
sure thing. yea, if
tailor
doesn’t get you a good experience out of the box, an issue would be appreciated… our goal is that folks mostly don’t need to hand-edit
BUILD
files, except to add metadata
đź‘Ť 1
a

ambitious-xylophone-5772

10/21/2022, 6:45 PM
@witty-crayon-22786 the only thing I had to add was a dependency for datasets that were used in my pytest.
tailor
didn’t seem to pick that up.
w

witty-crayon-22786

10/21/2022, 6:55 PM
ah, yea: “asset inference” (for
file
and
resource
targets) is disabled by default, but you can enable it: https://www.pantsbuild.org/docs/reference-python-infer#assets
đź‘€ 1
6 Views