Skip to content
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

proto-plus returns incorrect unwrapped protos when protobuf 4 is used in conda env #470

Closed
Ark-kun opened this issue Jul 9, 2024 · 0 comments · Fixed by #475
Closed
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@Ark-kun
Copy link

Ark-kun commented Jul 9, 2024

Environment details

  • Programming language: Python
  • OS: Linux
  • Language runtime version: 3.11, Anaconda
  • Package version: 1.24

Steps to reproduce

conda config --append channels conda-forge
conda create -n myenv
conda activate myenv 
pip install google-cloud-aiplatform 
$ python -c 'from vertexai.generative_models import _generative_models as g
part1 = g.Part.from_uri(uri="gs://foo/bar", mime_type="baz")
gapic_content = g._to_content(part1)
parts = gapic_content.parts
part0 = parts[0]
print(type(part0))
# print("text" in part0)
# print("file_data" in part0)
print(part0._pb.WhichOneof("data"))
<class 'Part'>
Traceback (most recent call last):
  File "<string>", line 9, in <module>
AttributeError: _pb
(issue_3129) user@w-avolkov-lydu7cih:~$ python
Python 3.11.0 (main, Mar  1 2023, 18:26:19) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from vertexai.generative_models import _generative_models as g
>>> part1 = g.Part.from_uri(uri="gs://foo/bar", mime_type="baz")
>>> gc = g._to_content(part1)

>>> type(gc)
<class 'google.cloud.aiplatform_v1beta1.types.content.Content'>
>>> type(gc.parts)
<class 'google.protobuf.pyext._message.RepeatedCompositeContainer'>
>>> type(gc.parts[0])
<class 'Part'>
>>> type(gc.parts[0]).__module__
>>> type(gc.parts[0]).__name__
'Part'
>>> type(gc.parts[0]).__dict__
mappingproxy({'DESCRIPTOR': <google.protobuf.pyext._message.MessageDescriptor object at 0x79c4ee245510>, '__module__': None, '__slots__': (), '__doc__': None, 'text': <field property 'google.cloud.aiplatform.v1beta1.Part.text'>, 'inline_data': <field property 'google.cloud.aiplatform.v1beta1.Part.inline_data'>, 'file_data': <field property 'google.cloud.aiplatform.v1beta1.Part.file_data'>, 'function_call': <field property 'google.cloud.aiplatform.v1beta1.Part.function_call'>, 'function_response': <field property 'google.cloud.aiplatform.v1beta1.Part.function_response'>, 'video_metadata': <field property 'google.cloud.aiplatform.v1beta1.Part.video_metadata'>})

See how gc is a proper GAPIC proto-plus message, but gc.parts[0] is a raw protobuf message.

See also googleapis/python-aiplatform#3129

@Ark-kun Ark-kun added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
1 participant