The target is intended to provide metadata for fil...
# development
h
The target is intended to provide metadata for files, so it sits next to them, but you can have
dependencies=[...]
that criss-cross the repo, there are no restrictions
t
That makes sense. The last missing piece is the syntax.
Copy code
# src/tests/BUILD
python_sources(dependencies=[":test_csv_files"])

files(name="test_csv_files", sources=["**/*.csv"])
This correctly detects my csv file sources
Copy code
pants dependencies src/tests
-> 
src/tests/test_data/csv/shape_example.csv:../../test_data_files
I just can't seem to figure out the correct syntax to include in the BUILD file located within my test module directory.
Copy code
# src/tests/dir/subdir/BUILD

python_tests(
    name="tests",
    dependencies=[":test_csv_files"]
)
:test_csv_files
is out of scope, but I am not sure how to reference the
python_sources
and/or
files
field located within
src/tests/BUILD
. I think I am just lacking a bit of understanding on how paths are resolved between
BUILD
files.
h
A dependency address is relative to the repo root:
path/to/dir:target_name
You can omit
:target_name
if it’s the same as the dir name
And just
:target_name
means “the target of this name in this directory”
Also, you can depend on individual files instead of targets:
path/to/file.txt
So in your case
dependencies=["src/tests:test_csv_files"]
BTW you could consider putting that
files()
target in
src/tests/test_data/csv/BUILD
, but that is not required
t
Incredible explanation, thank you. This all looks to be working on my end, both in my overly-simple example as well as the more complex, real-life case.
BTW you could consider putting that
files()
target in
src/tests/test_data/csv/BUILD
, but that is not required
I will be trying to only reference the files that I need per
BUILD
file. Most of the heavy handed glob work will be just to increase quality of life. Nonetheless, I will keep this in mind! Thank you again, this was tremendous help. P.S. I integrated pants into more than half of our monorepo. CI time is down from ~50 minutes to ~30 minutes. The final steps will hopefully bring us down to ~15 minutes. Pants is a great tool and its value is tremendous.
🎉 1
h
Out of curiosity. which Pants features are the CI time savings coming from?
t
“test” and “lint” are primarily what we have integrated. Remote test caching certainly saves the most time.