Skip to content

Commit 343143e

Browse files
committed
generated protobuf
1 parent a945809 commit 343143e

File tree

82 files changed

+204
-356
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+204
-356
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
protobuf:
2+
docker build -f generate-protobuf.Dockerfile . -t ydb-python-sdk-proto-generator-env
3+
docker run --rm -it -v $${PWD}:$${PWD} -w $${PWD} ydb-python-sdk-proto-generator-env python generate_protoc.py

generate-protobuf.Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM python:3.9.15
2+
RUN \
3+
python -m pip install --upgrade pip && \
4+
python -m pip install grpcio==1.39.0 && \
5+
python -m pip install grpclib && \
6+
python -m pip install protobuf==3.20.3 && \
7+
python -m pip install grpcio-tools==1.38.0
8+
9+
ENV PROTOC_VER=21.8
10+
RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VER}/protoc-${PROTOC_VER}-linux-x86_64.zip && \
11+
unzip protoc-*.zip && \
12+
rm -f protoc-*.zip && \
13+
mv bin/protoc /usr/local/bin/protoc && \
14+
mv include well-known-protos

generate_protoc.py

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,43 @@ def files_filter(dir, items: List[str]) -> List[str]:
2323
return ignore
2424

2525

26-
def create_init_files(dir):
27-
for root, _dirs, _files in os.walk(dir):
26+
def create_init_files(rootdirpath: str):
27+
for root, _dirs, _files in os.walk(rootdirpath):
2828
init_path = pathlib.Path(os.path.join(root, '__init__.py'))
2929
if not init_path.exists():
3030
init_path.touch()
3131

3232

33-
def replace_protos_dir():
34-
def replace_dir(src, dst):
35-
shutil.rmtree(dst, ignore_errors=True)
36-
shutil.copytree(src, dst, ignore=files_filter)
37-
create_init_files(dst)
38-
39-
replace_dir("ydb-api-protos", "ydb/_grpc")
40-
41-
42-
def remove_protos():
43-
for root, _dirs, files in os.walk("ydb/public/api"):
33+
def remove_protos(rootdirpath: str):
34+
for root, _dirs, files in os.walk(rootdirpath):
4435
for file in files:
4536
if file.endswith(".proto"):
4637
os.remove(os.path.join(root, file))
4738

4839

40+
def fiximports(rootdir: str):
41+
for dirpath, _, fnames in os.walk(rootdir):
42+
for fname in fnames:
43+
if not fname.endswith(".py"):
44+
continue
45+
46+
with open(os.path.join(dirpath, fname), 'r+t') as f:
47+
content = f.read()
48+
content = content.replace("from protos", "from ydb._grpc.protos")
49+
f.seek(0)
50+
f.write(content)
51+
52+
53+
def generate_protobuf(src_proto_dir: str, dst_dir: str):
54+
shutil.rmtree(dst_dir, ignore_errors=True)
55+
56+
shutil.copytree(src_proto_dir, dst_dir, ignore=files_filter)
57+
create_init_files(dst_dir)
58+
59+
command.build_package_protos(dst_dir)
60+
remove_protos(dst_dir)
61+
fiximports(dst_dir)
62+
63+
4964
if __name__ == '__main__':
50-
replace_protos_dir()
51-
command.build_package_protos("ydb/_grpc")
52-
# remove_protos()
65+
generate_protobuf("ydb-api-protos", "ydb/_grpc")

ydb/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from .settings import * # noqa
88
from .resolver import * # noqa
99
from .export import * # noqa
10-
from .s3list import * # noqa
1110
from .auth_helpers import * # noqa
1211
from .operation import * # noqa
1312
from .scripting import * # noqa
File renamed without changes.

ydb/_grpc/protos/__init__.py

Whitespace-only changes.

ydb/_grpc/protos/annotations/__init__.py

Whitespace-only changes.

ydb/public/api/protos/ydb_auth_pb2.py renamed to ydb/_grpc/protos/ydb_auth_pb2.py

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ydb/public/api/protos/ydb_cms_pb2.py renamed to ydb/_grpc/protos/ydb_cms_pb2.py

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ydb/public/api/protos/ydb_coordination_pb2.py renamed to ydb/_grpc/protos/ydb_coordination_pb2.py

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ydb/public/api/protos/ydb_discovery_pb2.py renamed to ydb/_grpc/protos/ydb_discovery_pb2.py

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ydb/public/api/protos/ydb_export_pb2.py renamed to ydb/_grpc/protos/ydb_export_pb2.py

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ydb/public/api/protos/ydb_import_pb2.py renamed to ydb/_grpc/protos/ydb_import_pb2.py

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ydb/public/api/protos/ydb_monitoring_pb2.py renamed to ydb/_grpc/protos/ydb_monitoring_pb2.py

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ydb/public/api/protos/ydb_operation_pb2.py renamed to ydb/_grpc/protos/ydb_operation_pb2.py

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ydb/public/api/protos/ydb_persqueue_cluster_discovery_pb2.py renamed to ydb/_grpc/protos/ydb_persqueue_cluster_discovery_pb2.py

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ydb/public/api/protos/ydb_persqueue_v1_pb2.py renamed to ydb/_grpc/protos/ydb_persqueue_v1_pb2.py

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ydb/public/api/protos/ydb_rate_limiter_pb2.py renamed to ydb/_grpc/protos/ydb_rate_limiter_pb2.py

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ydb/public/api/protos/ydb_scheme_pb2.py renamed to ydb/_grpc/protos/ydb_scheme_pb2.py

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ydb/public/api/protos/ydb_scripting_pb2.py renamed to ydb/_grpc/protos/ydb_scripting_pb2.py

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ydb/public/api/protos/ydb_table_pb2.py renamed to ydb/_grpc/protos/ydb_table_pb2.py

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ydb/public/api/protos/ydb_topic_pb2.py renamed to ydb/_grpc/protos/ydb_topic_pb2.py

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ydb/public/api/grpc/ydb_auth_v1_pb2.py renamed to ydb/_grpc/ydb_auth_v1_pb2.py

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ydb/public/api/grpc/ydb_auth_v1_pb2_grpc.py renamed to ydb/_grpc/ydb_auth_v1_pb2_grpc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"""Client and server classes corresponding to protobuf-defined services."""
33
import grpc
44

5-
from protos import ydb_auth_pb2 as protos_dot_ydb__auth__pb2
5+
from ydb._grpc.protos import ydb_auth_pb2 as protos_dot_ydb__auth__pb2
66

77

88
class AuthServiceStub(object):

ydb/public/api/grpc/ydb_cms_v1_pb2.py renamed to ydb/_grpc/ydb_cms_v1_pb2.py

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ydb/public/api/grpc/ydb_cms_v1_pb2_grpc.py renamed to ydb/_grpc/ydb_cms_v1_pb2_grpc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"""Client and server classes corresponding to protobuf-defined services."""
33
import grpc
44

5-
from protos import ydb_cms_pb2 as protos_dot_ydb__cms__pb2
5+
from ydb._grpc.protos import ydb_cms_pb2 as protos_dot_ydb__cms__pb2
66

77

88
class CmsServiceStub(object):

0 commit comments

Comments
 (0)