Skip to content
This repository was archived by the owner on Feb 26, 2026. It is now read-only.

build: update constraints files#935

Merged
gkevinzheng merged 12 commits intomainfrom
update-constraints
Aug 15, 2024
Merged

build: update constraints files#935
gkevinzheng merged 12 commits intomainfrom
update-constraints

Conversation

@parthea
Copy link
Copy Markdown
Contributor

@parthea parthea commented Aug 14, 2024

Towards #934

BEGIN_COMMIT_OVERRIDE
fix(deps): require opentelemetry-api>=1.9.0
fix(deps): require google-cloud-appengine-logging>=0.1.3
fix(deps): require google-cloud-audit-log >= 0.2.4
END_COMMIT_OVERRIDE

@product-auto-label product-auto-label bot added size: s Pull request size is small. api: logging Issues related to the googleapis/python-logging API. labels Aug 14, 2024
@parthea parthea added the owlbot:run Add this label to trigger the Owlbot post processor. label Aug 14, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Aug 14, 2024
@parthea
Copy link
Copy Markdown
Contributor Author

parthea commented Aug 14, 2024

If presubmits fail we may need to bump the minimum supported version of dependencies

@parthea parthea added the owlbot:run Add this label to trigger the Owlbot post processor. label Aug 14, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Aug 14, 2024
@product-auto-label product-auto-label bot added size: m Pull request size is medium. and removed size: s Pull request size is small. labels Aug 15, 2024
@parthea
Copy link
Copy Markdown
Contributor Author

parthea commented Aug 15, 2024

google-cloud-audit-log >= 0.1.1 is needed to resolve this error which appears with google-cloud-audit-log == 0.1.0

______ ERROR collecting tests/unit/handlers/test__monitored_resources.py _______
tests/unit/handlers/test__monitored_resources.py:23: in 
    from google.cloud.logging_v2.handlers._monitored_resources import (
google/cloud/logging_v2/__init__.py:21: in 
    from google.cloud.logging_v2.client import Client
google/cloud/logging_v2/client.py:25: in 
    from google.cloud.logging_v2._helpers import _add_defaults_to_filter
google/cloud/logging_v2/_helpers.py:25: in 
    from google.cloud.logging_v2.entries import LogEntry
google/cloud/logging_v2/entries.py:31: in 
    import google.cloud.audit.audit_log_pb2  # noqa: F401
.nox/unit-3-7-protobuf_implementation-python/lib/python3.7/site-packages/google/cloud/audit/audit_log_pb2.py:48: in 
    google_dot_rpc_dot_status__pb2.DESCRIPTOR,
.nox/unit-3-7-protobuf_implementation-python/lib/python3.7/site-packages/google/protobuf/descriptor.py:1034: in __init__
    _Deprecated('FileDescriptor')
.nox/unit-3-7-protobuf_implementation-python/lib/python3.7/site-packages/google/protobuf/descriptor.py:102: in _Deprecated
    category=DeprecationWarning, stacklevel=3)
E   DeprecationWarning: Call to deprecated create function FileDescriptor(). Note: Create unlinked descriptors is going to go away. Please use get/find descriptors from generated code or query the descriptor_pool.

@parthea
Copy link
Copy Markdown
Contributor Author

parthea commented Aug 15, 2024

opentelemetry-api >= 1.9.0 is needed to resolve this error which appears with opentelemetry-api < 1.9.0

(py392) partheniou@partheniou-vm-3:~/git/python-logging$ nox -s "unit-3.7(protobuf_implementation='python')" -- -k test_otel_span_exists_both_django_and_flask
nox > Running session unit-3.7(protobuf_implementation='python')
nox > Creating virtual environment (virtualenv) using python3.7 in .nox/unit-3-7-protobuf_implementation-python
nox > python -m pip install mock asyncmock pytest pytest-cov pytest-asyncio -c /usr/local/google/home/partheniou/git/python-logging/testing/constraints-3.7.txt
nox > python -m pip install flask webob django -c /usr/local/google/home/partheniou/git/python-logging/testing/constraints-3.7.txt
nox > python -m pip install -e . -c /usr/local/google/home/partheniou/git/python-logging/testing/constraints-3.7.txt
nox > py.test --quiet --junitxml=unit_3.7_sponge_log.xml --cov=google --cov=tests/unit --cov-append --cov-config=.coveragerc --cov-report= --cov-fail-under=0 tests/unit -k test_otel_span_exists_both_django_and_flask
F                                                                                                                                                                                                                                 [100%]
=============================================================================================================== FAILURES ================================================================================================================
___________________________________________________________________________________ Test_get_request_data.test_otel_span_exists_both_django_and_flask ___________________________________________________________________________________

self = <tests.unit.handlers.test__helpers.Test_get_request_data testMethod=test_otel_span_exists_both_django_and_flask>

    def test_otel_span_exists_both_django_and_flask(self):
        django_expected = (
            _DJANGO_HTTP_REQUEST,
            _DJANGO_TRACE_ID,
            _DJANGO_SPAN_ID,
            False,
        )
        flask_expected = (_FLASK_HTTP_REQUEST, _FLASK_TRACE_ID, _FLASK_SPAN_ID, False)
    
>       with _setup_otel_span_context():

tests/unit/handlers/test__helpers.py:428: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../../.pyenv/versions/3.7.16/lib/python3.7/contextlib.py:112: in __enter__
    return next(self.gen)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    @contextlib.contextmanager
    def _setup_otel_span_context():
        """Sets up a nonrecording OpenTelemetry span with a mock span context that gets returned
        by opentelemetry.trace.get_current_span, and returns it as a contextmanager
        """
        span_context = opentelemetry.trace.SpanContext(
            _OTEL_SPAN_CONTEXT_TRACE_ID,
            _OTEL_SPAN_CONTEXT_SPAN_ID,
            False,
            trace_flags=_OTEL_SPAN_CONTEXT_TRACEFLAGS,
        )
        ctx = opentelemetry.trace.set_span_in_context(NonRecordingSpan(span_context))
>       tracer = opentelemetry.trace.NoOpTracer()
E       AttributeError: module 'opentelemetry.trace' has no attribute 'NoOpTracer'

tests/unit/handlers/__init__.py:48: AttributeError
------------------------------------------------------------------- generated xml file: /usr/local/google/home/partheniou/git/python-logging/unit_3.7_sponge_log.xml --------------------------------------------------------------------
======================================================================================================== short test summary info ========================================================================================================
FAILED tests/unit/handlers/test__helpers.py::Test_get_request_data::test_otel_span_exists_both_django_and_flask - AttributeError: module 'opentelemetry.trace' has no attribute 'NoOpTracer'
1 failed, 1299 deselected in 2.13s
nox > Command py.test --quiet --junitxml=unit_3.7_sponge_log.xml --cov=google --cov=tests/unit --cov-append --cov-config=.coveragerc --cov-report= --cov-fail-under=0 tests/unit -k test_otel_span_exists_both_django_and_flask failed with exit code 1

@parthea
Copy link
Copy Markdown
Contributor Author

parthea commented Aug 15, 2024

google-cloud-appengine-logging>=0.1.3 is needed to resolve this diamond dependency issue related to google-api-core 2.x where older versions of google-cloud-appengine-logging require google-api-core 1.x

The conflict is caused by:
    google-cloud-logging 3.11.1 depends on google-api-core!=2.0.*, !=2.1.*, !=2.10.*, !=2.2.*, !=2.3.*, !=2.4.*, !=2.5.*, !=2.6.*, !=2.7.*, !=2.8.*, !=2.9.*, <3.0.0dev and >=1.34.1
    google-api-core[grpc] 2.14.0 depends on google-api-core 2.14.0 (from https://files.pythonhosted.org/packages/c4/1e/924dcad4725d2e697888e044edf7a433db84bf9a3e40d3efa38ba859d0ce/google_api_core-2.14.0-py3-none-any.whl (from https://pypi.org/simple/google-api-core/) (requires-python:>=3.7))
    google-cloud-appengine-logging 0.1.0 depends on google-api-core<2.0.0dev and >=1.22.2
    The user requested (constraint) google-api-core==2.14.0

@parthea
Copy link
Copy Markdown
Contributor Author

parthea commented Aug 15, 2024

This is a similar stack trace to what we see in #934 (comment) but with protobuf 4.x instead of 5.x. If we bump the minimum version of google-cloud-audit-log we should be able to solve it for protobuf 4.x. For protobuf 5.x support, we're waiting on googleapis/python-audit-log#147

nox > Running session unit-3.8(protobuf_implementation='upb')
nox > Creating virtual environment (virtualenv) using python3.8 in .nox/unit-3-8-protobuf_implementation-upb
nox > python -m pip install mock asyncmock pytest pytest-cov pytest-asyncio -c /usr/local/google/home/partheniou/git/python-logging/testing/constraints-3.8.txt
nox > python -m pip install flask webob django -c /usr/local/google/home/partheniou/git/python-logging/testing/constraints-3.8.txt
nox > python -m pip install -e . -c /usr/local/google/home/partheniou/git/python-logging/testing/constraints-3.8.txt
nox > py.test --quiet --junitxml=unit_3.8_sponge_log.xml --cov=google --cov=tests/unit --cov-append --cov-config=.coveragerc --cov-report= --cov-fail-under=0 tests/unit

================================================================================================================ ERRORS =================================================================================================================
________________________________________________________________________________ ERROR collecting tests/unit/gapic/logging_v2/test_config_service_v2.py _________________________________________________________________________________
tests/unit/gapic/logging_v2/test_config_service_v2.py:46: in <module>
    from google.cloud.logging_v2.services.config_service_v2 import (
google/cloud/logging_v2/__init__.py:21: in <module>
    from google.cloud.logging_v2.client import Client
google/cloud/logging_v2/client.py:25: in <module>
    from google.cloud.logging_v2._helpers import _add_defaults_to_filter
google/cloud/logging_v2/_helpers.py:25: in <module>
    from google.cloud.logging_v2.entries import LogEntry
google/cloud/logging_v2/entries.py:31: in <module>
    import google.cloud.audit.audit_log_pb2  # noqa: F401
.nox/unit-3-8-protobuf_implementation-upb/lib/python3.8/site-packages/google/cloud/audit/audit_log_pb2.py:62: in <module>
    _descriptor.FieldDescriptor(
.nox/unit-3-8-protobuf_implementation-upb/lib/python3.8/site-packages/google/protobuf/descriptor.py:560: in __new__
    _message.Message._CheckCalledFromGeneratedFile()
E   TypeError: Descriptors cannot not be created directly.
E   If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
E   If you cannot immediately regenerate your protos, some other possible workarounds are:
E    1. Downgrade the protobuf package to 3.20.x or lower.
E    2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).
E   
E   More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates

@parthea
Copy link
Copy Markdown
Contributor Author

parthea commented Aug 15, 2024

google-cloud-audit-log >= 0.2.2 is the version that solves #935 (comment) but google-cloud-audit-log >= 0.2.4 is the first version of google-cloud-audit-log which supports protobuf 4.x .

@parthea parthea marked this pull request as ready for review August 15, 2024 16:27
@parthea parthea requested a review from a team as a code owner August 15, 2024 16:27
@parthea parthea requested review from a team and daniel-sanche August 15, 2024 16:27
@parthea parthea assigned gkevinzheng and unassigned triplequark Aug 15, 2024
@gkevinzheng gkevinzheng merged commit 550abca into main Aug 15, 2024
@gkevinzheng gkevinzheng deleted the update-constraints branch August 15, 2024 20:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api: logging Issues related to the googleapis/python-logging API. size: m Pull request size is medium.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants