Open Eric-Arellano opened 1 year ago
"Bootstrap" uses a BootstrapScheduler
, which is configured a particular way: https://github.com/pantsbuild/pants/blob/f16e9d0c57295ec48660a2350e461b891422821e/src/python/pants/init/options_initializer.py#L64-L82 ... it should always fully disable remote execution due to the DynamicRemoteOptions.disabled()
line there.
@stuhood it looks like that only impacts our Rust values, but it does not overwrite the values of OptionsBootstrapper
used here:
options_bootstrapper.get_bootstrap_options().for_global_scope().remote_execution
in this method returns True during the plugin resolution stage.
This is an issue because we now determine whether to use RE from PyProcessConfigFromEnvironment
, whereas before it was a global toggle controlled by Rust.
I think we have two fixes:
OptionsBootstrapper -> GlobalOptions
into disabling all the dynamic remote options, e.g. add OptionsBootstrapper.remote_options_disabled()
Suggestions?
There is a pattern of adding static resolve
methods to GlobalOptions
which take the inputs needed to compute a value, rather than accessing it directly:
https://github.com/pantsbuild/pants/blob/be00ed54ca4d68539c5d840bf2381b33603d747a/src/python/pants/option/global_options.py#L1838-L1919
... but they're used purely by convention. In this case that might look like calling: GlobalOptions.resolve_remote_execution(global_options, dynamic_remote_options)
in a @rule
.
There isn't a way to "overlay" the DynamicRemoteOptions
onto the options bootstrapper... but you could think of them as another options "Rank
"... "DYNAMIC_OPTIONS" or "PLUGIN_OPTIONS" or something: https://github.com/pantsbuild/pants/blob/be00ed54ca4d68539c5d840bf2381b33603d747a/src/python/pants/option/ranked_value.py#L12-L20 ... and then have a facility for plugins to add options? ...pretty advanced.
A hacky way to accomplish something similar would be to essentially convert the DynamicRemoteOptions
back into CLI args, and append those during bootstrap. Oy.
Thanks for the feedback!
In this case that might look like calling: GlobalOptions.resolve_remote_execution(global_options, dynamic_remote_options) in a @rule.
The issue is we would need in the rule to still know whether we're in the plugin resolver or not. Generally, we'd want to use DynamicRemoteOptions
as is. But in same cases, we want to use its .disabled()
variant. Now, that could be injected into the graph!
But at that point, maybe it's easier to have some other sentinel mechanism so that these 3 relevant rules can check if they're in the plugin resolver and change their logic accordingly?
But at that point, maybe it's easier to have some other sentinel mechanism so that these 3 relevant rules can check if they're in the plugin resolver and change their logic accordingly?
@stuhood thoughts on how we could know inside platform_rules.py
that it's the plugin resolver session?
Now, that could be injected into the graph!
Anything can be injected as a singleton without a lot of fanfare in EngineInitializer.setup_graph_extended
... you could pass a wrapped boolean, pass the entire DynamicRemoteOptions
in and then use it to call static methods, etc.
@stuhood it looks like this is still an issue, right? I thought I had seen you fix something related, but can't find it.
https://github.com/pantsbuild/pants/pull/17135 needs to run in local execution mode when the bootstrap stage is happening. Otherwise we get:
I'm not sure how to know it's the bootstrap stage.