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

Error on collecting tests: #372

Closed
mcepl opened this issue Apr 27, 2022 · 6 comments · Fixed by #373
Closed

Error on collecting tests: #372

mcepl opened this issue Apr 27, 2022 · 6 comments · Fixed by #373
Assignees
Labels
priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@mcepl
Copy link

mcepl commented Apr 27, 2022

While updating the packaging for this package for openSUSE, we run the test suite and it errored on us:

Environment details

  • OS type and version: Linux/openSUSE/Tumbleweed as of today (2022-04-27)
  • Python version: python --version 3.9.12 (but also with 3.8.13 and 3.10.4)
  • pip version: pip --version 22.0.4
  • google-api-core version: pip show google-api-core 2.7.2

Steps to reproduce

  1. see below

Stack trace

[    9s] + PYTHONPATH=/home/abuild/rpmbuild/BUILDROOT/python-google-api-core-2.7.2-0.x86_64/usr/lib/python3.9/site-packages
[    9s] + PYTHONDONTWRITEBYTECODE=1
[    9s] + pytest-3.9 --ignore=_build.python39 --ignore=_build.python310 --ignore=_build.python38 -v
[    9s] ============================= test session starts ==============================
[    9s] platform linux -- Python 3.9.12, pytest-7.1.1, pluggy-1.0.0 -- /usr/bin/python3.9
[    9s] cachedir: .pytest_cache
[    9s] rootdir: /home/abuild/rpmbuild/BUILD/google-api-core-2.7.2
[    9s] plugins: asyncio-0.17.2
[    9s] asyncio: mode=legacy
[   10s] collecting ... collected 614 items / 1 error
[   10s]
[   10s] ==================================== ERRORS ====================================
[   10s] ______________ ERROR collecting tests/unit/test_rest_streaming.py ______________
[   10s] /usr/lib/python3.9/site-packages/google/protobuf/descriptor_database.py:129: in FindFileContainingSymbol
[   10s]     return self._file_desc_protos_by_symbol[symbol]
[   10s] E   KeyError: 'Genre'
[   10s]
[   10s] During handling of the above exception, another exception occurred:
[   10s] /usr/lib/python3.9/site-packages/google/protobuf/descriptor_database.py:138: in FindFileContainingSymbol
[   10s]     return self._file_desc_protos_by_symbol[top_level]
[   10s] E   KeyError: ''
[   10s]
[   10s] During handling of the above exception, another exception occurred:
[   10s] tests/unit/test_rest_streaming.py:36: in <module>
[   10s]     class Genre(proto.Enum):
[   10s] /usr/lib/python3.9/site-packages/proto/enums.py:102: in __new__
[   10s]     file_info.generate_file_pb(new_class=cls, fallback_salt=full_name)
[   10s] /usr/lib/python3.9/site-packages/proto/_file_info.py:138: in generate_file_pb
[   10s]     descriptor = pool.FindEnumTypeByName(full_name)
[   10s] /usr/lib/python3.9/site-packages/google/protobuf/descriptor_pool.py:534: in FindEnumTypeByName
[   10s]     self._FindFileContainingSymbolInDb(full_name)
[   10s] /usr/lib/python3.9/site-packages/google/protobuf/descriptor_pool.py:728: in _FindFileContainingSymbolInDb
[   10s]     raise error
[   10s] /usr/lib/python3.9/site-packages/google/protobuf/descriptor_pool.py:723: in _FindFileContainingSymbolInDb
[   10s]     file_proto = self._internal_db.FindFileContainingSymbol(symbol)
[   10s] /usr/lib/python3.9/site-packages/google/protobuf/descriptor_database.py:141: in FindFileContainingSymbol
[   10s]     raise KeyError(symbol)
[   10s] E   KeyError: 'Genre'
[   10s] =============================== warnings summary ===============================
[   10s] ../../../../../usr/lib/python3.9/site-packages/pytest_asyncio/plugin.py:191
[   10s]   /usr/lib/python3.9/site-packages/pytest_asyncio/plugin.py:191: DeprecationWarning: The 'asyncio_mode' default value will change to 'strict' in future, please explicitly use 'asyncio_mode=strict' or 'asyncio_mode=auto' in pytest configuration file.
[   10s]     config.issue_config_time_warning(LEGACY_MODE, stacklevel=2)

[ ... this warning repeated many times ... ]

[   10s] -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
[   10s] =========================== short test summary info ============================
[   10s] ERROR tests/unit/test_rest_streaming.py - KeyError: 'Genre'
[   10s] !!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
[   10s] ======================== 19 warnings, 1 error in 1.39s =========================
[   10s] error: Bad exit status from /var/tmp/rpm-tmp.4T1eKX (%check)
[   10s]

Complete build log with all details of packages used and steps taken to reproduce.

@mcepl
Copy link
Author

mcepl commented Apr 27, 2022

I have a deep suspicion about

https://github.com/protocolbuffers/protobuf/blob/ece5ef6b9b6fa66ef4638335612284379ee4548f/python/google/protobuf/descriptor_database.py#L81

It seems to me that it add to database a symbol with the lead dot, i.e., “.Genre”, not “Genre”.

@anandolee
Copy link

It only happens when package is empty.

The .proto file starts with a package declaration, which helps to prevent naming conflicts between different projects. In Python, packages are normally determined by directory structure, so the package you define in your .proto file will have no effect on the generated code. However, you should still declare package to avoid name collisions in the Protocol Buffers name space as well as in non-Python languages.

@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Apr 28, 2022
@mcepl
Copy link
Author

mcepl commented Apr 28, 2022

It only happens when package is empty.

This is freaking this package’s test suite! Does it mean you agree with me it is buggy?

the package you define in your .proto file will have no effect on the generated code.

As above, I haven’t defined anything, this is the test suite.

@parthea parthea added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p2 Moderately-important priority. Fix may not be included in next release. and removed triage me I really want to be triaged. labels Apr 29, 2022
@parthea
Copy link
Collaborator

parthea commented Apr 29, 2022

Related issues:
googleapis/proto-plus-python#171
googleapis/proto-plus-python#175

I have a similar stack trace with our internal build system. Googlers see cl/442743937. I'll check whether googleapis/proto-plus-python#309 fixes it.

@parthea parthea self-assigned this Apr 29, 2022
@parthea parthea added priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. and removed priority: p2 Moderately-important priority. Fix may not be included in next release. labels Apr 29, 2022
@parthea
Copy link
Collaborator

parthea commented Apr 29, 2022

Hi @mcepl, I was able to re-create the issue and confirmed that it is resolved with #373. We're planning to publish a new version next week. Please feel free to re-open this issue if the problem still appears with the next release.

@mcepl
Copy link
Author

mcepl commented Apr 29, 2022

#373 helped. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants