hundreds-father-404
10/14/2021, 5:11 PM./pants test src/py
, do you expect it to only run tests in src/py
? š§µhundreds-father-404
10/14/2021, 5:12 PMpython_tests
in a BUILD file, that is actually generating a python_test
target for each file in the sources
field. Pants runs on python_test
targets, not python_tests
, which only exist for boilerplate reduction
We allow you to refer to that python_tests
target as an alias for all of its generated targets: ./pants test src/py:tests
will result in running all the relevant python_test
targets, rather than erroring that the target is python_tests
so not runnable. Same with the dependencies
field, we'll replace the python_tests
target with its generated python_test
targetswitty-crayon-22786
10/14/2021, 5:12 PMhundreds-father-404
10/14/2021, 5:14 PM./pants test src/py
how to handle matching a python_tests
target defined in src/py
. Does the user expect this alias mechanism to apply there too? If so, that means ./pants test src/py
might actually run over dozens of directories! Depends if the python_tests
target is generating into a bunch of subdirectorieshundreds-father-404
10/14/2021, 5:15 PM./pants peek src/py
, we want to show both the python_tests
target and any python_test
targets that are generated into that directory
But for "build" goals like test
, how do we handle src/py
matching src/py:tests
with sources=["**/*_test.py"]
?witty-crayon-22786
10/14/2021, 5:19 PMhundreds-father-404
10/14/2021, 5:21 PM./pants test src/py:tests
(when it's a build goal), and with dependencies
My hesitation is specifically whether it's useful vs. confusing to expand aliases with a directory specwitty-crayon-22786
10/14/2021, 5:22 PM./pants peek src/py
will show the alias, ./pants test src/py
should run it.hundreds-father-404
10/14/2021, 5:23 PMPants should do what the user expects, even if that means behavior is slightly different between goals (project introspection vs. build goals).
hundreds-father-404
10/14/2021, 5:24 PMUsers mostly think in terms of files and directories. BUILD files / targets are usually only a means to an end.
curved-television-6568
10/14/2021, 5:27 PMDoes the user expect this alias mechanism to apply there too?If I run
./pants test src/py
and have a python_tests(sources=["**/*_test.py"])
in there, Iād expect to run the tests for all those sources.hundreds-father-404
10/14/2021, 5:28 PM./pants test src/py:tests
or ./pants test src/py::
to say "all the tests")curved-television-6568
10/14/2021, 5:28 PMcurved-television-6568
10/14/2021, 5:29 PMhundreds-father-404
10/14/2021, 5:29 PMcurved-television-6568
10/14/2021, 5:30 PMwitty-crayon-22786
10/14/2021, 5:31 PM*_binary
in a directory and no files, it should match. and then not matching for target types that own files would be inconsistenthundreds-father-404
10/14/2021, 5:33 PMa bit of confusion to allow either paths OR spec addresses on the command lineā¦Part of https://docs.google.com/document/d/1WWQM-X6kHoSCKwItqf61NiKFWNSlpnTC5QNu3ul9RDk/edit is that address specs vs. file specs is no longer as relevant as it used to be I at first proposed
dir::
(addresses) vs dir/...
(file semantics), then we generally agreed it's confusing for the user to have to know the nuances of dir:
vs dir
, and dir::
vs dir/...
. 95% of Pants users will likely never read the majority of ours, particularly users who aren't on our Slack and only use Pants because their org uses it. Not worth the subtlyhundreds-father-404
10/14/2021, 5:35 PManother important example isĀ *_binary: if i have only aĀ *_binaryĀ in a directoryAgreed it should match. They live in that directory
witty-crayon-22786
10/14/2021, 5:42 PMtarget
alias with a short name that referred to something deeper in the directory structure, so that you could do ./pants run shortname
, ./pants test shortname
, etc. for that to work, itās necessary to expand the alias⦠but because we didnāt have a native facility for that, it got hacked into a bunch of goalscurved-television-6568
10/14/2021, 5:43 PM./pants test //src/py/utils # interpret as target address
./pants test src/py/utils # interpret as path spec
./pants test src/py/utils:tests # still path spec, if there is not a dir "utils:tests" it is an error
./pants test --targets src/py/utils:test # all specs treated as target address specs due to flag
Iām not really up to speed on all the nuances to be able to reason if this will improve the situation considerably or not.. but thought worth exploring (or discarding)⦠š (Iāll be afk now, time to put some kids to bed..)witty-crayon-22786
10/14/2021, 5:56 PM*
wildcard matching and ::
matching exist: the latter is intended to match targets, and the former to match files, regardless of whether there are associated targets. but whether they should be merged (and whether there should be a filtering flag like the one you mentioned) is an open question.witty-crayon-22786
10/14/2021, 5:58 PMdir
expanding to `dir:dir`: if we stop matching the target in that case, itās a more significant behavior change, and seemingly closer to a regression (maybe in the eye of the beholder, but.).hundreds-father-404
10/14/2021, 6:01 PMif weĀ stopĀ matching the target in that case, itās a more significant behavior changeChanging the semantics of
dir
being dir:dir
in particular can be feature gated to not break the deprecation policy as badly, demonstrated by https://github.com/pantsbuild/pants/pull/13219/commits/1c93cafff6d51e291596a9041a33b51966292c8f
Maybe confusing that I used ./pants test src/py
in my example rather than src/py:
. I was using src/py
because that's what users will be typing once we finish completely deprecating it beign shorthand for src/py:py
witty-crayon-22786
10/14/2021, 6:08 PMhundreds-father-404
10/14/2021, 6:13 PMDirLiteralSpec
into AddressLiteralSpec
. I reverted all breaking changes from ithappy-kitchen-89482
10/14/2021, 6:31 PM/pants test src/py
to the user means /pants test src/py/test_*.py
(or whatever their test file naming conventions are)happy-kitchen-89482
10/14/2021, 6:32 PMhappy-kitchen-89482
10/14/2021, 6:32 PMwitty-crayon-22786
10/14/2021, 6:33 PMhappy-kitchen-89482
10/14/2021, 6:33 PMhappy-kitchen-89482
10/14/2021, 6:33 PMhappy-kitchen-89482
10/14/2021, 6:33 PMhappy-kitchen-89482
10/14/2021, 6:34 PMwitty-crayon-22786
10/14/2021, 6:34 PM./pants run src/py
should run a binary target, even if it has no files, but ./pants test src/py
should ignore a test target?hundreds-father-404
10/14/2021, 6:35 PMhappy-kitchen-89482
10/14/2021, 6:35 PMwitty-crayon-22786
10/14/2021, 6:35 PMhappy-kitchen-89482
10/14/2021, 6:35 PMhappy-kitchen-89482
10/14/2021, 6:36 PM./pants run src/py
should not run itcurved-television-6568
10/14/2021, 6:36 PMhappy-kitchen-89482
10/14/2021, 6:36 PMsrc/py
means "just the dir, not its subdirs", and I think we all agree on that at this point?witty-crayon-22786
10/14/2021, 6:36 PMhappy-kitchen-89482
10/14/2021, 6:36 PMhappy-kitchen-89482
10/14/2021, 6:36 PM./pants run src/py/main.py
happy-kitchen-89482
10/14/2021, 6:36 PMhundreds-father-404
10/14/2021, 6:36 PMgo_binary
is file-less. But it does reside in the directory where it is defined, so ./pants run src/go
will run any go_binary
targets defined therehappy-kitchen-89482
10/14/2021, 6:37 PM./pants run src/py:tgt
if you want to address the target itselfwitty-crayon-22786
10/14/2021, 6:37 PMhappy-kitchen-89482
10/14/2021, 6:37 PMhappy-kitchen-89482
10/14/2021, 6:37 PMhappy-kitchen-89482
10/14/2021, 6:37 PMwitty-crayon-22786
10/14/2021, 6:38 PMhappy-kitchen-89482
10/14/2021, 6:38 PMhundreds-father-404
10/14/2021, 6:38 PMwhy would we not match aliases?For a user who doesn't really care about targets and BUILD files or even Pants, it's confusing that
./pants test src/py
might run src/py/foo
, src/py/foo/bar
, *happy-kitchen-89482
10/14/2021, 6:39 PMwitty-crayon-22786
10/14/2021, 6:39 PM./pants peek src/py
and ./pants list src/py
shouldnāt render those targets either, youāre saying?witty-crayon-22786
10/14/2021, 6:40 PMhappy-kitchen-89482
10/14/2021, 6:42 PMsrc/py:
and src/py::
match all targets in the dir/subdirs), but addresses without colons always match files/dirs, and if you want to do so recursively you use -r
?happy-kitchen-89482
10/14/2021, 6:43 PM-r/--recursive
is reasonably common in other tools)happy-kitchen-89482
10/14/2021, 6:43 PM::
and the hypothesized ...
hundreds-father-404
10/14/2021, 6:44 PM-r
more than dir/...
happy-kitchen-89482
10/14/2021, 6:44 PM./pants -r peek src/py
and ./pants peek src/py::
are different thingshappy-kitchen-89482
10/14/2021, 6:44 PMhappy-kitchen-89482
10/14/2021, 6:44 PMhundreds-father-404
10/14/2021, 6:45 PM./pants tailor
to be recursive. We'd "fix" it to not recurse by default, and you use ./pants -r tailor dir
for recursionhappy-kitchen-89482
10/14/2021, 6:45 PM/pants peek src/py
doesn't render those targets, but /pants peek src/py:
doeshundreds-father-404
10/14/2021, 6:45 PM-r
is that you can't have some dirs be recursive and others be non-recursive, whereas test dir another_dir::
would handle that. But probably finewitty-crayon-22786
10/14/2021, 6:45 PM-r
doesnāt let you control recursion on a spec by spec basishappy-kitchen-89482
10/14/2021, 6:46 PMhappy-kitchen-89482
10/14/2021, 6:46 PMhappy-kitchen-89482
10/14/2021, 6:46 PMrm
hundreds-father-404
10/14/2021, 6:47 PMdir/... another-dir/...
witty-crayon-22786
10/14/2021, 6:48 PM:
and ::
donāt match generated targets, and defer the rest until after 2.8.x. the actual bug that exists right now is that ./pants peek ::
and ./pants list ::
donāt show you all targets, and thatās really the only thing that imo MUST be fixed for 2.8.xwitty-crayon-22786
10/14/2021, 6:49 PMhundreds-father-404
10/14/2021, 6:49 PMSourcesSnapshot
(count-loc
and validate
). If you use :
and ::
, that means only operate on sources owned by targets, like today
If you use dir
or -r dir
, that means all sources regardless of targetswitty-crayon-22786
10/14/2021, 6:53 PM-r
might be a replacement for *
syntax, but i feel like weāve gone totally off the rails to be discussing a third globbing/recursion semantics for what started as a bugfix so that Asher can get a graph of the whole repo with ./pants peek ::
hundreds-father-404
10/14/2021, 6:54 PMwitty-crayon-22786
10/14/2021, 6:55 PMwitty-crayon-22786
10/14/2021, 6:55 PM::
and :
donāt match file/generated addresses: letās fix that.witty-crayon-22786
10/14/2021, 7:06 PM./pants test src/go/pkg
does what you expect, addresses are short without adding `#`s, and itās just :
and ::
that have a glaring bug (across all languages).witty-crayon-22786
10/14/2021, 7:20 PM:
and ::
donāt match file/generated targets
3. defer complete overhauls of **
vs -r
vs ::
until we can do them without the false pretext (imo) of fixing a bugwitty-crayon-22786
10/14/2021, 7:21 PMhappy-kitchen-89482
10/14/2021, 8:07 PMhappy-kitchen-89482
10/14/2021, 8:07 PMhappy-kitchen-89482
10/14/2021, 8:08 PMhundreds-father-404
10/14/2021, 8:14 PMdir
to be shorthand for dir:
, and punting on it meaning something else. I think it's important we get directory specs right. (And adding dir specs would prompt a bunch of other changes I'd feel compelled we'd need to do)
I'm putting up now the "bug fix" that gets :
and ::
behaving how Stu believes they should. I believe it's a big step forward, even if I'd like to improve it even more (what this thread is about)
I don't agree with reverting the Go changes. It's experimental, so we're not committing to things. Thanks to ./pants tailor
, it should be easy for Pants 2.9 to stop doing the target generation and instruct alpha users that they need to now use ./pants tailor
. The docs won't mention generated address syntax, they'll only talk about using dir:
and dir::
to run, which this pending bug fix mostly gets righthundreds-father-404
10/14/2021, 8:17 PMoverrides
for python_sources
et al (only a few tests away)
⢠figuring out python_tests
generating conftest.py
as python_test
, which it isn't. Might cause major issues with lockfiles in the future. https://github.com/pantsbuild/pants/issues/13238
⢠(stretch goal) ./pants mend
hundreds-father-404
10/14/2021, 10:58 PMdir:
and dir::
, that they should continue to expand target generators even with build goals like test
But I also still believe ./pants test dir
should only test dir/*
and not expand target generators. (I also think ./pants package dir
should package all file-less targets like go_binary
, which is where this gets tricky. dir
is not strictly shorthand for 'dir/*'
, it would include file-less targets)
And what I realize now is I disagree with our earlier decision that dir
should == dir:
. I think it's useful to have `dir`/`-r dir` and also `dir:`/`dir::`
I agree with punting on directory specs in Pants 2.8. Let's land https://github.com/pantsbuild/pants/pull/13263 (when I finish it), and call it a day for now with specswitty-crayon-22786
10/15/2021, 1:14 AMBut IĀ alsoĀ still believeĀyes, that is where things get tricky. because it is inconsistent for some goals to match targets and others not to.Ā should only testĀ./pants test dir
Ā and not expand target generators. (I alsoĀ thinkĀdir/*
Ā should package all file-less targets likeĀ./pants package dir
, which is where this gets tricky.Āgo_binary
Ā is not strictly shorthand forĀdir
, it would include file-less targets)'dir/*'
witty-crayon-22786
10/15/2021, 1:14 AMhundreds-father-404
10/22/2021, 8:16 PMdir/...
, even if we decide for dir
and dir:
to have different semantics around target generators
To recap, I'm thinking that dir:
should replace a target generator with all its generated targets, whereas dir
should not and only run on targets resident to that directory.
If we're recursing into subdirs, I don't think that really matters whether we replace target generators or not. We'll already end up globbing over every target generated by it because those targets must be in subdirectories. The end result should be the same
That's a good thing! We only need dir
, dir:
, dir::
, dir/f.py
, and dir:tgt
. (I suspect we can under-document dir:
in favor of dir
also)witty-crayon-22786
10/22/2021, 9:23 PMTo recap, Iām thinking thatĀi donāt think itās a question of āreplacingā so much as āexpandingā⦠the caller can decide whether things end up āreplacedā (confusingly, by requesting eitherĀ should replace a target generator with all its generated targets, whereasĀdir:
Ā should not and only run on targets resident to that directory.dir
Target
or UnexpandedTarget
). but Specs
calculation should either expand an alias or not, without replacing it.witty-crayon-22786
10/22/2021, 9:23 PMdir/ā¦
witty-crayon-22786
10/22/2021, 9:24 PMwitty-crayon-22786
10/22/2021, 9:25 PMUnexpandedTargets
ticket:
await Get(UnexpandedTargets, Specs(SiblingAddresses(..))): new: includes BOTH the generator and the generated, as in your example
await Get(Targets, Specs(SiblingAddresses(..)): as now, includes only the generated targets, since the aliases will have been expanded and deduped with the generated
await Get(UnexpandedTargets, Specs(SingleAddress(..)): as now, only the alias (as in your example)