Isn't there a way from within a rule to call an as...
# plugins
p
Isn't there a way from within a rule to call an async function that issues an
await Get
in its body? I'm getting this error when I do that:
Copy code
E       native_engine.IntrinsicError: Get(Targets, UnparsedAddressInputs, UnparsedAddressInputs(values=('//runners/noop_runner',), relative_to='src/foobar', description_of_origin='entry_point_dependencies from src/foobar/test_something.py:tests', skip_invalid_addresses=False)) was not detected in your @rule body at rule compile time. Was the `Get` constructor called in a non async-function, or was it inside an async function defined after the @rule? Make sure the `Get` is defined before or inside the @rule body.
Here's the
Get
in the helper function that 2 rules call: https://github.com/pantsbuild/pants/pull/21062/files#diff-e1ddf55fc4b2b832db8a39ec88ffed8fdda413dde2620f56a5a18431882a6954R204-R211
1
w
I thought this used to be the use case for
@rule_helper
- but I thought that this should "just work" now...
Ah you know what, I can't recall if that use case included being able to call Get's inside
p
Yeah. That's what I thought... I'm getting this error in a test, so I suppose it could be that I haven't registered all the rules I need to. But, the error clearly mentions compile time detection of the get.
w
Unless I'm misunderstanding, this should work? https://github.com/pantsbuild/pants/pull/17947
🤷 1
Oh wait
What about literally, physically - it's below the call site?
Can you move the function above the rule function?
p
Oh. Yeah:
was it inside an async function defined after the @rule?
I'm reordering the rules now.
That worked 😅
w
🥳 I ran into that a while back, and thought to myself “I’ll never forget this” - until I subsequently forgot about it
😆 1
h
Related - looks like we can't call-by- name recursively? It gives that
was not detected in your @rule body at rule compile time
error.
w
Like, actually recursively? Do we recursively use GETs?
c
We should clarify this in the error message, that order of declaration matters.
h
Actually recursively. You can call a Get by type recursively inside the @rule that matches the type signature, but not by name.
I feel like once we migrate to call-by-name, it shouldn't matter? I'm not sure why we're doing this much validation in that case.
w
You can call a Get by type recursively inside the @rule that matches the type signature,
Ah yeah Well, they'll run side-by-side, and plugins will have GETs, so it's an issue to flag. Probably not a huge issue in the grand scheme
h
Hmm, it seems like a huge issue?
For example your migration script will cause currently-working recursive Gets to fail
w
Yeah, there's still a ton of sharp edges to go through, and manually fix things that we can't easily automate - e.g. cyclic deps
Though - in reading this, I'm surprised that would break, because the rule graph is still generated - we're calling into it using a different mechanism though
Is there some code I can try to migrate to run into this?
h
I'm debugging it ATM, will see what it's about