freezing-vegetable-92896
11/10/2021, 12:15 AM::
that I can use in the sources
field of a files
target? I'm trying to package up an entire directory for use on spark. I know the better long term solution is to have specific targets for a given job, but I'd like to have something that just over-estimates to get something good enough without explicitly listing all the targets.
We currently have a hack using a files(sources=[""**/*.py""])
but that does not nice things to target discovery, so I'm hoping there is a better way to do this?freezing-vegetable-92896
11/10/2021, 12:16 AMfiles(sources=[""**/*.py""])
but that does not nice things to target discovery, so I'm hoping there is a better way to do this?hundreds-father-404
11/10/2021, 12:20 AMsources=["**/*.py"]
is how you would do it
Perhaps you want to use resources
instead though? How are you trying to load these files?freezing-vegetable-92896
11/10/2021, 12:24 AMfreezing-vegetable-92896
11/10/2021, 12:25 AMfreezing-vegetable-92896
11/10/2021, 12:25 AMhundreds-father-404
11/10/2021, 12:26 AMI was previously getting problems where it seemed like it was causing everything to depend on everythingGenerally, dependency inference doesn't happen for
files
and resources
targets. You'd have to manually add to dependencies
field of what you want, or for an archive
target to its files
field
I’m just trying to get a zip file with the files in the same locations as they are in our repo which is how spark expects to find themGot it, so then it sounds like you're using
archive
and the files
target? Coolwitty-crayon-22786
11/10/2021, 12:30 AMwitty-crayon-22786
11/10/2021, 12:31 AMfiles
will not strip source roots, so if you wanted them to actually be loadable as python code by spark, you’d probably want to use resources
witty-crayon-22786
11/10/2021, 12:35 AMdependencies
list somewhere for only the “reflective access” portion of your code.
if you have an explicit import
statement, you shouldn’t need something in dependencies
… but if it is loaded via a string, you might need either an explicit dependency in the dependencies
list (which is the largest single dependencies
list in Pants own codebase, used for our plugins), or alternatively, if you know that a type is loaded via a string, you can enable [python-infer].string_importsfreezing-vegetable-92896
11/10/2021, 12:36 AMfiles(
name="files",
sources=["**/*.py"]
)
target.
The code we need here happens to not use source roots in a problematic way, so that constructs something we can use in sparkfreezing-vegetable-92896
11/10/2021, 12:37 AMhundreds-father-404
11/10/2021, 12:38 AMfreezing-vegetable-92896
11/10/2021, 12:41 AMdependencie.zip
for some new spark jobs we wanted to run because I was doing leading work towards fully adopting pants, then my co-worker made an extension with the **/*.py
glob. In the commit am working on today to actually check in all the BUILD
files and start us down the course of actually adopting pants proper I thought the recursive glob was a problem, but we don’t want to loose the functionality it enables until we get further in and have the better solutions in placefreezing-vegetable-92896
11/10/2021, 12:42 AMbusy-vase-39202
11/10/2021, 12:49 AM