hundreds-father-404
03/18/2020, 10:18 PMtargets()
entry point to register.py
like this:
def targets():
return [PythonBinary, PythonLibrary, PythonTests]
It leaves open the question of how do you register macros like objects
and context_aware_object_factories
. In a discussion with Stu, I was thinking something like this:
def macros():
return {"objects": [O1, O2], "context_aware_object_factories": [CAOF1]
My reasoning is that macros are by definition an “advanced” concept. I would love for plugin authors to be able to register Targets without having to know about macros.
Thoughts?hundreds-father-404
03/18/2020, 10:19 PMBuildFileAliases
enough-analyst-54434
03/18/2020, 10:22 PMhundreds-father-404
03/18/2020, 10:24 PMtargets()
for Targets.
It’s still open how to register macros. I would advocate macros()
with a dict, but we could do macros()
with a typed object like Macros(objects=[], context_aware_object_factories=[])
or have objects()
as an entrypoint, etc.enough-analyst-54434
03/18/2020, 10:26 PMhundreds-father-404
03/18/2020, 10:26 PMBuildFileAliases
unmodifiedenough-analyst-54434
03/18/2020, 10:26 PMenough-analyst-54434
03/18/2020, 10:26 PMhundreds-father-404
03/18/2020, 10:27 PMHmm, that’s confusing based on the words for an end user.How likely do we expect it to be that users write both V1 and V2 plugins? It’s confusing in a mixed codebase, indeed, but in a V2 only codebase you can ignore “build_file_aliases”
happy-kitchen-89482
03/18/2020, 10:28 PMenough-analyst-54434
03/18/2020, 10:28 PMenough-analyst-54434
03/18/2020, 10:28 PMenough-analyst-54434
03/18/2020, 10:28 PMhappy-kitchen-89482
03/18/2020, 10:29 PMenough-analyst-54434
03/18/2020, 10:30 PMbuild_file_aliases
I have in my register.py implies those are the aliases that show up in BUILD files. Sure we can have docs that say - hey, in v2 we'll add aliases from targets
too ... but as I said, confusing just based on the words in the register.py file.enough-analyst-54434
03/18/2020, 10:33 PMenough-analyst-54434
03/18/2020, 10:35 PMenough-analyst-54434
03/18/2020, 10:37 PMhundreds-father-404
03/18/2020, 10:39 PMGiven a clean room, I think having a registrsation function per type would be best for clarity sake.Agreed, this is the approach I took.
Given the non-cleanroom, not sure.My thoughts on this is that plugin authors are super-users. Your typical Pants user at an org like Foursquare is unlikely to write a plugin or poke around
register.py
, although it is very likely that a team or individual at the org will write some plugins. So, I’m not as concerned as I normally would be with the possibility for confusion because the audience is small and more familiar with Pants
I think it’s worth going with the approach that we’d develop in a clean room. V1 will be removed one day, whereas this endpoint will presumably exist for ever, so I’d rather that we do what is the cleanest approach, even if the migration path is more confusingenough-analyst-54434
03/18/2020, 10:40 PMhundreds-father-404
03/18/2020, 10:42 PMCan I register an old style “python_binary”: PythonBinary and a FieldsBasedPythonBinary with alias “python_binary” too? Is there a silent winner or a build configuration validation error?That hasn’t yet been worked out. FWIT, I think that we should eagerly fail when that happens, which is possible because
build_configuration
stores both entries.
One of my next sprints is providing a way to go from a V2 Target to V1 target. Meaning, in the case of both V2 and V1, we’ll want V2 to be the canonical symbol, and then it gets downcast to a V1 target. (If you aren’t using V2, you can keep your V1 target without changes)enough-analyst-54434
03/18/2020, 10:42 PMwitty-crayon-22786
03/18/2020, 11:03 PMwitty-crayon-22786
03/18/2020, 11:04 PMhundreds-father-404
03/18/2020, 11:06 PMthe other thing that Eric and I briefly discussed is that end users are more likely to create macros than they are to create targetsI still disagree with this. I asked @clean-wolf-14674 to run a quick ripgrep experiment and Foursquare is using
targets
11x more than objects
and context_aware_object_factories
combinedenough-analyst-54434
03/18/2020, 11:08 PMhundreds-father-404
03/18/2020, 11:09 PMa slightly confusing thing about having lots of registration functions is that it is unclear that they all end up as aliases in BUILD filesOnce
BuildFileAliases
is removed (because V1 is removed), we would only have the entry points: rules()
, targets()
, and macros()
.
No more build_file_aliases()
, global_subsystems()
, or goals()
targets()
and macros()
register symbols, rules()
does not.witty-crayon-22786
03/18/2020, 11:09 PMmacros
would have both objects
and $something_that_can_create_more_than_one_target
?witty-crayon-22786
03/18/2020, 11:10 PMcontext_aware_object_factories
... likely renamed for v2)hundreds-father-404
03/18/2020, 11:10 PMmacros()
actually looks like, yet. But, the idea is that it has all the things used that behave like a macrowitty-crayon-22786
03/18/2020, 11:11 PMwitty-crayon-22786
03/18/2020, 11:12 PMpython_requirement
, artifact, etc: https://github.com/pantsbuild/pants/blob/9259097a86a6ec7294f280a22d2b91053d1b9d31/src/python/pants/backend/python/register.py#L60-L82witty-crayon-22786
03/18/2020, 11:12 PMenough-analyst-54434
03/18/2020, 11:12 PMenough-analyst-54434
03/18/2020, 11:12 PMhundreds-father-404
03/18/2020, 11:12 PMThe other part of the old new target API was the build-file facing part that allowed inlining content for sharing which would eliminate the need for most objects and some macros. I haven’t followed along enough to know if that’s still in play.It presumably could be, but hasn’t received much attention. We are still using
Struct
fwitwitty-crayon-22786
03/18/2020, 11:13 PMregister.py
will look like "at the end", imo, let's do thatwitty-crayon-22786
03/18/2020, 11:14 PMhundreds-father-404
03/18/2020, 11:14 PMto the extent that we can dodge the question of what register.py will look like “at the end”, imo, let’s do thatWe could punt on it and call it
targets2
for now. I’d rather call it targets
, but even more I’d rather land this PR today so that I’m unblocked on the next PRs in this project. We could revisit later need bewitty-crayon-22786
03/18/2020, 11:14 PMcreate_python_tests
, which declares two targets: a python2 target and a python3 target (...and others for thrift and jdk11. the thrift case goes away based on the codegen API, i think. but tests are roots)hundreds-father-404
03/18/2020, 11:15 PMtargets2
acceptable? There’s precedent with backend_packages2
witty-crayon-22786
03/18/2020, 11:15 PMwitty-crayon-22786
03/18/2020, 11:15 PMhappy-kitchen-89482
03/19/2020, 12:14 AMtargets
?hundreds-father-404
03/19/2020, 12:15 AMtargets
is the way to go but just pushed a commit to call it targets2
because this is easy for us to change back and this decision isn’t very important to the rest of the projecthappy-kitchen-89482
03/19/2020, 2:13 AM