-
-
Notifications
You must be signed in to change notification settings - Fork 644
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
Integrate shell-completion with Pants #16315
Comments
Any thoughts on the outstanding questions? I'm not really sure in which direction I can take this to integrate with Pants. From the Slack conversations, With all the API discussions we've had the past few weeks and my general dislike of API bloat, I'd rather this not be a new goal, but somehow be shoe-horned into something else. I can take a crack at something, but I don't yet know what that "thing" is. Alternatively (and I'm not super into this either) I could intermezzo this with an |
I'd love to play with this, but it wasn't working for me, as we discussed on Slack or on the ticket, I forget which... Has anything been fixed there? Once I get to using it regularly I can form opinions about how to proceed... |
Yep, just pushed two fixes: #16442 Works on Mac and Debian Bullseye for me now, no warnings/complaints. |
I think we should redesign If you don't want to be blocked, you could call it
This would be #12014 |
Re: #16397 @benjyw Thoughts? I don't want to start creating new experimentally-namespaced goals, while discussing in another ticket whether we should have them or not. Here's my entirely selfish perspective of my DX workflow over the last couple weeks. From mainline Pants, I've generated the most thorough This isn't the best, as it doesn't react to my The biggest reason for completions for me was related to introspection commands, which I'm trying to solve by creating that super trivial VSCode extension, so introspection tools are always visible. This is all to say that I'm totally fine not creating any custom goals until The completions might be much more useful for new/casual Pants users, who don't have all the commands memorized. For that case, we could even do something similar to what I'm doing - which is to generate a single, massive completions file, host that on the website and let users know that it might not all work, depending on their pants.toml. Ugly workaround? Sure - but better than touching the public API in my mind. |
I want to play with this for a couple of days (now that it should work, after your recent changes), and hopefully that will give me ideas. |
Just so this isn't fully lost to Slack history (between Stu and I):
I'll take a crack at this, and see if I can get anything created by Pants for arbitrary repos, and then we can work on naming. |
…tins folder # Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
Thanks a lot @sureshjoshi! |
@stuhood No problem, but we still need an endgame here wrt my Slack thread (https://pantsbuild.slack.com/archives/C0D7TNJHL/p1664221191673119).
According to Eric, 3 relates to #12014 |
This is an important question, yea. Looking around at prior art would be good here, as I don't know how tools do this in general. But do note that one annoying issue in this case is that each repo on your system might be using a different version of pants. Any bit of automation that attempted to write out a global config would need to be version aware (and perhaps have a shim at the top level to decide which copy of the completions to use?) Or we could recommend that people use
I don't think that it needs to be: because this would be a built-in goal, it would not be running as
If it ends up auto-updated, then I don't think that it would need a goal name: rather, an option name? But perhaps you'd still need a goal for the initial install of completions. It's also possible though that the installation script could bootstrap what is needed there. |
For, let's say, "static" tooling - it often comes down at installation time. For something a bit more dynamic,
My original idea in the long long ago times was that it would be part of the installation script somehow, which also might give us some ability to hook into changes to the backend packages. Felt both like a good and bad idea to be in that script, if we could enable/disable it to the user's preference. Whether it's a good idea or not, I was thinking that you could source the repo's completions after your first
This is something I didn't think too much about - I'd never seen it done (at least, I don't think I have). If we could dynamically re-direct to the current directory's |
Yea... this would be a bit like a custom implementation of |
Oh yeah, I guess so. I don't currently use Do we have any idea on the ratios of users to number of Pants repos a given user works on? For me, it's about 10:1 repos per SJ, but I would think that in companies focusing on monorepos, it might be less. So, if there is a default single-repo path, and then "here is a tool/way/mechanism for a multi-repo case"? For the single-repo case, I think just printing to console, and then letting the user pipe wherever they so choose could make sense. Hmm, though, this kinda falls over to backend-package changes... Blah. |
Ok; so... coming in here like a buffoon and probably asking questions you've talked about elsewhere... Wouldn't going for fully dynamic completion be somewhat easier (from a user viewpoint, not necessarily tech)? :-) _pants () {
pants="${COMP_WORDS[0]}";
local words=("${COMP_WORDS[@]}")
local completions=$($pants --complete --word $COMP_CWARD --point $COMP_POINT "${words[@]}")
COMPREPLY=( $(compgen -W "$completions" -- "$word") )
}
complete -F _pants pants Works for |
Thanks for the feedback, and yeah, we briefly talked about this yesterday on the slack channel. In short, it's not a bad idea to do that on On my machine (6-core i5 Mac Mini), I think it ended up somewhere between 0.5-2 seconds per call - with the daemon running, and that's without any real substantial changes to the code base. If calling In lieu of fully dynamic, as you suggested, putting something in the pants script would be the intermezzo - but I'm just not sure how that would look, with config as well. |
Finishing shipping #7369 will unblock improving latency, because it will ease shipping the native-client that is already implemented. It will also touch the That will still only be for the "warm |
Figured as much, but wanted to check. Mine doesn't take that long (<0.5s) which IMO is fine, but 2s would be a bit annoying if it's every tab.
My primary use-case isn't goals, it's targets1. Finding the right target in a directory, finding out which ones exist, etc. That's going to change much more often. I had a bit of a check in how Buck and Bazel do it; and they seem to both have options for either querying via the tool or dumb grepping for targets. Both seem to depend on some known lists of commands and flags as well; likely shipped with the binary. But since both goals and targets (and which goals affect which target) can change (plus depending on location), that is a bit more complex for Pants. Spitballing here; could the list be maintained by the daemon? So instead of Footnotes
|
That's great information! This first version of the completions only cover the goals/options/subsystems/etc - targets are a step two, as other than filesystem targets, those internal to BUILD files are going to need to be more clever (which is another good use case for dynamically created completions!) |
I've got a new implementation coming down the pipe (hopefully PR this weekend). No more statically generated completions. The new implementation calls into Pants itself to perform the completion, so we should be able to go repo-to-repo with the same bash completion script. |
Hey @sureshjoshi, thank you for the pr! I can see it is still in draft, what's the status? |
That's the proper one I think - I apparently forgot that it was never merged, but I think it was the testing that was falling over. When I'm back working on Pants in a week or two, I'm going to land this and a few other open items I have. Specifically, I think I was waiting on closing another VSCode plugin related ticket first, before I came back to this - but the scope of that one increased, and then I ran out of time while landing some work projects |
Okay, I just recalled what went down here. Making notes for when I come back to this in about 2 weeks: The overall completion functionality was roughly complete, but I was running into testing issues. The tests themselves were meh, but as I was trying to clean them up and fix them, I ran into a bunch of dreaded Coursier networking/Haskell architecture bugs which effectively kill the workflow on my machine. Anyways:
|
@benjyw @kaos e.g. I wanted to store the bash and zsh completions as separate files, and then just print them out using the CLI, in the event anyone wanted to be able to download them out-of-band of Pants itself (e.g. automation scripts). Not sure where to put them though |
The closest analogy I have are the various per-backend/per-tool config or lock files, which are inline. |
Would these be per-backend? How would the backends I opt in to affect the completions? I think it's fine to create a |
@benjyw They'd be single-instance files. For instance, this is something like the zsh completion:
Right now, they just live next to the completions.py, but ... yeah, doesn't feel great. |
I don't have any issue with them living next to the python source that use them. Consider the alternative of having the shell source verbatim inline in the python source file.. we've just made them easier to work with by placing them in their own source file. |
Since #16200 has landed, integration with Pants should be the next focus (plus dedicated ZSH completions wouldn't hurt). The merged PR was strictly a Python script to generate bash completions.
The outstanding questions are:
pants.toml
is changed?The text was updated successfully, but these errors were encountered: