Created
June 10, 2021 01:45
-
-
Save balopat/9d829d7dd0b730f89b5241b3dfb48f86 to your computer and use it in GitHub Desktop.
Generate compatibility matrix for cirq-google protobuf / grpcio-tools
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dataclasses | |
import subprocess | |
import sys | |
import traceback | |
from collections import defaultdict | |
from typing import Dict, Optional | |
grcpio_tools_versions = ["1.26.0","1.27.1","1.28.1","1.30.0","1.31.0","1.32.0","1.33.2","1.34.0","1.35.0","1.36.0","1.37.0","1.38.0"] | |
protobuf_versions = ["3.8.0", "3.9.2", "3.10.0", "3.11.3", "3.12.4", "3.13.0", "3.14.0", "3.15.8", "3.16.0", "3.17.3"] | |
info = dict() | |
@dataclasses.dataclass | |
class CompatibilityMap: | |
grpcio_tools_version: str | |
libprotoc_version: str | |
# None means no error, str is an error | |
protobuf_version_errors: Dict[str, Optional[str]] | |
# ensuring that the Engine API protos import the old format of the resource_pb2, otherwise it will fail | |
subprocess.check_call(f"pip install googleapis-common-protos==1.52.0".split(" ")) | |
for grpcio_tools_version in grcpio_tools_versions: | |
print("=" * 50) | |
print(f"installing grpcio-tools=={grpcio_tools_version}...") | |
subprocess.check_call(f"pip install grpcio-tools=={grpcio_tools_version} --quiet".split(" ")) | |
version = subprocess.check_output([sys.executable, "-m", "grpc_tools.protoc", "--version"]).decode("UTF-8").rstrip()[len("libprotoc "):] | |
print(f"libprotoc version: {version}") | |
subprocess.check_call(f"./dev_tools/build-protos.sh") | |
info[grpcio_tools_version] = CompatibilityMap(grpcio_tools_version, version, defaultdict(lambda: None)) | |
print("--- protobuf testing ---- ") | |
for pb_ver in protobuf_versions: | |
print(f"protobuf version: {pb_ver}") | |
subprocess.check_call(f"pip install protobuf=={pb_ver} --quiet".split(" ")) | |
try: | |
subprocess.check_call([sys.executable, "-c", "import cirq_google"]) | |
print("all good") | |
except BaseException as ex: | |
info[grpcio_tools_version].protobuf_version_errors[pb_ver] = traceback.format_exc() | |
print(f"{pb_ver} issue: {info[grpcio_tools_version].protobuf_version_errors[pb_ver]}") | |
print("--------" * 20) | |
print(";".join(["grpcio_tools_version", "libprotoc"] + ["pbv"+ pbver for pbver in protobuf_versions])) | |
for gtv in grcpio_tools_versions: | |
rec = [gtv, info[gtv].libprotoc_version] | |
rec += [str(info[gtv].protobuf_version_errors[pbv] is None) for pbv in protobuf_versions] | |
print(";".join(rec)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment