-
-
Notifications
You must be signed in to change notification settings - Fork 637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
./pants --query for unifying target selection mechanisms to improve performance #7346
Comments
I think making I think one thing that could also be true is that the command-line target specs (and their dependencies) would always bound the size of the graph used in |
Preliminary research suggests that pants/src/python/pants/init/target_roots_calculator.py Lines 111 to 116 in 9873b14
|
Another thought -- shlexing strings may avoid parsing now, but we'll want to support keyword arguments pretty soon. Using the python |
From
|
This is very exciting, glad to see it moving forwards! :D
I find that a lot harder to read (particularly as other arguments may be interspersed between query arguments) than:
The place I think this falls down is that not all operators are single argument. There are a bunch of binary-or-more-argument operators that I think are pretty hard to model nicely in this kind of pipeline. As an example, how would you write:
necessitating a kind of funky This may seem like a contrived example, but in my experience it isn't; I've written this kind of thing before quite a bit, and found it super useful...
FWIW the bazel way of phrasing this is The buck way of phrasing this is We should work out whether in pants we view targets as depending on files (as bazel does), or we consider the relationship to be something different (as buck does). We could have This was actually specifically the reason we went with a separate argument for
One answer buck found for this was to effectively allow templating into queries; see the "Executing multiple queries at once" section of https://buckbuild.com/command/query.html |
I hadn't considered this! I was mostly skimming over the bazel query language spec.
I was thinking that
After implementing some of it in #7356, I'm less concerned that we need to use any specific sort of syntax. However, I really do not appreciate nested function calls, and I would strongly prefer that there is a function composition operator. This makes it more likely people will write
|
While we're on syntax, if it's not going to be |
Now that we have I'm reminded of the UNIX philosophy of doing one thing (and doing it well). |
Generally agreed. We need to document more recipes though: #14969 |
Starting with #6501 (comment), it seems like it would be both useful and fun to merge our target selection options (currently:
--changed-parent
,--owner-of
, and thefilter
,paths?
, anddependees
goals) into a composable interface. One existing example (ish) of this is the bazel query language, although that tries to output graphs, and has its own command-line goal.Rather than making it into its own goal, it seems like making an option
--query
which wraps our existing target selection logic, and then allowing goals such aslist
,compile
, ortest
to use the selected targets the same way they currently use e.g.--changed-parent
seems like a great way to incorporate our current mechanisms, while making the use of multiple selection mechanisms significantly more performant by allowing query composition instead of invoking multiple pants processes, as well as by use of the v2 engine.Another specific and possibly important point from #6501 (comment) is that while composing expressions in the bazel query language is done by nesting function calls, we can consider what should be a strict extension to that language by incorporating the
|
operator à lajq
. Other extensions to that language would involve incorporating our existing selection mechanisms such as--owner-of
and--changed-parent
into functions in the pants--query
language.For now, the "output" would be whatever you get from
./pants --query <...> list
, which is lines of text, each specifying a target address. This seems like a very good interface to start with, because the result of--query
can then be immediately used by pants tasks without invoking a separate process (which should at least reduce our internal CI time). There may be other outputs we might want, but it seems we can avoid needing a complex output format in favor of adding more of our existing target selection mechanisms to the pants--query
language.TODO
--owner-of
and--changed-parent
to be the first supported (single) expressions in a--query
global option.--query
functions which can also be used in@rules
(less important), as per./pants dependees
should be deprecated in favor of a "root selection" option #6501 (comment).--owner-of
,--changed-parent
, all of the arguments tofilter
, and whatever else comes to mind into--query
functions.--query
expression to allow chaining function calls with|
likejq
.--query
.The text was updated successfully, but these errors were encountered: