-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Can not manipulate select statement in macros #8419
Comments
I'm glad you found the workaround of just using a direct This general request has been discussed a lot, particularly with the Starlark designers. In principle everyone supports it. But no one's yet figured out a clean design. I think it'd have to be its own dedicated mini-project to make this happen (i.e. go through a design review vs. just spinning off a PR when someone has a few spare cycles). The core problem is that there are fundamental limits to how deeply macros can explore So the question is how far to turn that knob. A simple iteration like you describe seems reasonable since it doesn't imply macros have to know anything about which
And how can we prevent I have no doubt reasonable answers can come out of this. But it needs to be designed. So FYI about why I think we're not going to get a solution to this tomorrow. Paging @brandjon who I've discussed this with on and off for some time. |
Also @serynth - we've talked about having a better list of worthwhile but not-currently-prioritized projects. The label I just created for this issue is a simple attempt to nudge that idea forward (although I'm sure we'll want to do more). |
I know I had a whole host of opinions last time select() in macros came up, and I've forgotten them all now. Off-hand, I'm inclined to favor an approach of "expose the structure of select" (opening it up to compatibility requirements, but how often would we break that?) and provide utilities in skylib to do abstract operations over them, like map and union. |
To be clear, I'm happy to support anyone who wants to try designing an answer to this (design review, code review, code help, etc.) Starting from @brandjon 's suggestions would be a good start. |
Just ran into this, too, trying to make cross-platform cc macros that can call into Java on Android. In my case, there's enough Android specialization already that I'll just weave a workaround into that, but very interested in a solution if one comes about. (subscribing and +1 :) |
Can we just make the underlying dictionary items passed to
We don't expect selects to be excessively large, so I don't have efficiency concerns, and this allows macros to reconstruct selects as they see fit. WDYT? |
Scratch my previous message. Let me clarify a more rigorous proposal: Some background: As a mechanism to workaround this issue, I'm proposing that macro writers and users use the following convention:
Thus, instead of:
You might create:
Creating an actual selector list from this type is fairly trivial:
Upstream design proposal: Expose a native method on selector list, Thus:
I'll mail a PR which takes this approach, and ties it to an experimental flag. |
Hi anyone still reading this. Please see the latest conversation at #14157. I'm trying to push forward a solution to this, but need the help of anyone who would like to see this happen. |
We just reviewed this issue. My last comment remains relevant. |
Hi there! We're doing a clean up of old issues and will be closing this one. Please reopen if you’d like to discuss anything further. We’ll respond as soon as we have the bandwidth/resources to do so. |
@sgowroji Still relevant |
Description of the feature request:
The rules_k8s have a rule
k8s_objects
which takes a list of labels (k8s_object
targets) and creates multiple targets with these labels, with custom endings, that it knows have been created from the underlyingk8s_object
. So there is code like[x + ".create" for x in objects]
If objects is now aselect
statement that fails with something like: select is not iterable. IT would be nice if I could still iterate over aselect
statement similar to a dict, so I could manipulate the labels in the macro.Feature requests: what underlying problem are you trying to solve with this feature?
Now I have to use a normal
dict
as a workaround which the macro then converts into aselect
statement. I think this ends up being confusing for the end-user as that is not usualWhat's the output of
bazel info release
?0.25.2
Have you found anything relevant by searching the web?
#8171 but seems not directly related
Any other information, logs, or outputs that you want to share?
For the exact use of this see PR: bazelbuild/rules_k8s#342
The text was updated successfully, but these errors were encountered: