I'm trying to upgrade to 2.15 from 2.14, and I'm g...
# plugins
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?
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.
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)
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
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.
try changing your union type declaration to
Copy code
from pants.engine.environment import EnvironmentName
I could kiss you @curved-television-6568
😇 1
there’s blood sweat and tears embedded in that knowledge 😉
That should probably be documented.
yes, and fixed with a proper error message 🙂
Doesn’t appear to be mentioned in the upgrade guide, or Union docs.
hmm… that’s unfortunate
What does the change/fix … mean?
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
Hmm. Ok… I’m guessing /something/ in the graph is using Environments (because my code isn’t) hence the dependency?
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.
Cool. That one change that took a load off. 😍 love working with you lot.
❤️ 2