flat-zoo-31952
03/03/2022, 10:11 PMhundreds-father-404
03/03/2022, 10:16 PMtarget
as a "bag of dependencies": https://www.pantsbuild.org/v2.10/docs/reference-target
Honestly, address syntax has gotten so complex and is going to get even more complex with the upcoming parametrize feature that I'd be really hesitant to add even more variants on address syntax. We believe the complexity is a necessary evil, but still https://www.pantsbuild.org/v2.10/docs/targets#target-generationflat-zoo-31952
03/03/2022, 10:17 PMhundreds-father-404
03/03/2022, 10:19 PMflat-zoo-31952
03/03/2022, 10:25 PMoverrides
hundreds-father-404
03/03/2022, 10:28 PMAs long as there's a rule for getting files from globs...Yeah, although here you probably want the addresses of those file globs right? The plugin hook for dependency inference expects you to return
Addresses
You can use Get(Owners, OwnersRequest)
ah... or I could just use tags and overridesHow so?
I mean, I suppose I could write a plugin to do thisHow frequent will this problem be? Are you adding a new testing framework it sounds like, that might be replicated in multiple places? If so, a plugin could be a really good idea. You spend some time to make things much more intuitive and automatic for your org's users
flat-zoo-31952
03/03/2022, 10:32 PMpython_sources(
name="aiven",
sources=["aiven/**/*.py"],
overrides={
"aiven/admin/*_cli.py": {
"tags": ["components/admin-commands"],
}
}
)
components/admin-commands/BUILD
can be a bare target()
that I can make the tests depend onhundreds-father-404
03/03/2022, 10:34 PMtags
into it pulling in dependencies? tags
isn't wired up to dependencies
unless you add a pluginflat-zoo-31952
03/03/2022, 10:35 PMfilter
+ peek
hundreds-father-404
03/03/2022, 10:36 PM./pants dependencies
will be lying and --changed-since
too
For quick and dirty, I'd recommend using target()
as a bag of dependencies
For robust and hopefully not too slow, I'd recommend the plugin. Lmk if you're interested in this route, I think it'd only be about 20 lines of codeflat-zoo-31952
03/03/2022, 10:36 PM./pants --changed-since=main list | xargs ./pants filter --tag-regex="^components" | ./pants peek | jq uniqe(.tag)
hundreds-father-404
03/03/2022, 10:38 PMLmk if you're interested in this routeI can try to find some examples you can crib if you want. when redesigning
example-plugin
repo, we should definitely have examples of this plugin hook
Might also be helpful to show off a pants plugin to coworkersflat-zoo-31952
03/03/2022, 10:38 PMglob_dependencies
or something like that, and then I could define targets that use that like a barebones component
targethundreds-father-404
03/03/2022, 10:47 PMsources
field. See https://github.com/pantsbuild/pants/blob/fe41887641970a34dc7de19d5c49442978ec83e1/src/python/pants/backend/codegen/thrift/apache/python/rules.py#L66-L94 for an example rule. Use inject_for = Dependencies
rather than something more specific, which means this will get used for every single target
3. In your rule, also use the WrappedTarget
line. Then tgt.get(DependenciesGlobField)
. Now use that to call await Get(Owners, OwnersRequest())
4. Register the UnionRule
dependencies
even more complex
Still an open question if it's desirable to add, but cool!flat-zoo-31952
03/03/2022, 10:54 PMhundreds-father-404
03/03/2022, 11:18 PMparametrize
feature meant to make multiple resolves (lockfiles) ergonomic. For example:
python_source(
name="utils"
source="utils.py",
resolve=parametrize("python-default", "data-science"),
)
That is syntactic sugar for creating two targets: dir:utils&resolve=python-default
and dir:utils&resolve=data-science
. It's important that you don't depend on both because Pants won't like that you're attempting to use two resolves in the same closure. A glob of dir/utils.py
would match both targets as they're both the owners.
Now, you could make your plugin hook fancy and proactively filter out targets from Owners
that it doesn't like. Totally feasible. Only holdup is that it means we would have a harder time generalizing this to pantsbuild/pants as a field on every single target
cc @witty-crayon-22786flat-zoo-31952
03/04/2022, 1:50 AM