ancient-vegetable-10556
03/08/2023, 10:43 PMwitty-crayon-22786
03/08/2023, 10:43 PMwitty-crayon-22786
03/08/2023, 10:44 PMancient-vegetable-10556
03/08/2023, 10:44 PMwitty-crayon-22786
03/08/2023, 10:44 PMancient-vegetable-10556
03/08/2023, 10:45 PMancient-vegetable-10556
03/08/2023, 10:46 PMwitty-crayon-22786
03/08/2023, 10:46 PMRuleRunner , you’re thinking of “supplied by a `Get`” vs “supplied by a `Query`” ?ancient-vegetable-10556
03/08/2023, 10:47 PMEnvironmentName that would get automatically passed in as a param to the rule if one were not supplied explicitly, and there’s the EnvironmentName that gets supplied explicitly in a Getwitty-crayon-22786
03/08/2023, 10:48 PMancient-vegetable-10556
03/08/2023, 10:48 PMwitty-crayon-22786
03/08/2023, 10:48 PMproduct_requestancient-vegetable-10556
03/08/2023, 10:49 PMEnvironmentName needs to be passed in explicitly (Josh’s example; BuiltPackage , etc), but because we don’t separate the concepts of an explicitly-supplied environment and the Embedded environment, you can call the rule without supplying an EnvironmentName, it’ll work, and it’ll be wrongwitty-crayon-22786
03/08/2023, 10:50 PMwitty-crayon-22786
03/08/2023, 10:50 PMancient-vegetable-10556
03/08/2023, 10:50 PMBuiltPackage bugs that we experienced)witty-crayon-22786
03/08/2023, 10:50 PMBuiltPackage bugs… but i could be wrong.ancient-vegetable-10556
03/08/2023, 10:51 PMancient-vegetable-10556
03/08/2023, 10:56 PMwitty-crayon-22786
03/08/2023, 10:56 PMwitty-crayon-22786
03/08/2023, 10:57 PM@rule definitions everywhere to indicate that they want to pass the EnvironmentName throughancient-vegetable-10556
03/08/2023, 10:58 PMSuppliedEnvironmentName type, which we use for things like the BuiltPackage boundaryancient-vegetable-10556
03/08/2023, 10:59 PMEnvironmentName param. You need to explicitly construct oneancient-vegetable-10556
03/08/2023, 11:00 PMancient-vegetable-10556
03/08/2023, 11:00 PMwitty-crayon-22786
03/08/2023, 11:03 PM@union to specify that SuppliedEnvironmentName will be in scope: https://github.com/pantsbuild/pants/blob/f5710a2856d73d2c68c06298d87da11b49c5a8bb/src/python/pants/core/goals/package.py#L38 or removing the EnvironmentName from the @union(in_scope_types=..), and requiring that PackageFieldSet implementations have and use an environment field.ancient-vegetable-10556
03/08/2023, 11:05 PMSuppliedEnvironmentName would be needed to invoke the first rule, but that’s what provides the in-scope EnvironmentName from then onancient-vegetable-10556
03/08/2023, 11:10 PMwitty-crayon-22786
03/08/2023, 11:10 PM@union(in_scope_types=..) is supposed to be for.ancient-vegetable-10556
03/08/2023, 11:11 PMancient-vegetable-10556
03/08/2023, 11:12 PMBuiltPackage implementers as out of scope, but then every rule that you call has to explicitly supply an environmentwitty-crayon-22786
03/08/2023, 11:12 PMwitty-crayon-22786
03/08/2023, 11:12 PMancient-vegetable-10556
03/08/2023, 11:12 PMwitty-crayon-22786
03/08/2023, 11:13 PMin_scope_types could probably be tweaked to enforce that.witty-crayon-22786
03/08/2023, 11:14 PMwitty-crayon-22786
03/08/2023, 11:16 PMancient-vegetable-10556
03/08/2023, 11:17 PMcurved-television-6568
03/08/2023, 11:27 PMPackageFieldSet has the in_scope_types defined, if we remove that, wouldn’t that require all rules dealing with it to also explicitly provide the EnvironmentName?
https://github.com/pantsbuild/pants/blob/f5710a2856d73d2c68c06298d87da11b49c5a8bb/src/python/pants/core/goals/package.py#L38-L40curved-television-6568
03/08/2023, 11:28 PMwitty-crayon-22786
03/08/2023, 11:28 PMcurved-television-6568
03/08/2023, 11:29 PMancient-vegetable-10556
03/08/2023, 11:29 PMwitty-crayon-22786
03/08/2023, 11:30 PMancient-vegetable-10556
03/08/2023, 11:30 PMGet having to supply EnvironmentName, which is messy)witty-crayon-22786
03/08/2023, 11:31 PMyou either can get it automatically (which leads to bugs)to be clear: it’s still the case that in 98% of positions, you want it implicitly/automatically. i think that it will only be some `@union`s where that is not the case.
ancient-vegetable-10556
03/08/2023, 11:31 PMcurved-television-6568
03/08/2023, 11:32 PMin_scope_types it would be:
built_package = await Get(BuiltPackage, {fs: PackageFieldSet, env: EnvironmentName})"curved-television-6568
03/08/2023, 11:32 PMwitty-crayon-22786
03/08/2023, 11:33 PMwitty-crayon-22786
03/08/2023, 11:33 PMcurved-television-6568
03/08/2023, 11:33 PMwitty-crayon-22786
03/08/2023, 11:33 PMwitty-crayon-22786
03/08/2023, 11:34 PMancient-vegetable-10556
03/08/2023, 11:34 PMancient-vegetable-10556
03/08/2023, 11:35 PMancient-vegetable-10556
03/08/2023, 11:35 PMcurved-television-6568
03/08/2023, 11:35 PMcurved-television-6568
03/08/2023, 11:36 PMwitty-crayon-22786
03/08/2023, 11:36 PM@union implementationwitty-crayon-22786
03/08/2023, 11:37 PMisn’t the example above what we’d want to work, though?yes. i think that another way to have implemented
@union(in_scope_types=..) would have been to make it an argument to Get instead.ancient-vegetable-10556
03/08/2023, 11:38 PMwitty-crayon-22786
03/08/2023, 11:39 PMbuilt_package = await Get(BuiltPackage, {fs: PackageFieldSet}, implicitly=[EnvironmentName])witty-crayon-22786
03/08/2023, 11:40 PM@union usage provides the `EnvironmentName`” declaration from @union onto the `Get`s that used the @union.ancient-vegetable-10556
03/08/2023, 11:41 PMBuiltPackage case where a rule wants you to explicitly specify the environmentancient-vegetable-10556
03/08/2023, 11:41 PMwitty-crayon-22786
03/08/2023, 11:43 PMawait Get(BuiltPackage, {fs: PackageFieldSet, env: EnvironmentName})witty-crayon-22786
03/08/2023, 11:43 PMwitty-crayon-22786
03/08/2023, 11:44 PMwitty-crayon-22786
03/08/2023, 11:45 PM@union(in_scope_types=..) is more like the callee declaring the interface, vs the caller.curved-television-6568
03/08/2023, 11:47 PMcurved-television-6568
03/08/2023, 11:50 PMcurved-television-6568
03/08/2023, 11:52 PMancient-vegetable-10556
03/08/2023, 11:53 PMancient-vegetable-10556
03/08/2023, 11:53 PMwitty-crayon-22786
03/08/2023, 11:54 PMwitty-crayon-22786
03/08/2023, 11:54 PMin_scope_types resolved https://github.com/pantsbuild/pants/issues/12934witty-crayon-22786
03/08/2023, 11:57 PMcurved-television-6568
03/09/2023, 12:00 AM@union specifics.. need to ponder a bit longer on what the unions bring for pecularities that gives them a “particular limited API”witty-crayon-22786
03/09/2023, 12:02 AM@rule ends up with an expanded signature that includes all of the dependency parameters that it needs transitively… on the other hand, use of a @union effectively has a statically declared signature (this output type for exactly these input types)curved-television-6568
03/09/2023, 12:04 AMcurved-television-6568
03/09/2023, 12:05 AMwitty-crayon-22786
03/09/2023, 12:05 AMcurved-television-6568
03/09/2023, 12:07 AMwitty-crayon-22786
03/09/2023, 12:08 AMcurved-television-6568
03/09/2023, 12:10 AMcurved-television-6568
03/09/2023, 12:11 AMwitty-crayon-22786
03/09/2023, 12:12 AM@rule is that they become part of the “key”/“identity” for the `@rule`: that’s how memoization works.curved-television-6568
03/09/2023, 12:12 AMwitty-crayon-22786
03/09/2023, 12:12 AM@rule consumes the environment, so that the environment can be included in its identity, and two copies are created for two different environmentscurved-television-6568
03/09/2023, 12:13 AM