Skip to content

Commit 80fb11a

Browse files
Revert unintended v6 gRPC stub changes.
Restore auto-generated stubs and generate_protoc.py to match main. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 3a583b1 commit 80fb11a

53 files changed

Lines changed: 989 additions & 47 deletions

Some content is hidden

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

generate_protoc.py

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,11 @@
11
import os
22
import pathlib
3-
import re
43
import shutil
54

65
from typing import List
76
from argparse import ArgumentParser
87

9-
_GRPC_VERSION_GATE_RE = re.compile(
10-
r"GRPC_GENERATED_VERSION = '[^']+'\n"
11-
r"GRPC_VERSION = grpc\.__version__\n"
12-
r"_version_not_supported = False\n\n"
13-
r"try:\n"
14-
r" from grpc\._utilities import first_version_is_lower\n"
15-
r" _version_not_supported = first_version_is_lower\(GRPC_VERSION, GRPC_GENERATED_VERSION\)\n"
16-
r"except ImportError:\n"
17-
r" _version_not_supported = True\n\n"
18-
r"if _version_not_supported:\n"
19-
r" raise RuntimeError\(\n"
20-
r"(?: .+\n)+"
21-
r" \)\n"
22-
)
23-
24-
25-
def strip_grpc_version_gate(content: str) -> str:
26-
"""Remove grpcio-tools version gate from generated *_grpc.py stubs."""
27-
updated = _GRPC_VERSION_GATE_RE.sub("", content)
28-
if updated != content:
29-
updated = updated.replace("import warnings\n", "")
30-
return updated
31-
32-
33-
def strip_grpc_version_gate_from_tree(rootdir: str) -> None:
34-
for dirpath, _, fnames in os.walk(rootdir):
35-
for fname in fnames:
36-
if not fname.endswith("_grpc.py"):
37-
continue
38-
39-
path = os.path.join(dirpath, fname)
40-
with open(path, "r+t") as f:
41-
content = f.read()
42-
updated = strip_grpc_version_gate(content)
43-
if updated == content:
44-
continue
45-
f.seek(0)
46-
f.write(updated)
47-
f.truncate()
8+
from grpc_tools import command
489

4910

5011
def files_filter(dir, items: List[str]) -> List[str]:
@@ -95,18 +56,11 @@ def fix_file_contents(rootdir, protobuf_version: str):
9556

9657
# Add ignore style check
9758
content = content.replace("# -*- coding: utf-8 -*-", "# -*- coding: utf-8 -*-\n" + flake_ignore_line)
98-
99-
if fname.endswith("_grpc.py"):
100-
content = strip_grpc_version_gate(content)
101-
10259
f.seek(0)
10360
f.write(content)
104-
f.truncate()
10561

10662

10763
def generate_protobuf(src_proto_dir: str, dst_dir, protobuf_version: str):
108-
from grpc_tools import command
109-
11064
shutil.rmtree(dst_dir, ignore_errors=True)
11165

11266
shutil.copytree(src_proto_dir, dst_dir, ignore=files_filter)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
22
"""Client and server classes corresponding to protobuf-defined services."""
33
import grpc
4+
import warnings
45

56

7+
GRPC_GENERATED_VERSION = '1.72.1'
8+
GRPC_VERSION = grpc.__version__
9+
_version_not_supported = False
10+
11+
try:
12+
from grpc._utilities import first_version_is_lower
13+
_version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION)
14+
except ImportError:
15+
_version_not_supported = True
16+
17+
if _version_not_supported:
18+
raise RuntimeError(
19+
f'The grpc package installed is at version {GRPC_VERSION},'
20+
+ f' but the generated code in draft/protos/ydb_dynamic_config_pb2_grpc.py depends on'
21+
+ f' grpcio>={GRPC_GENERATED_VERSION}.'
22+
+ f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
23+
+ f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
24+
)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
22
"""Client and server classes corresponding to protobuf-defined services."""
33
import grpc
4+
import warnings
45

56

7+
GRPC_GENERATED_VERSION = '1.72.1'
8+
GRPC_VERSION = grpc.__version__
9+
_version_not_supported = False
10+
11+
try:
12+
from grpc._utilities import first_version_is_lower
13+
_version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION)
14+
except ImportError:
15+
_version_not_supported = True
16+
17+
if _version_not_supported:
18+
raise RuntimeError(
19+
f'The grpc package installed is at version {GRPC_VERSION},'
20+
+ f' but the generated code in draft/protos/ydb_federated_query_pb2_grpc.py depends on'
21+
+ f' grpcio>={GRPC_GENERATED_VERSION}.'
22+
+ f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
23+
+ f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
24+
)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
22
"""Client and server classes corresponding to protobuf-defined services."""
33
import grpc
4+
import warnings
45

56

7+
GRPC_GENERATED_VERSION = '1.72.1'
8+
GRPC_VERSION = grpc.__version__
9+
_version_not_supported = False
10+
11+
try:
12+
from grpc._utilities import first_version_is_lower
13+
_version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION)
14+
except ImportError:
15+
_version_not_supported = True
16+
17+
if _version_not_supported:
18+
raise RuntimeError(
19+
f'The grpc package installed is at version {GRPC_VERSION},'
20+
+ f' but the generated code in draft/protos/ydb_keyvalue_pb2_grpc.py depends on'
21+
+ f' grpcio>={GRPC_GENERATED_VERSION}.'
22+
+ f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
23+
+ f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
24+
)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
22
"""Client and server classes corresponding to protobuf-defined services."""
33
import grpc
4+
import warnings
45

56

7+
GRPC_GENERATED_VERSION = '1.72.1'
8+
GRPC_VERSION = grpc.__version__
9+
_version_not_supported = False
10+
11+
try:
12+
from grpc._utilities import first_version_is_lower
13+
_version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION)
14+
except ImportError:
15+
_version_not_supported = True
16+
17+
if _version_not_supported:
18+
raise RuntimeError(
19+
f'The grpc package installed is at version {GRPC_VERSION},'
20+
+ f' but the generated code in draft/protos/ydb_maintenance_pb2_grpc.py depends on'
21+
+ f' grpcio>={GRPC_GENERATED_VERSION}.'
22+
+ f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
23+
+ f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
24+
)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
22
"""Client and server classes corresponding to protobuf-defined services."""
33
import grpc
4+
import warnings
45

56

7+
GRPC_GENERATED_VERSION = '1.72.1'
8+
GRPC_VERSION = grpc.__version__
9+
_version_not_supported = False
10+
11+
try:
12+
from grpc._utilities import first_version_is_lower
13+
_version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION)
14+
except ImportError:
15+
_version_not_supported = True
16+
17+
if _version_not_supported:
18+
raise RuntimeError(
19+
f'The grpc package installed is at version {GRPC_VERSION},'
20+
+ f' but the generated code in draft/protos/ydb_object_storage_pb2_grpc.py depends on'
21+
+ f' grpcio>={GRPC_GENERATED_VERSION}.'
22+
+ f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
23+
+ f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
24+
)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
22
"""Client and server classes corresponding to protobuf-defined services."""
33
import grpc
4+
import warnings
45

56

7+
GRPC_GENERATED_VERSION = '1.72.1'
8+
GRPC_VERSION = grpc.__version__
9+
_version_not_supported = False
10+
11+
try:
12+
from grpc._utilities import first_version_is_lower
13+
_version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION)
14+
except ImportError:
15+
_version_not_supported = True
16+
17+
if _version_not_supported:
18+
raise RuntimeError(
19+
f'The grpc package installed is at version {GRPC_VERSION},'
20+
+ f' but the generated code in draft/protos/ydb_replication_pb2_grpc.py depends on'
21+
+ f' grpcio>={GRPC_GENERATED_VERSION}.'
22+
+ f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
23+
+ f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
24+
)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
22
"""Client and server classes corresponding to protobuf-defined services."""
33
import grpc
4+
import warnings
45

56

7+
GRPC_GENERATED_VERSION = '1.72.1'
8+
GRPC_VERSION = grpc.__version__
9+
_version_not_supported = False
10+
11+
try:
12+
from grpc._utilities import first_version_is_lower
13+
_version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION)
14+
except ImportError:
15+
_version_not_supported = True
16+
17+
if _version_not_supported:
18+
raise RuntimeError(
19+
f'The grpc package installed is at version {GRPC_VERSION},'
20+
+ f' but the generated code in draft/protos/ydb_view_pb2_grpc.py depends on'
21+
+ f' grpcio>={GRPC_GENERATED_VERSION}.'
22+
+ f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
23+
+ f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
24+
)

ydb/_grpc/v6/draft/ydb_dynamic_config_v1_pb2_grpc.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,28 @@
11
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
22
"""Client and server classes corresponding to protobuf-defined services."""
33
import grpc
4+
import warnings
45

56
from ydb._grpc.v6.draft.protos import ydb_dynamic_config_pb2 as draft_dot_protos_dot_ydb__dynamic__config__pb2
67

8+
GRPC_GENERATED_VERSION = '1.72.1'
9+
GRPC_VERSION = grpc.__version__
10+
_version_not_supported = False
11+
12+
try:
13+
from grpc._utilities import first_version_is_lower
14+
_version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION)
15+
except ImportError:
16+
_version_not_supported = True
17+
18+
if _version_not_supported:
19+
raise RuntimeError(
20+
f'The grpc package installed is at version {GRPC_VERSION},'
21+
+ f' but the generated code in draft/ydb_dynamic_config_v1_pb2_grpc.py depends on'
22+
+ f' grpcio>={GRPC_GENERATED_VERSION}.'
23+
+ f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
24+
+ f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
25+
)
726

827

928
class DynamicConfigServiceStub(object):

ydb/_grpc/v6/draft/ydb_federated_query_v1_pb2_grpc.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,28 @@
11
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
22
"""Client and server classes corresponding to protobuf-defined services."""
33
import grpc
4+
import warnings
45

56
from ydb._grpc.v6.draft.protos import ydb_federated_query_pb2 as draft_dot_protos_dot_ydb__federated__query__pb2
67

8+
GRPC_GENERATED_VERSION = '1.72.1'
9+
GRPC_VERSION = grpc.__version__
10+
_version_not_supported = False
11+
12+
try:
13+
from grpc._utilities import first_version_is_lower
14+
_version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION)
15+
except ImportError:
16+
_version_not_supported = True
17+
18+
if _version_not_supported:
19+
raise RuntimeError(
20+
f'The grpc package installed is at version {GRPC_VERSION},'
21+
+ f' but the generated code in draft/ydb_federated_query_v1_pb2_grpc.py depends on'
22+
+ f' grpcio>={GRPC_GENERATED_VERSION}.'
23+
+ f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
24+
+ f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
25+
)
726

827

928
class FederatedQueryServiceStub(object):

0 commit comments

Comments
 (0)