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

Failed to import viewport by wrong import path #13222

Open
1 task done
ringsaturn opened this issue Oct 28, 2024 · 1 comment
Open
1 task done

Failed to import viewport by wrong import path #13222

ringsaturn opened this issue Oct 28, 2024 · 1 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.

Comments

@ringsaturn
Copy link

ringsaturn commented Oct 28, 2024

Determine this is the right repository

  • I determined this is the correct repository in which to report this bug.

Summary of the issue

Context

I tried to build a message with viewport.

Expected Behavior:

Run as normally without exception.

Actual Behavior:

Failde with ImportError: cannot import name 'viewport_pb2' from 'google.geo.type'

API client name and version

google-geo-type v0.3.10

Reproduction steps: code

file: sample.proto

syntax = "proto3";

import "google/geo/type/viewport.proto";
import "google/protobuf/timestamp.proto";

message ImageItem {
  string path = 1;
  google.protobuf.Timestamp timestamp = 2;
  google.geo.type.Viewport viewport = 3;
}

file: sample_pb2

# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# NO CHECKED-IN PROTOBUF GENCODE
# source: sample.proto
# Protobuf Python Version: 5.28.2
"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from google.protobuf import runtime_version as _runtime_version
from google.protobuf import symbol_database as _symbol_database
from google.protobuf.internal import builder as _builder
_runtime_version.ValidateProtobufRuntimeVersion(
    _runtime_version.Domain.PUBLIC,
    5,
    28,
    2,
    '',
    'sample.proto'
)
# @@protoc_insertion_point(imports)

_sym_db = _symbol_database.Default()


from google.geo.type import viewport_pb2 as google_dot_geo_dot_type_dot_viewport__pb2
from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2


DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0csample.proto\x1a\x1egoogle/geo/type/viewport.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"u\n\tImageItem\x12\x0c\n\x04path\x18\x01 \x01(\t\x12-\n\ttimestamp\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12+\n\x08viewport\x18\x03 \x01(\x0b\x32\x19.google.geo.type.Viewportb\x06proto3')

_globals = globals()
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'sample_pb2', _globals)
if not _descriptor._USE_C_DESCRIPTORS:
  DESCRIPTOR._loaded_options = None
  _globals['_IMAGEITEM']._serialized_start=81
  _globals['_IMAGEITEM']._serialized_end=198
# @@protoc_insertion_point(module_scope)

Reproduction steps: supporting files

https://github.com/ringsaturn/proto-debug

Reproduction steps: actual results

file: sample_pb2

python sample_pb2.py                             
Traceback (most recent call last):
  File "~/proto-debug/sample_pb2.py", line 26, in <module>
    from google.geo.type import viewport_pb2 as google_dot_geo_dot_type_dot_viewport__pb2
ImportError: cannot import name 'viewport_pb2' from 'google.geo.type' (~/proto-debug/.venv/lib/python3.12/site-packages/google/geo/type/__init__.py)

Reproduction steps: expected results

file: sample_pb2

OS & version + platform

macoS

Python environment

3.12

Python dependencies

Package                  Version
------------------------ ---------
cachetools               5.5.0
certifi                  2024.8.30
charset-normalizer       3.4.0
google-api-core          2.21.0
google-auth              2.35.0
google-geo-type          0.3.10
googleapis-common-protos 1.65.0
grpcio                   1.67.0
grpcio-status            1.67.0
idna                     3.10
proto-plus               1.25.0
protobuf                 5.28.3
pyasn1                   0.6.1
pyasn1-modules           0.4.1
requests                 2.32.3
rsa                      4.9
urllib3                  2.2.3

Additional context

A repo for debug: https://github.com/ringsaturn/proto-debug

@ringsaturn ringsaturn added triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Oct 28, 2024
@vchudnov-g vchudnov-g added priority: p2 Moderately-important priority. Fix may not be included in next release. and removed triage me I really want to be triaged. labels Nov 8, 2024
@vchudnov-g
Copy link
Contributor

Thanks for filing this issue! We'll investigate.

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
Development

No branches or pull requests

2 participants