From c82699d61aa8842bda17465d47b48ae48cc93d81 Mon Sep 17 00:00:00 2001 From: Gerda Shank Date: Tue, 19 Nov 2024 10:25:20 -0500 Subject: [PATCH] Upgrade protobuf to >=5.0,<6.0 (#219) * upgrade protobuf to >=5,<6 * Run 5.28.3 instead of 5.28.2 * Changie --------- Co-authored-by: Eric Hauser --- .../Under the Hood-20241112-133750.yaml | 6 ++++++ dbt_common/events/base_types.py | 7 +++++-- dbt_common/events/functions.py | 2 +- dbt_common/events/types_pb2.py | 18 ++++++++++++++---- pyproject.toml | 4 ++-- 5 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 .changes/unreleased/Under the Hood-20241112-133750.yaml diff --git a/.changes/unreleased/Under the Hood-20241112-133750.yaml b/.changes/unreleased/Under the Hood-20241112-133750.yaml new file mode 100644 index 00000000..500dac38 --- /dev/null +++ b/.changes/unreleased/Under the Hood-20241112-133750.yaml @@ -0,0 +1,6 @@ +kind: Under the Hood +body: Upgrade protobuf to <=5.0 +time: 2024-11-12T13:37:50.886196-05:00 +custom: + Author: gshank + Issue: "218" diff --git a/dbt_common/events/base_types.py b/dbt_common/events/base_types.py index 781b2a0e..2f11e4c7 100644 --- a/dbt_common/events/base_types.py +++ b/dbt_common/events/base_types.py @@ -91,15 +91,18 @@ def __getattr__(self, key): def to_dict(self): return MessageToDict( - self.pb_msg, preserving_proto_field_name=True, including_default_value_fields=True + self.pb_msg, + preserving_proto_field_name=True, + always_print_fields_with_no_presence=True, ) def to_json(self) -> str: return MessageToJson( self.pb_msg, preserving_proto_field_name=True, - including_default_value_fields=True, + always_print_fields_with_no_presence=True, indent=None, + sort_keys=True, ) def level_tag(self) -> EventLevel: diff --git a/dbt_common/events/functions.py b/dbt_common/events/functions.py index 4e055aa4..86d68237 100644 --- a/dbt_common/events/functions.py +++ b/dbt_common/events/functions.py @@ -97,7 +97,7 @@ def msg_to_dict(msg: EventMsg) -> dict: msg_dict = MessageToDict( msg, preserving_proto_field_name=True, - including_default_value_fields=True, # type: ignore + always_print_fields_with_no_presence=True, ) except Exception as exc: event_type = type(msg).__name__ diff --git a/dbt_common/events/types_pb2.py b/dbt_common/events/types_pb2.py index 6574462e..ed1d5c55 100644 --- a/dbt_common/events/types_pb2.py +++ b/dbt_common/events/types_pb2.py @@ -1,12 +1,22 @@ # -*- coding: utf-8 -*- # Generated by the protocol buffer compiler. DO NOT EDIT! +# NO CHECKED-IN PROTOBUF GENCODE # source: types.proto -# Protobuf Python Version: 4.25.2 +# Protobuf Python Version: 5.28.3 """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, + 3, + '', + 'types.proto' +) # @@protoc_insertion_point(imports) _sym_db = _symbol_database.Default() @@ -20,9 +30,9 @@ _globals = globals() _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'types_pb2', _globals) -if _descriptor._USE_C_DESCRIPTORS == False: - DESCRIPTOR._options = None - _globals['_EVENTINFO_EXTRAENTRY']._options = None +if not _descriptor._USE_C_DESCRIPTORS: + DESCRIPTOR._loaded_options = None + _globals['_EVENTINFO_EXTRAENTRY']._loaded_options = None _globals['_EVENTINFO_EXTRAENTRY']._serialized_options = b'8\001' _globals['_EVENTINFO']._serialized_start=62 _globals['_EVENTINFO']._serialized_end=335 diff --git a/pyproject.toml b/pyproject.toml index 0a601051..5fa7fdd9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,7 +35,7 @@ dependencies = [ "Jinja2>=3.1.3,<4", "mashumaro[msgpack]>=3.9,<4.0", "pathspec>=0.9,<0.13", - "protobuf>=4.0.0,<5.0.0", + "protobuf>=5.0,<6.0", "python-dateutil>=2.0,<3.0", "requests<3.0.0", # needs to match dbt-core "typing-extensions>=4.4,<5.0", @@ -51,7 +51,7 @@ lint = [ "pytest>=7.3,<8.0", # needed for linting tests "types-Jinja2>=2.11,<3.0", "types-jsonschema>=4.17,<5.0", - "types-protobuf>=4.24,<5.0", + "types-protobuf>=5.0,<6.0", "types-python-dateutil>=2.8,<3.0", "types-PyYAML>=6.0,<7.0", "types-requests"