mirror of
https://github.com/microsoft/autogen.git
synced 2025-09-04 13:57:42 +00:00
Improve grpc type checking (#5189)
This commit is contained in:
parent
06d5ac332b
commit
1982f1b0ec
35
python/fixup_generated_files.py
Normal file
35
python/fixup_generated_files.py
Normal file
@ -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)
|
@ -2,7 +2,3 @@
|
|||||||
The :mod:`autogen_ext.runtimes.grpc.protos` module provides Google Protobuf classes for agent-worker communication
|
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__)))
|
|
||||||
|
@ -12,7 +12,7 @@ from google.protobuf.internal import builder as _builder
|
|||||||
_sym_db = _symbol_database.Default()
|
_sym_db = _symbol_database.Default()
|
||||||
|
|
||||||
|
|
||||||
import cloudevent_pb2 as cloudevent__pb2
|
from . import cloudevent_pb2 as cloudevent__pb2
|
||||||
from google.protobuf import any_pb2 as google_dot_protobuf_dot_any__pb2
|
from google.protobuf import any_pb2 as google_dot_protobuf_dot_any__pb2
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ isort:skip_file
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import builtins
|
import builtins
|
||||||
import cloudevent_pb2
|
from . import cloudevent_pb2
|
||||||
import collections.abc
|
import collections.abc
|
||||||
import google.protobuf.any_pb2
|
import google.protobuf.any_pb2
|
||||||
import google.protobuf.descriptor
|
import google.protobuf.descriptor
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"""Client and server classes corresponding to protobuf-defined services."""
|
"""Client and server classes corresponding to protobuf-defined services."""
|
||||||
import grpc
|
import grpc
|
||||||
|
|
||||||
import agent_worker_pb2 as agent__worker__pb2
|
from . import agent_worker_pb2 as agent__worker__pb2
|
||||||
|
|
||||||
|
|
||||||
class AgentRpcStub(object):
|
class AgentRpcStub(object):
|
||||||
|
@ -4,7 +4,7 @@ isort:skip_file
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import abc
|
import abc
|
||||||
import agent_worker_pb2
|
from . import agent_worker_pb2
|
||||||
import collections.abc
|
import collections.abc
|
||||||
import grpc
|
import grpc
|
||||||
import grpc.aio
|
import grpc.aio
|
||||||
|
@ -96,7 +96,11 @@ samples-code-check = """pyright ./samples"""
|
|||||||
|
|
||||||
check = ["fmt", "lint", "pyright", "mypy", "test", "markdown-code-lint", "samples-code-check"]
|
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"
|
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"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user