-
-
Notifications
You must be signed in to change notification settings - Fork 649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Protobuf sources does not work with parametrized resolves #21409
Comments
Hi, it would be really helpful if you could create a repo containing a minimal repro of this, with a README explaining how to reproduce the bug. Then all we need to do is clone your repo and run that, and we can be sure we're all looking at the same thing. Thanks! |
I recall a steady series of fixes to parametrisation in 2.22.0 and 2.23 (currently in pre-release), so potentially you could try upgrading to one of those and see if the problem is already resolved. If not, a standalone reproducer as Benjy describes would be great, thank you! |
Hi all, I've tried with 2.22.0 and still see the issue. I have made a sample repo here where the README explains the problem and steps to reproduce |
Thanks. I can reproduce the issue with 2.23.0a0 too. I don't have input on resolving it though, but maybe someone else does. (BTW, not related to that issue, just picking up from the description: Pants will manage the codegen and venvs internally, so |
Thanks for the robust repro, which reproduces the issue for me. I will take a look ASAP. |
These warnings seem pertinent:
|
The parametrization introduces two sources of each .proto to .proto dependency. And because dep inference isn't disambiguating via the specific parametrization, Pants selects neither dep, and you end up with those errors. I'll see how this is handled in other parametrized contexts, such as dep inference between .py files. |
Interestingly:
So the |
So for Python dep resolution the resolve is used in a deep way to disambiguate:
The same is not true for proto dep resolution. The problem is, I'm not sure how it could be. The resolve is a python-specific concept that is passed through the |
@omri-cavnue have you found a workaround? |
@benjyw no not yet. I've tried a few solutions, including adding the files to the dependencies list manually, as well as creating a matrix via parametrization in the dependencies field, but neither works and these are also very manual solutions |
@benjyw I wanted to follow up here to see whether there is anything in the pipeline to unblock this issue? |
I haven't looked at it in depth yet, but thanks for the reminder. Will try and get to it ASAP. |
EDIT: Spoke too soon, it was because of not having the correct |
@omri-cavnue , looking at this more closely - now that I think of it, why are you parametrizing the proto targets at all? Is this so that the runtime proto library comes from the appropriate resolve in each case? |
@benjyw That's right. We have our protos as first party dependencies and would like to use them across resolves, so we are parametrizing them so that we can use compiled python definitions across resolves |
And if you don't parameterize the proto targets, Pants assigns the generated python code to the default resolve or something? |
What is interesting here is that the protobuf Python rules do deal with the pants/src/python/pants/backend/codegen/protobuf/python/python_protobuf_module_mapper.py Line 61 in 3c15034
|
Yes, but proto dep inference is entirely in the proto rules, which don't know about this "plugin field". |
So we need a way for protobuf dep inference to account for |
Thought: Add a mix-in |
Very rough draft of the partitioning solution: #21918 It does not work currently due to rule graph errors, but you can see the potential solution direction. |
After some more work on the draft PR, it fixes the bug in the reproduction repository. Although it still needs a unit test and there is a limitation if more than 1 resolve-like field were registered on a protobuf target. |
@benjyw yup exactly, it will only work with the default resolve in that case |
Describe the bug
When introducing multiple resolves into the repo, all of the python sources and test targets seem to work. However, the protobuf_sources does not work against multiple resolves. On a single resolve, the target works. But when parametrizing against multiple resolves, it complains about proto files not being found when they are imported into other proto files.
Pants version
2.21.0
OS
Both mac and linux
Additional info
The repo structure is similart to:
Here, the dog.proto would import person.proto to identify an owner.
and it complains about messages/example/v1/person.proto File not found.
The BUILD file is as follows:
With one resolve, this works as expected. With multiple resolves, it complains that the person.proto file is not found when trying to create python sources for the dog proto
The text was updated successfully, but these errors were encountered: