ancient-vegetable-10556
09/02/2022, 8:41 PMancient-vegetable-10556
09/02/2022, 8:42 PMancient-vegetable-10556
09/02/2022, 8:43 PMhundreds-father-404
09/02/2022, 8:45 PM[python-bootstrap].search_path
around, and it providing the default value for all environments (including no envs defined). That makes things much simpler when environments can be n = 1
Environment targets now only override the options systemancient-vegetable-10556
09/02/2022, 8:47 PMhundreds-father-404
09/02/2022, 8:50 PMdefault
and simplify our help
message to be nothing more than `"Overrides [python-bootstrap].binary_names
."`
2. Nothing needs to change about the options system, other than help
message to point out the relevant field
3. At our consumption sites, you will call something like
env_tgt.field_or_option(PythonBootstrapBinaryNamesField, python_bootstrap_subsystem, "search_path")
I caution that instead consuming the value via the Subsystem
instance may be an uphill battle. It can't use the Rules API, so you can't get magical — you must pass the env_tgt: ResolvedEnvironmentTarget
to the subsystem. So, it would now be something like python_bootstrap_subsystem.search_path(env_tgt)
, which makes accessing options much more complex for things that don't need itancient-vegetable-10556
09/02/2022, 8:55 PMenv_tgt
, but that’s a thing I want to explore further.)witty-crayon-22786
09/02/2022, 11:07 PMwitty-crayon-22786
09/02/2022, 11:08 PMwitty-crayon-22786
09/02/2022, 11:10 PM@rule
, partially applied with the subsystem to create: https://github.com/pantsbuild/pants/blob/d2b22d1594803c6a13dfcf6915a02e3b770f91dc/src/python/pants/option/subsystem.py#L133-L135 … if you adjusted that def signature
/ and @rule
to take an Environment, you could construct the subsystem with the overrideswitty-crayon-22786
09/02/2022, 11:11 PMwitty-crayon-22786
09/02/2022, 11:14 PMif you adjusted that…after https://github.com/pantsbuild/pants/pull/16721 lands/ anddef signature
to take an Environment, you could construct the subsystem with the overrides@rule
hundreds-father-404
09/02/2022, 11:33 PMthe end goal is still for options to live on Subsystems, then you could change the creation of the Subsystem to be environment specific.the idea is: • still keep the subsystems for when you're fine with exactly 1 env (and possible overrides via pants.rc) • otherwise, users define evironments using the new code from this week. subsystems give the defaults so I don't think we need to adjust how the subsystem is created?
witty-crayon-22786
09/02/2022, 11:33 PMwitty-crayon-22786
09/02/2022, 11:34 PMwitty-crayon-22786
09/02/2022, 11:35 PMhundreds-father-404
09/02/2022, 11:35 PMpython_bootstrap_subsystem.search_path
and It Just Does The Right Thingwitty-crayon-22786
09/02/2022, 11:35 PMhundreds-father-404
09/02/2022, 11:36 PMwitty-crayon-22786
09/02/2022, 11:42 PMancient-vegetable-10556
09/02/2022, 11:42 PMancient-vegetable-10556
09/02/2022, 11:43 PMhundreds-father-404
09/02/2022, 11:45 PMI think getting everything defined in the subsystem means we won’t need to do any of the options migration work, it’s just a matter of definining which options are environment specificDepending on how we have the fields defined in the local environment target. I continue to personally bias towards this:
local_environment(
python_bootstrap_search_paths=["<PYENV>"],
golang_executable_search_paths=["<PATH>"],
)
over this
local_environment(
options={
"[python-boostrap].search_paths": ["<PYENV>"],
"[golang].executable_search_paths": ["<PATH>"],
},
)
It makes ./pants help
nicer, and we eagerly get things like data validation & rejection of unrecognized fields
help
would look like:
Overrides [python-bootstrap].binary_names.
I like that ./pants help local_environment
makes clear which options can be used and which cannotwitty-crayon-22786
09/02/2022, 11:46 PMI Agree about revisiting the design doc. I think on Tuesday I write a two-pager about how I think this should work, and we update the rest of the design based on that?possibly… talk with @hundreds-father-404 on the mechanics of how to go about it probably.
hundreds-father-404
09/02/2022, 11:47 PMpossibly… talk with @hundreds-father-404 on the mechanics of how to go about it probably.I don't think a ton will need to change. Targets still make sense for defining environments; consuming targets like
python_test
still have environment: str
field the same as before
But yeah, sounds good to re-evaluate on Tuesdaywitty-crayon-22786
09/02/2022, 11:47 PMancient-vegetable-10556
09/02/2022, 11:52 PMancient-vegetable-10556
09/02/2022, 11:54 PMancient-vegetable-10556
09/02/2022, 11:55 PMhundreds-father-404
09/02/2022, 11:58 PMbut I also don’t want to get tied up on using fields if we can’t automate itI expect you can DRY this pretty nicely. Field subclassing is heavily encouraged, so you can develop
EnvironmentFieldMixin
that automates almost everything. And then Stu's suggestion can be combined with your options registration idea so that it's even better
Including because this is opt-in, I'm not that worried about having an extra 3-4 lines of simple boilerplate for this new mechanism. It's also not even very common you need to define a new EnvironmentFieldancient-vegetable-10556
09/06/2022, 3:26 PMancient-vegetable-10556
09/06/2022, 3:39 PMlocal_environment
target always represents a subset of what is available through the options system.
Advantages:
• We can systematically generate the names of the fields, so that there is consistent namespacing of fields, and field names will always match the corresponding option names
• Migrating an option from singleton to environment-sensitive is a one-line change
• We still get all the data validation advantages of using BUILD files
Disadvantages:
• If implemented naïvely, there is a cycle between creating the fields and creating the subsystem (not sure this is insurmountable, but it gives me pause)
• The origin of these fields is opaque to the casual observerwitty-crayon-22786
09/06/2022, 3:52 PMI think all of the config-related code should live in the same place, so that there isn’t a conceptual gap between singleton options and environment-sensitive ones. To the implementer, they’re all options, and it’d probably be easy to introduce a backwards incompatibility as you move from an option to a field.in general i agree that this would be preferable. haven’t really looked at the mechanism though. will let you and Eric talk through this a bit before i revisit.
ancient-vegetable-10556
09/06/2022, 3:54 PMwitty-crayon-22786
09/06/2022, 4:34 PMwitty-crayon-22786
09/06/2022, 4:34 PMwitty-crayon-22786
09/06/2022, 4:34 PMwitty-crayon-22786
09/06/2022, 4:35 PMancient-vegetable-10556
09/06/2022, 4:36 PMancient-vegetable-10556
09/06/2022, 4:37 PMwitty-crayon-22786
09/06/2022, 4:46 PMwitty-crayon-22786
09/06/2022, 4:48 PMhelp
for that Subsystem would still display the default
value, etc. the change is just that how things end up overridden by environments won’t be obvious in the help without some extra work there.ancient-vegetable-10556
09/06/2022, 4:50 PMwitty-crayon-22786
09/06/2022, 4:51 PMancient-vegetable-10556
09/06/2022, 4:52 PMwitty-crayon-22786
09/06/2022, 4:52 PMancient-vegetable-10556
09/06/2022, 4:52 PMancient-vegetable-10556
09/06/2022, 4:53 PMancient-vegetable-10556
09/06/2022, 4:54 PMancient-vegetable-10556
09/06/2022, 8:32 PMwitty-crayon-22786
09/06/2022, 8:35 PMancient-vegetable-10556
09/06/2022, 8:36 PMhundreds-father-404
09/06/2022, 8:37 PM[environments-preview]
at least)hundreds-father-404
09/06/2022, 8:37 PMwitty-crayon-22786
09/06/2022, 8:38 PMwitty-crayon-22786
09/06/2022, 8:39 PMancient-vegetable-10556
09/06/2022, 9:04 PMwitty-crayon-22786
09/06/2022, 9:06 PMwitty-crayon-22786
09/06/2022, 9:08 PMwitty-crayon-22786
09/06/2022, 9:09 PMancient-vegetable-10556
09/06/2022, 9:11 PMwitty-crayon-22786
09/06/2022, 9:11 PMmy assumption so far had been that environments would be similar to resolves in that regard: mostly admins.and to be clear: this is “an admin blesses the creation of a new environment/resolve, but an end user might be editing it day to day”. that’s definitely the case for a resolve (all the requirements need edits on an ongoing basis), but whether it’s the case for an environment is unclear (changing env vars all the time…?)
witty-crayon-22786
09/06/2022, 9:13 PMInteresting — we’re definitely conceptualising Docker in a different way to how Docker is usually conceptualisedyea. i think because this use case in particular is for the consumption of images, rather than their production.
ancient-vegetable-10556
09/06/2022, 9:14 PMwitty-crayon-22786
09/06/2022, 9:15 PMdocker_image
target… those we’re expecting lots ofancient-vegetable-10556
09/06/2022, 9:16 PMwitty-crayon-22786
09/06/2022, 9:17 PMancient-vegetable-10556
09/06/2022, 9:23 PMhundreds-father-404
09/06/2022, 9:23 PMancient-vegetable-10556
09/06/2022, 9:23 PMancient-vegetable-10556
09/06/2022, 9:24 PMancient-vegetable-10556
09/12/2022, 10:19 PM