I have a python package whose sole purpose is to p...
# general
p
I have a python package whose sole purpose is to provide resources for tests in other packages. There is some helper python in that package that loads the resources for things that depend on it. An interesting side effect is that in those other packages, pants only needs to know about the python imports to get access to those resources. But, within the tests package (named
st2tests
), can I tell pants that python file X depends on resources Y so that pants knows when to invalidate due to resources changes? ie I can use
python_library(dependencies=[... list of resources targets ...])
within
st2tests
. But then all of the python files in that directory will depend on all of the resources. How do I tell pants that only one file depends on one set of resources targets and a different file depends on a different set of resources?
e
You can't today without a target per test file. Then each target can get a manual dependencies list like you sketch above that is customized. To automate this, you'd want a dedicated resource mananger file per commonly used group of resource files. Then dep inference would just figure this all out. If the goal though is to have just 1 resource manager and have it fetch resources by name, The only way Pants could help you is if the names were all string literals the user of the resource manager sent and you added a fancy dep inference plugin that parsed these and added appropriate deps. This last bit, although maybe doable with certain constraints on how the resource manager API was written / used - would be a lot of work / slightly bonkers.
p
Resource manager... Yeah, I'm just going to include large swaths of that
st2tests
package and deal with overzealous invalidation.