Skip to content

Commit f9f2bda

Browse files
committed
generate protobuf from public proto
1 parent 92a0b8e commit f9f2bda

File tree

101 files changed

+7295
-24341
lines changed

Some content is hidden

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

101 files changed

+7295
-24341
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
__pycache__
22
ydb.egg-info/
33
/.idea
4+
/tox
45
/venv
6+
/ydb_certs

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "ydb-api-protos"]
2+
path = ydb-api-protos
3+
url = https://github.com/ydb-platform/ydb-api-protos.git

generate_protoc.py

+45-14
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,53 @@
11
import os
2+
import pathlib
3+
import shutil
4+
from typing import List
5+
26
from grpc_tools import command
37

4-
command.build_package_protos('.')
58

6-
init_files_to_create = []
9+
def files_filter(dir, items: List[str]) -> List[str]:
10+
ignored_dirs = ['protos', '.git']
11+
12+
ignore = []
13+
for item in items:
14+
fullpath = os.path.join(dir, item)
15+
if os.path.isdir(fullpath) and item not in ignored_dirs:
16+
continue
17+
if item.endswith(".proto"):
18+
continue
19+
ignore.append(item)
20+
21+
print("items: ", items)
22+
print("ignore: ", ignore)
23+
return ignore
24+
25+
26+
def create_init_files(dir):
27+
for root, _dirs, _files in os.walk(dir):
28+
init_path = pathlib.Path(os.path.join(root, '__init__.py'))
29+
if not init_path.exists():
30+
init_path.touch()
31+
32+
33+
def replace_protos_dir():
34+
def replace_dir(src, dst):
35+
shutil.rmtree(dst)
36+
shutil.copytree(src, dst, ignore=files_filter)
37+
create_init_files(dst)
38+
39+
replace_dir("ydb-api-protos", "ydb/public/api/grpc")
40+
replace_dir("ydb-api-protos/protos", "ydb/public/api/protos")
741

8-
for root, dirs, files in os.walk('kikimr'):
9-
if '__init__.py' in files:
10-
continue
1142

12-
init_files_to_create.append(
13-
os.path.join(
14-
root,
15-
'__init__.py'
16-
)
17-
)
43+
def remove_protos():
44+
for root, _dirs, files in os.walk("ydb/public/api"):
45+
for file in files:
46+
if file.endswith(".proto"):
47+
os.remove(os.path.join(root, file))
1848

1949

20-
for filename in init_files_to_create:
21-
with open(filename, 'w') as f:
22-
pass
50+
if __name__ == '__main__':
51+
replace_protos_dir()
52+
command.build_package_protos('./ydb/public/api/')
53+
remove_protos()

requirements.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
grpcio==1.38.0
2-
protobuf>3.17.3
1+
grpcio==1.39.0
2+
protobuf>3.17.3,<4.0.0
33
pytest==6.2.4
44
aiohttp==3.7.4

test-requirements.txt

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@ docker==5.0.0
1010
docker-compose==1.29.2
1111
dockerpty==0.4.1
1212
docopt==0.6.2
13-
grpcio>=1.38.0
13+
grpcio==1.39.0
14+
grpcio-tools==1.39.0
1415
idna==3.2
1516
importlib-metadata==4.6.1
1617
iniconfig==1.1.1
1718
jsonschema==3.2.0
1819
packaging==21.0
1920
paramiko==2.10.1
2021
pluggy==0.13.1
21-
protobuf>3.17.3
22+
protobuf>3.17.3,<4.0.0
2223
py==1.10.0
2324
pycparser==2.20
2425
PyNaCl==1.4.0

ydb-api-protos

Submodule ydb-api-protos added at 07b827b

ydb/public/api/grpc/draft/__init__.py

Whitespace-only changes.

ydb/public/api/grpc/draft/dummy_pb2.py

-248
This file was deleted.

0 commit comments

Comments
 (0)