-
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
Platform reuse rules #6218
Comments
I think the proper semantics is to add a new attribute to the existing platform rule, called "parent", and allow the newly-defined platform to inherit non-conflicting constraint values from the parent. Straw man example:
One question: how should remote_execution_properties be handled when a platform extends another? Replace? Add some type of macro that can be expanded to the parent's remote execution properties? |
Wait, if we could expand from ":some_platform" to its constraints and execution properties, we wouldn't even need the parent attribute, we could just reuse these directly, right? It would be a tad bulkier, but still achieve the main goal of not having to, for example, copy/paste the name of the docker image all over the build files. |
There's no current mechanism to expand the attributes of a target in another target. I'm trying to figure out what's needed to handle the remote_execution_properties. The simplest option is that it's completely replaced (or, if not changed, kept intact), but I suspect what you actually need is a way to modify the remote execution properties in the child. Is it enough to simply add new text to the end of the remote execution properties? Would the beginning be better? Note that Bazel itself doesn't do anything with these properties until it's time to send a remote execution request, when they get converted into a proto. Ideally, Bazel wants to do the smallest amount of processing for these properties, since they are very dependent on the specific remote execution system that processes them. |
Oh, so what did you mean by "Add some type of macro that can be expanded to the parent's remote execution properties?" Wait, is it okay that we could never remove constraints from the parent using this approach? (I'm not sure if there's a use case for it anyway) |
When I said "Add some type of macro that can be expanded to the parent's remote execution properties" what I was suggesting was that the platform rule define a special macro, say "{PARENT_REMOTE_EXECUTION_PROPETIES}", and when a platform has the parent attribute set, the remote_execution_properties has this expanded. This would be a one-off for just this property, but as an example, we could do:
Having duplicate attributes is confusing to users and violates how other Bazel rules work. When you define a java_library, you don't use deps in the base library and extra_deps in a library that depends on it, you use the same attribute in both places. The simplest way to handle remote_execution_properties is to not have special macro handling, and just append at the end. The benefit of special macro handling is that it allows the user to control whether the parent properties are copies to the child or not, so it's more flexible. |
Got it. Sure, sounds good! Let's do the macro, it's more flexible and more explicit. Thank you! |
* Add design draft for platform inheritance, related to bazelbuild/bazel#6218. * Fixes from review.
PlatformInfo. Part of work on bazelbuild#6218. Change-Id: I035ee60ad6e19a527d7e0c9f7064d1804dc8e38a
Fixes bazelbuild#6218. Change-Id: I7dcf430fbcf745654058113cf68df18a88e44c94
It would be nice to be able to reuse existing platforms for defining other platforms. For example, we're using remote execution properties to turn on docker features like enabling network usage, or root access, or use a specific machine type for particular targets (multipool). Sometimes, extra constraints are needed to make sure the modified platform gets selected for a rule that has exec_compatible_with it.
I think extending or modifying single parent platform would be a nice syntactic sugar to have, e.g:
platform_from_parent(
parent,
constraint_values=... / extra_constraint_values=...
remote_properties=... / extra_remote_properties=...
)
The text was updated successfully, but these errors were encountered: