https://pantsbuild.org/ logo
#plugins
Title
# plugins
a

ambitious-actor-36781

04/05/2023, 3:53 AM
I'm trying to upgrade to 2.15 from 2.14, and I'm getting rule graph errors. I think I've narrowed it down to a:
Get(SourceFiles, SourceFilesRequest((tgt.get(SourcesField) for tgt in transitive_targets.closure), enable_codegen=True, for_source_types=(PythonSourcesField)
Has there been any changes around this?
p

proud-dentist-22844

04/05/2023, 9:51 PM
My update from 2.14 to 2.15 was extensive. I don’t think I’m doing exactly the same thing, but feel free to peruse my PR: https://github.com/StackStorm/st2/pull/5899 Also, check out: https://github.com/pantsbuild/pants/blob/main/src/python/pants/notes/2.15.x.md https://www.pantsbuild.org/v2.15/docs/plugin-upgrade-guide Sorry I don’t have time to dig in and figure out which of the changes could be triggering your rule graph error.
a

ambitious-actor-36781

04/06/2023, 2:32 AM
cheers. Ill have a look!
Are there any tricks to deciphering and finding the root-cause of rule graph errors? I feel like a Get(SourceFiles) shouldn’t be the trigger. But am completely stumped as to what the actual problem is. (And it’s not like it’s the only time I call it. Other rules depend on the same thing with no issues)
1
w

wide-midnight-78598

04/10/2023, 11:08 PM
Just this as far as I know - https://www.pantsbuild.org/docs/rules-api-tips#debugging-rule-graph-issues I'm in the same boat. Certain amount of magic in making those graph errors go away - sucks when its a glorified typo or missing field
Oh! Wait. I ran into this too a while back. I'll try and find some code in some repo where I solved it
a

ambitious-actor-36781

04/10/2023, 11:09 PM
I think I’ve traced it down to a Union rule. Not actually a source request.
If I comment out the “UnionRule(A, Base)” I don’t get the error.
c

curved-television-6568

04/10/2023, 11:10 PM
try changing your union type declaration to
@union(in_scope_types=[EnvironmentName])
Copy code
from pants.engine.environment import EnvironmentName
a

ambitious-actor-36781

04/10/2023, 11:12 PM
I could kiss you @curved-television-6568
😇 1
c

curved-television-6568

04/10/2023, 11:13 PM
there’s blood sweat and tears embedded in that knowledge 😉
a

ambitious-actor-36781

04/10/2023, 11:15 PM
That should probably be documented.
c

curved-television-6568

04/10/2023, 11:16 PM
yes, and fixed with a proper error message 🙂
a

ambitious-actor-36781

04/10/2023, 11:16 PM
Doesn’t appear to be mentioned in the upgrade guide, or Union docs.
c

curved-television-6568

04/10/2023, 11:16 PM
hmm… that’s unfortunate
a

ambitious-actor-36781

04/10/2023, 11:17 PM
What does the change/fix … mean?
c

curved-television-6568

04/10/2023, 11:17 PM
let’s see if can get this right.. (typing…)
with the introduction of the new environments feature, there was a need to be able to plumb through which environment to target without to pass that around explicitly as that would require a lot of changes to ~every rule. This was done generically for the rule graph, but unions are a bit special, so needed to explicitly opt-in to it per union type (as you see above).
So what happens when you don’t is that rules that need to know which environment to target doesn’t work
but not all unions need/want this, which is why it’s not on by default.
and rule graph errors being what they are, gives grief when you get this wrong
a

ambitious-actor-36781

04/10/2023, 11:21 PM
Hmm. Ok… I’m guessing /something/ in the graph is using Environments (because my code isn’t) hence the dependency?
c

curved-television-6568

04/10/2023, 11:21 PM
yea, there’s a ton of rules in core that rely/need it.
so my no 1 go to for rule graph issues now is to check any unions in play first.
a

ambitious-actor-36781

04/10/2023, 11:22 PM
Cool. That one change that took a load off. 😍 love working with you lot.
❤️ 2