remote_stop.py 730 B

1234567891011121314151617181920212223242526
  1. import argparse
  2. from easyfl.communication import grpc_wrapper
  3. from easyfl.pb import common_pb2 as common_pb
  4. from easyfl.pb import server_service_pb2 as server_pb
  5. parser = argparse.ArgumentParser(description='Federated Server')
  6. parser.add_argument('--server-addr',
  7. type=str,
  8. default="172.18.0.1:23501",
  9. help='Server address')
  10. args = parser.parse_args()
  11. def send_stop_request():
  12. stub = grpc_wrapper.init_stub(grpc_wrapper.TYPE_SERVER, args.server_addr)
  13. response = stub.Stop(server_pb.StopRequest())
  14. if response.status.code == common_pb.SC_OK:
  15. print("Success")
  16. else:
  17. print(response)
  18. if __name__ == '__main__':
  19. send_stop_request()