Python backend for image manipulation and processing. Data transmission and communication using gRPC
- Prerequisites
- Generate gRPC Code (Python)
- Run Python server
- Build Python server
- Deploy and start with electron app
- Python > 3.5
- pip > 9.01
- setup a virtual environment and specify an appropriate interpreter
- create run configuration
- for debug purposes: specify environment variables for run config:
GRPC_VERBOSITY=DEBUG
GRPC_TRACE=api,client_channel_routing,cares_resolver
python -m pip install --upgrade pip (need admin rights)
pip install -r requirements.txt // for installing dependencies
pip freeze > requirements.txt // update requirements after after installing new packages- Protos are located in
python/protos - to generate code (
greet_pb2_grpcandgreet_pb2), use the terminal command:
python -m grpc_tools.protoc -I . --python_out=. --grpc_python_out=. ./generated_services/*.proto --pyi_out=.
-
this creates the grpc code in
generated_services/ -
REMARK: python does not allow to generate files in another directory than the proto file (see gitHub discussion)
-
REMARK: the
__pyi_outflag generates metaclasses for message types(see StackOverflow issue). This is not necessary for protobuf to work, but for python auto-completion -
import files using:
from generated_services import greet_pb2, greet_pb2_grpc
open Terminal and run python main.py from inside python folder
server serves on port 50051, defined in main.py
implementation follows example from official documentation
Service is implemented in service/interactionProcessingService.py
TODO: How to build an executable ?
TODO: Deployment / Packaging und auto-(re)start