From 4c6b7ad195c78e99430afc4501d3d80c939f8a63 Mon Sep 17 00:00:00 2001 From: Oleg Ovcharuk Date: Mon, 8 Jul 2024 18:40:42 +0300 Subject: [PATCH 1/2] Move draft imports to draft folder --- ydb/_apis.py | 24 ------------------------ ydb/draft/_apis.py | 29 +++++++++++++++++++++++++++++ ydb/draft/dynamic_config.py | 3 ++- 3 files changed, 31 insertions(+), 25 deletions(-) create mode 100644 ydb/draft/_apis.py diff --git a/ydb/_apis.py b/ydb/_apis.py index bd455838..12610fe9 100644 --- a/ydb/_apis.py +++ b/ydb/_apis.py @@ -12,10 +12,6 @@ ydb_topic_v1_pb2_grpc, ) - from ._grpc.v4.draft import ( - ydb_dynamic_config_v1_pb2_grpc, - ) - from ._grpc.v4.protos import ( ydb_status_codes_pb2, ydb_discovery_pb2, @@ -26,9 +22,6 @@ ydb_common_pb2, ) - from ._grpc.v4.draft.protos import ( - ydb_dynamic_config_pb2, - ) else: from ._grpc.common import ( ydb_cms_v1_pb2_grpc, @@ -39,10 +32,6 @@ ydb_topic_v1_pb2_grpc, ) - from ._grpc.common.draft import ( - ydb_dynamic_config_v1_pb2_grpc, - ) - from ._grpc.common.protos import ( ydb_status_codes_pb2, ydb_discovery_pb2, @@ -53,10 +42,6 @@ ydb_common_pb2, ) - from ._grpc.common.draft.protos import ( - ydb_dynamic_config_pb2, - ) - StatusIds = ydb_status_codes_pb2.StatusIds FeatureFlag = ydb_common_pb2.FeatureFlag @@ -127,12 +112,3 @@ class TopicService(object): DropTopic = "DropTopic" StreamRead = "StreamRead" StreamWrite = "StreamWrite" - - -class DynamicConfigService(object): - Stub = ydb_dynamic_config_v1_pb2_grpc.DynamicConfigServiceStub - - ReplaceConfig = "ReplaceConfig" - SetConfig = "SetConfig" - GetConfig = "GetConfig" - GetNodeLabels = "GetNodeLabels" diff --git a/ydb/draft/_apis.py b/ydb/draft/_apis.py new file mode 100644 index 00000000..f42ef290 --- /dev/null +++ b/ydb/draft/_apis.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +import typing + +# Workaround for good IDE and universal for runtime +if typing.TYPE_CHECKING: + from .._grpc.v4.draft import ( + ydb_dynamic_config_v1_pb2_grpc, + ) + + from .._grpc.v4.draft.protos import ( + ydb_dynamic_config_pb2, + ) +else: + from .._grpc.common.draft import ( + ydb_dynamic_config_v1_pb2_grpc, + ) + + from .._grpc.common.draft.protos import ( + ydb_dynamic_config_pb2, + ) + + +class DynamicConfigService(object): + Stub = ydb_dynamic_config_v1_pb2_grpc.DynamicConfigServiceStub + + ReplaceConfig = "ReplaceConfig" + SetConfig = "SetConfig" + GetConfig = "GetConfig" + GetNodeLabels = "GetNodeLabels" diff --git a/ydb/draft/dynamic_config.py b/ydb/draft/dynamic_config.py index afec19ec..4648b29a 100644 --- a/ydb/draft/dynamic_config.py +++ b/ydb/draft/dynamic_config.py @@ -1,6 +1,7 @@ import abc from abc import abstractmethod -from .. import issues, operation, _apis +from . import _apis +from .. import issues, operation class IDynamicConfigClient(abc.ABC): From a5bdfe8fef0d2aedaf6ec411bf84d89ae6291fed Mon Sep 17 00:00:00 2001 From: Oleg Ovcharuk Date: Mon, 8 Jul 2024 18:45:00 +0300 Subject: [PATCH 2/2] style fixes --- ydb/_apis.py | 1 - ydb/draft/_apis.py | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ydb/_apis.py b/ydb/_apis.py index 12610fe9..8c0b1164 100644 --- a/ydb/_apis.py +++ b/ydb/_apis.py @@ -51,7 +51,6 @@ ydb_table = ydb_table_pb2 ydb_discovery = ydb_discovery_pb2 ydb_operation = ydb_operation_pb2 -ydb_dynamic_config = ydb_dynamic_config_pb2 class CmsService(object): diff --git a/ydb/draft/_apis.py b/ydb/draft/_apis.py index f42ef290..5b878677 100644 --- a/ydb/draft/_apis.py +++ b/ydb/draft/_apis.py @@ -20,6 +20,9 @@ ) +ydb_dynamic_config = ydb_dynamic_config_pb2 + + class DynamicConfigService(object): Stub = ydb_dynamic_config_v1_pb2_grpc.DynamicConfigServiceStub