A programming framework for agentic AI
Improve grpc type checking (#5189)
Jack Gerrits1982f1b0ec83
diff --git a/python/fixup_generated_files.py b/python/fixup_generated_files.pynew file mode 100644index 000000000..58db7c98b--- /dev/null+++ b/python/fixup_generated_files.py@@ -0,0 +1,35 @@+from pathlib import Path+from typing import Dict++this_file_dir = Path(__file__).parent++files = [+ this_file_dir / "packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos/agent_worker_pb2_grpc.py",+ this_file_dir / "packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos/agent_worker_pb2_grpc.pyi",+ this_file_dir / "packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos/agent_worker_pb2.py",+ this_file_dir / "packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos/agent_worker_pb2.pyi",+ this_file_dir / "packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos/cloudevent_pb2_grpc.py",+ this_file_dir / "packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos/cloudevent_pb2_grpc.pyi",+ this_file_dir / "packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos/cloudevent_pb2.py",+ this_file_dir / "packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos/cloudevent_pb2.pyi",+]++substitutions: Dict[str, str] = {+ "\nimport agent_worker_pb2 as agent__worker__pb2\n": "\nfrom . import agent_worker_pb2 as agent__worker__pb2\n",+ "\nimport agent_worker_pb2\n": "\nfrom . import agent_worker_pb2\n",+ "\nimport cloudevent_pb2 as cloudevent__pb2\n": "\nfrom . import cloudevent_pb2 as cloudevent__pb2\n",+ "\nimport cloudevent_pb2\n": "\nfrom . import cloudevent_pb2\n",+}+++def main():+ for file in files:+ with open(file, "r") as f:+ content = f.read()++ print("Fixing imports in file:", file)+ for old, new in substitutions.items():+ content = content.replace(old, new)++ with open(file, "w") as f:+ f.write(content)diff --git a/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos/__init__.py b/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos/__init__.pyindex b8b57d2f8..0bcd40bf0 100644--- a/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos/__init__.py+++ b/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos/__init__.py@@ -2,7 +2,3 @@The :mod:`autogen_ext.runtimes.grpc.protos` module provides Google Protobuf classes for agent-worker communication"""-import os-import sys--sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))diff --git a/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos/agent_worker_pb2.py b/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos/agent_worker_pb2.pyindex 8744a04a6..37faa08a9 100644--- a/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos/agent_worker_pb2.py+++ b/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos/agent_worker_pb2.py@@ -12,7 +12,7 @@ from google.protobuf.internal import builder as _builder_sym_db = _symbol_database.Default()-import cloudevent_pb2 as cloudevent__pb2+from . import cloudevent_pb2 as cloudevent__pb2from google.protobuf import any_pb2 as google_dot_protobuf_dot_any__pb2diff --git a/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos/agent_worker_pb2.pyi b/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos/agent_worker_pb2.pyiindex 12f1a8728..91625ff79 100644--- a/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos/agent_worker_pb2.pyi+++ b/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos/agent_worker_pb2.pyi@@ -4,7 +4,7 @@ isort:skip_file"""import builtins-import cloudevent_pb2+from . import cloudevent_pb2import collections.abcimport google.protobuf.any_pb2import google.protobuf.descriptordiff --git a/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos/agent_worker_pb2_grpc.py b/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos/agent_worker_pb2_grpc.pyindex 4f5e4cd0a..24c0c633e 100644--- a/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos/agent_worker_pb2_grpc.py+++ b/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos/agent_worker_pb2_grpc.py@@ -2,7 +2,7 @@"""Client and server classes corresponding to protobuf-defined services."""import grpc-import agent_worker_pb2 as agent__worker__pb2+from . import agent_worker_pb2 as agent__worker__pb2class AgentRpcStub(object):diff --git a/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos/agent_worker_pb2_grpc.pyi b/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos/agent_worker_pb2_grpc.pyiindex 2d895360b..ce8a7c12e 100644--- a/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos/agent_worker_pb2_grpc.pyi+++ b/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos/agent_worker_pb2_grpc.pyi@@ -4,7 +4,7 @@ isort:skip_file"""import abc-import agent_worker_pb2+from . import agent_worker_pb2import collections.abcimport grpcimport grpc.aiodiff --git a/python/pyproject.toml b/python/pyproject.tomlindex f3871e662..4ee8bdd57 100644--- a/python/pyproject.toml+++ b/python/pyproject.toml@@ -96,7 +96,11 @@ samples-code-check = """pyright ./samples"""check = ["fmt", "lint", "pyright", "mypy", "test", "markdown-code-lint", "samples-code-check"]-gen-proto = "python -m grpc_tools.protoc --python_out=./packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos --grpc_python_out=./packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos --mypy_out=./packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos --mypy_grpc_out=./packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos --proto_path ../protos/ agent_worker.proto --proto_path ../protos/ cloudevent.proto"+gen-proto = [+ { cmd = "python -m grpc_tools.protoc --python_out=./packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos --grpc_python_out=./packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos --mypy_out=./packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos --mypy_grpc_out=./packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos --proto_path ../protos/ agent_worker.proto --proto_path ../protos/ cloudevent.proto" },+ { script = "fixup_generated_files:main" }+]+gen-proto-samples = "python -m grpc_tools.protoc --python_out=./samples/core_xlang_hello_python_agent/protos --grpc_python_out=./samples/core_xlang_hello_python_agent/protos --mypy_out=./samples/core_xlang_hello_python_agent/protos --mypy_grpc_out=./samples/core_xlang_hello_python_agent/protos --proto_path ../protos/ agent_events.proto"