witty-crayon-22786
10/12/2021, 10:39 PMwitty-crayon-22786
10/12/2021, 10:40 PMSpecs
match “everything living in a directory” is for the actual path component to be front and center by continuing to use “file(system) addresses” when representing things that live on diskwitty-crayon-22786
10/12/2021, 10:41 PM:
and ::
would match an Address
based on its filesystem location (rather than where its metadata lives)witty-crayon-22786
10/12/2021, 10:42 PM#
syntax, and should not match for anything other than the location of the generatorhundreds-father-404
10/12/2021, 10:44 PMoperate on where the target 'is resident'/'lives'this is different typing for how to express that
witty-crayon-22786
10/12/2021, 10:45 PMAddress
(only) to decide whether something matches a Spec
witty-crayon-22786
10/12/2021, 10:45 PMwitty-crayon-22786
10/12/2021, 10:46 PMhundreds-father-404
10/12/2021, 10:48 PMsrc/go:mod#./mypkg
src/go:mod#./mypkg/util
We'd have
src/go/mypkg:../mod
src/go/mypkg/util:../../mod
We both agreed that the ../../mod
isn't great. So, you are wondering if it really makes sense to be generating targets for subdirs like Go and Terraform are doing. Whether we should always use 111. Right?witty-crayon-22786
10/12/2021, 10:48 PMwitty-crayon-22786
10/12/2021, 10:49 PMhundreds-father-404
10/12/2021, 10:51 PMwitty-crayon-22786
10/12/2021, 10:51 PM:
)witty-crayon-22786
10/12/2021, 10:52 PMwitty-crayon-22786
10/12/2021, 10:53 PMhundreds-father-404
10/12/2021, 10:53 PMwitty-crayon-22786
10/12/2021, 10:53 PMwitty-crayon-22786
10/12/2021, 10:54 PMhundreds-father-404
10/12/2021, 10:54 PMand the lack of locality makes it hard to grok where metadata lives when going to edit it.In Go, you edit the sole BUILD file you have in your project, where the
go.mod
is located. Which is idiomatic fwict *to Go developers, that's already where you'd go to change metadatawitty-crayon-22786
10/12/2021, 10:55 PMwitty-crayon-22786
10/12/2021, 10:56 PMwitty-crayon-22786
10/12/2021, 10:57 PMimport
statements aren’t at the root of the repository, because they are locally relevantwitty-crayon-22786
10/12/2021, 10:58 PMhundreds-father-404
10/12/2021, 10:59 PMhappy-kitchen-89482
10/12/2021, 11:33 PMwitty-crayon-22786
10/12/2021, 11:33 PMhappy-kitchen-89482
10/12/2021, 11:33 PMhappy-kitchen-89482
10/12/2021, 11:34 PMhappy-kitchen-89482
10/12/2021, 11:34 PMwitty-crayon-22786
10/12/2021, 11:34 PMhundreds-father-404
10/12/2021, 11:36 PMoverrides={
"./subdir": {"tags": ["overridden"]},
("./subdir", "./subdir/util"): {"test_timeout": 120},
}
witty-crayon-22786
10/12/2021, 11:37 PMI do buy it getting unwieldy when it’s file-based, with hundreds of files in the subdirs. I don’t buy that when you only have a handful - dozen directoriessure… but that’s precisely the case where it doesn’t really matter that much to have BUILD files. https://github.com/toolchainlabs/remote-api-tools/commit/c1fe3e7de819425bf67d33598fbb0837a7b7a416 deleted 13 total lines
hundreds-father-404
10/12/2021, 11:40 PMwitty-crayon-22786
10/12/2021, 11:40 PM# BUILD
go_mod(
overrides={
"./pkg/stats": dict(tags=["overridden"]),
}
)
and
# pkg/stats/BUILD
go_package(
tags=["overridden"],
)
witty-crayon-22786
10/12/2021, 11:40 PMwitty-crayon-22786
10/12/2021, 11:42 PMwitty-crayon-22786
10/12/2021, 11:42 PM#
(again, except where something does not exist on disk at all, such as with 3rdparty)witty-crayon-22786
10/12/2021, 11:44 PMGoing from 10 BUILD files to 3 BUILD files is the more important benefit than removing 13 lines.i’m not sure that it’s relevant at all given
tailor
. we’re already massively beyond bazel in terms of boilerplate reduction.hundreds-father-404
10/12/2021, 11:44 PMsrc/go/mypkg:../../mod
src/go/mypkg/util:../../mod
vs
src/go:mod#./mypkg
src/go:mod#./mypkg/util
Beauty is indeed in the eye of the beholder, but I personally find the latter easier to work withwitty-crayon-22786
10/12/2021, 11:45 PMhundreds-father-404
10/12/2021, 11:46 PMi’m not sure that it’s relevant at all given tailor. we’re already massively beyond bazel in terms of boilerplate reduction.We are, which is awesome! Bazel isn't our competition though, complacency / custom Bash scripts are. We should continue trying to minimize boilerplate when possible
happy-kitchen-89482
10/12/2021, 11:46 PMwitty-crayon-22786
10/12/2021, 11:46 PMhappy-kitchen-89482
10/12/2021, 11:46 PMhappy-kitchen-89482
10/12/2021, 11:47 PMwitty-crayon-22786
10/12/2021, 11:47 PMhappy-kitchen-89482
10/12/2021, 11:47 PMhappy-kitchen-89482
10/12/2021, 11:47 PMwitty-crayon-22786
10/12/2021, 11:47 PMwitty-crayon-22786
10/12/2021, 11:47 PMhappy-kitchen-89482
10/12/2021, 11:47 PMhappy-kitchen-89482
10/12/2021, 11:47 PMwitty-crayon-22786
10/12/2021, 11:48 PMhappy-kitchen-89482
10/12/2021, 11:48 PMwitty-crayon-22786
10/12/2021, 11:48 PMhappy-kitchen-89482
10/12/2021, 11:48 PMhappy-kitchen-89482
10/12/2021, 11:48 PMhappy-kitchen-89482
10/12/2021, 11:49 PMhappy-kitchen-89482
10/12/2021, 11:49 PMwitty-crayon-22786
10/12/2021, 11:49 PMhappy-kitchen-89482
10/12/2021, 11:50 PMhundreds-father-404
10/12/2021, 11:50 PMwitty-crayon-22786
10/12/2021, 11:50 PMhappy-kitchen-89482
10/12/2021, 11:50 PMhappy-kitchen-89482
10/12/2021, 11:51 PMwitty-crayon-22786
10/12/2021, 11:51 PMhappy-kitchen-89482
10/12/2021, 11:51 PMhappy-kitchen-89482
10/12/2021, 11:52 PMwitty-crayon-22786
10/12/2021, 11:52 PMhundreds-father-404
10/12/2021, 11:52 PMoverrides
. Our users are engineers: if things are getting overwhelming, they can refactor to have metadata live closer to what it modifieshappy-kitchen-89482
10/12/2021, 11:52 PMhappy-kitchen-89482
10/12/2021, 11:53 PMwitty-crayon-22786
10/12/2021, 11:53 PMhappy-kitchen-89482
10/12/2021, 11:53 PMhappy-kitchen-89482
10/12/2021, 11:53 PMhappy-kitchen-89482
10/12/2021, 11:53 PMhappy-kitchen-89482
10/12/2021, 11:53 PMhappy-kitchen-89482
10/12/2021, 11:54 PMhappy-kitchen-89482
10/12/2021, 11:54 PMwitty-crayon-22786
10/12/2021, 11:55 PMwitty-crayon-22786
10/12/2021, 11:59 PMhappy-kitchen-89482
10/12/2021, 11:59 PMhappy-kitchen-89482
10/13/2021, 12:00 AMwitty-crayon-22786
10/13/2021, 12:00 AMhundreds-father-404
10/13/2021, 12:00 AMsrc/py/f.py
vs src/py#f.py
happy-kitchen-89482
10/13/2021, 12:00 AMwitty-crayon-22786
10/13/2021, 12:00 AM#
if there are multiple sets of merged metadata?witty-crayon-22786
10/13/2021, 12:01 AMwitty-crayon-22786
10/13/2021, 12:02 AMhundreds-father-404
10/13/2021, 12:03 AMsure, but where do you put the # if there are multiple sets of merged metadata?Not sure, probably on the original target definition which declared the intent of what the file represents. If the
.py
file is python_source
vs. resource
happy-kitchen-89482
10/13/2021, 12:15 AMfast-nail-55400
10/13/2021, 12:16 AMhappy-kitchen-89482
10/13/2021, 12:16 AMfast-nail-55400
10/13/2021, 12:17 AMhappy-kitchen-89482
10/13/2021, 12:17 AMfast-nail-55400
10/13/2021, 12:17 AMhappy-kitchen-89482
10/13/2021, 12:17 AMhappy-kitchen-89482
10/13/2021, 12:18 AMhappy-kitchen-89482
10/13/2021, 12:19 AMhappy-kitchen-89482
10/13/2021, 12:19 AMfast-nail-55400
10/13/2021, 12:20 AMhappy-kitchen-89482
10/13/2021, 12:20 AMfast-nail-55400
10/13/2021, 12:21 AMfast-nail-55400
10/13/2021, 12:22 AMhundreds-father-404
10/13/2021, 2:19 PMAddress
somehow to disambiguate the residence dir, right?
For file/dir address syntax, we must consult the filesystem to determine if foo
is a file without an extension vs. a dir. (What AddressInput -> Address
does)
For generated address syntax, we must consult Target.residence_dir
because the generated_name
is arbitraryhundreds-father-404
10/13/2021, 5:30 PMResidentTargets
solely given a directory path will look extremely similar regardless of "dir address" syntax vs Target.residence_dir
. Either way, we need to find AscendantAddresses
with target gen enabled. Then we either inspect the address to determine residence vs look at Target.residence_dir
The focus for 2.8 is not to figure out generated target syntax vs file syntax. Nor to figure out 111 for Go. Important conversations, but not blocking 2.8 as Go is still experimental
So I'm thinking we can punt on dir addresses. Use Target.residence_dir for now, and we can replace it with dir addresses in 2.9
Wdyt @witty-crayon-22786witty-crayon-22786
10/13/2021, 6:13 PMFor generated address syntax, we must consultmy point is that we should not do this, because if a Target corresponds to a file/dir on disk, it should use a file(system) address. and then only the path component of an Address is relevant tobecause theTarget.residence_dir
is arbitrarygenerated_name
Specs
matching. but yes, we still need to go from AddressInput
to Address
witty-crayon-22786
10/13/2021, 6:16 PMSo I’m thinking we can punt on dir addresses. Use Target.residence_dir for now, and we can replace it with dir addresses in 2.9i think that moving go to using filesystem addresses, and then applying these semantics to filesystem addresses is the path forward. fixing this for filesystem addresses fixes the issue for Python and for Java, which generate filesystem addresses corresponding to files. i think that the right way to fix this for Go is to have it use filesystem addresses for dirs, rather than adding a facility specific to
#
addresses, which should not correspond to things in the filesystem (imo)hundreds-father-404
10/13/2021, 6:27 PMGet(ResidentTargets, ResidentTargetsRequest("some/dir"))
.
Because a target generator can live in any ancestor directory, I believe we must look at all ascendant targets as candidates. Does that part make sense?witty-crayon-22786
10/13/2021, 6:34 PMSpecs
expansion you would need to match AscendantAddresses
or some equivalenthundreds-father-404
10/13/2021, 6:41 PMResidentTargetsRequests("some/dir") -> ResidentTargets
rule whether we determine residence from the Address
vs. Target.residence_dir
. The more interesting part of the algorithm was AscendentAddresses
So, to give us more time to discuss file addresses vs. generated addresses & 111, I'm suggesting we go with ResidentTarget.residence_dir
for now, as an implementation detail that can change in Pants 2.9+. It means that the new specs semantics will work out-of-the-box with Go, Python, etc without having to make any changes to Address
- no need to block the release on figuring out 111 and address syntaxwitty-crayon-22786
10/13/2021, 6:42 PMwitty-crayon-22786
10/13/2021, 6:43 PMhundreds-father-404
10/13/2021, 6:44 PMwitty-crayon-22786
10/13/2021, 6:46 PMwitty-crayon-22786
10/13/2021, 6:47 PMwitty-crayon-22786
10/13/2021, 6:51 PMhundreds-father-404
10/13/2021, 6:53 PMGet(ResidentTargets, ResidentTargetsRequest("some/dir"))
via Target.residence_dir
witty-crayon-22786
10/13/2021, 6:54 PMSpecs
.witty-crayon-22786
10/13/2021, 6:55 PMSpecs
for languages already using filesystem addresseswitty-crayon-22786
10/13/2021, 6:56 PMSpecs
are fixed for our other languages.hundreds-father-404
10/13/2021, 6:58 PMTarget.residence_dir
, there is a bunch of other work involved in implementing https://docs.google.com/document/d/1WWQM-X6kHoSCKwItqf61NiKFWNSlpnTC5QNu3ul9RDk/edit#heading=h.z4f4lstj51db. Like the rule for ResidentTargetsRequest -> ResidentTargets
, which is mostly the same regardless of which scheme we use to determine residence
I already did the work for Target.residence_dir
, so now any work I do is on stuff that should be agnostic to what we decide with "dir" addresseshundreds-father-404
10/13/2021, 6:59 PMdir#./
. With Terraform, it's dir#.
witty-crayon-22786
10/13/2021, 7:17 PMSpecs
for file addresses is uncontroversial, right?hundreds-father-404
10/13/2021, 7:19 PMGet(ResidentTargets, ResidentTargetsRequest("some/dir")
I'm unblocked by doing that via Target.residence_dir
, and then you can put up a PR to swap that part of the implementation with dir specs. It's only a few lines that will change in that rulewitty-crayon-22786
10/13/2021, 7:20 PMResidentTargets
with AscendantAddresses
and a filter on the address path?hundreds-father-404
10/13/2021, 7:24 PMgo_binary(main=)
field inference rule for examplewitty-crayon-22786
10/13/2021, 7:25 PMTarget.residence_dir
.witty-crayon-22786
10/13/2021, 7:26 PMhundreds-father-404
10/13/2021, 7:28 PM(ResidentTargets, ResidentTargetsRequest)
as prework, which also refactors the go_binary
rule
• Use that to "fix" address specs. (Note that our internal types need not == what users type. It may be useful to keep `SiblingAddresses`/`DescendentAddresses` w/ current semantics purely for plugin authors. Unclear!)
• Add directory specs as shorthand for dir:
Changing how the ResidentTargets
rule's filter works (address vs. residence_dir
) is encapsulated from everything else, and you're welcome to put up your proposed change there whenever it's readywitty-crayon-22786
10/13/2021, 7:33 PMSibling/Descendent
match addresses generated in parents is easier than that: should be able to do it with only changes to https://github.com/pantsbuild/pants/blob/e2afe17853bdccc891327be90b362134425b9c76/src/python/pants/base/specs.py#L64-L92witty-crayon-22786
10/13/2021, 7:33 PMhundreds-father-404
10/13/2021, 7:43 PMdir
, rather than resident? Again, plugin author needs can diverge from what we expose to end users.
I don't think there's any use case for that?witty-crayon-22786
10/13/2021, 7:48 PMhundreds-father-404
10/13/2021, 7:51 PMis there any utility for plugin authors to be able to resolve only targets defined in dir, rather than resident?I'm talking about changing the behavior of
SiblingAddresses
and DescendentAddresses
when used in rules so that they now include generated targets that are "resident" in those dirs
It seems likely to me that that is a great default for plugins too. If we find there is some niche case where you only want targets explicitly defined in the folder, we could add a new typewitty-crayon-22786
10/13/2021, 7:52 PMfast-nail-55400
10/13/2021, 8:02 PMwitty-crayon-22786
10/13/2021, 9:00 PMhundreds-father-404
10/13/2021, 9:01 PMSourcesSnapshot
, how we let you operate on files without owners with count-loc
and validate
. Adding proposal to the design doc + have been doing a refactor that will make it easier to muck around with Specs codehappy-kitchen-89482
10/13/2021, 9:44 PM