| """gRPC server skeleton for AlphaGeometry using proto/alphageometry.proto. | |
| This is a lightweight skeleton; to run it install grpcio and grpcio-tools and | |
| generate Python stubs from the proto. The server handlers delegate to the | |
| existing Pipeline and UniverseManager implementations. | |
| """ | |
| import os | |
| try: | |
| import grpc | |
| # import generated modules when available | |
| from proto import alphageometry_pb2_grpc as pb2_grpc | |
| from proto import alphageometry_pb2 as pb2 | |
| except Exception: | |
| grpc = None | |
| class AlphaGeometryServicer: | |
| # placeholder methods if proto generated modules available | |
| pass | |
| def serve(port: int = 50051): | |
| if grpc is None: | |
| raise RuntimeError("grpc not installed or generated stubs are missing") | |
| server = grpc.server( | |
| grpc.thread_pool_executor(max_workers=10) | |
| ) | |
| pb2_grpc.add_AlphaGeometryServicer_to_server(AlphaGeometryServicer(), server) | |
| server.add_insecure_port(f"[::]:{port}") | |
| server.start() | |
| try: | |
| server.wait_for_termination() | |
| except KeyboardInterrupt: | |
| server.stop(0) | |