The following examples demonstrate how to create a basic pyansys server/client package following both Google and Ansys's recommendations regarding gRPC.
The main aim of these examples is to demonstrate any Ansys specific tools, packaging, or paradigms designed to make it easier to build, maintain, and deliver services.
For all other documentation, reference the official documentation at gRPC.
Every gRPC service contains a Server and Client with a proto file or files describing the services exposed by the service. This example contains the minimum components necessary to install a greeter service and client package to demonstrate how to package and run a basic service.
-
First, visit the protos directory and follow the instructions there to build the proto package from the example proto files.
-
Install the server within the server directory by following the README there. This relies on the package you built from the previous step; please be sure you installed that.
-
Install the client within the client directory by following the README there. This also relies on the proto package you built from the previous step; please be sure you installed that.
Once you have the server and client installed on your local environment, startup the server with:
python -m ansys.examples.greeter_server
Then, within a different terminal, start the client with:
python -m ansys.examples.greeter_client
If everything worked out, the client should start, connect to the server and print:
Greeter client received: Hello, you!
For further details, see the READMEs within the proto
, server
, or
client
directories.
If you want to just want to run the greeter example without building any of the packages, you can download the source distributions from Releases. Please follow the directions in the release.
Regarding versioning, note that python packages must use semantic
versioning. As the gRPC service version is insuffient, gRPC packages
from auto-generated from the proto files contain an additional
VERSION
file that tracks the semantic version of the service
definition. Please see the documentation and reasoning behind this at
pyansys-protos-generator.