示例#1
0
def run_server(port=5000, learner=None):
    """Run server."""

    logging.info("Listening on port %d" % port)

    web.Application([(r"/", MainHandler)])
    run_server.learner = learner()

    @method
    def reload():
        """Refresh data from the database."""
        # loading data from database
        run_server.learner = learner()

    @method
    def fit(*args, **kwargs):
        """Fit the model."""
        reload()
        # loading data from database
        return run_server.learner.fit(*args, **kwargs)

    @method
    def call(*args, **kwargs):
        return [float(x) for x in run_server.learner(*args, **kwargs)]

    serve(port=port)
            '-test_percent=%f' % (test_percent),
            '-validata_percent=% f' % (validata_percent),
            '-channel_num=%d' % (channel_num),
            '-batch_size=%d' % (batch_size),
            '-lr=%f' % (lr),
            '-epochs=%d' % (epochs),
            '-save_dir=%s' % (save_dir),
            '-model_name=%s' % (model_name),
            '-model_id=%s' % (model_id),
            '-model_userid=%s' % (model_userid),
            '-model_version=%s' % (model_version),
            '-user_Optimizer=%s' % (user_optimizer),
            '-ams_id=%s' % (ams_id),
            '-jsonrpcMlClientPoint=%s' % (jsonrpcMlClientPoint)
        ])
        print('current server ip address', jsonrpcMlClientPoint)
        print("starting executing the python scripts.......")

    except Exception as e:
        print("Unexpected Error: {}".format(e))
    # return a + b
    Codes_path = '/root/Codes/uptest/made_modelApp.py'
    return result


if __name__ == '__main__':
    print("serve is running!!!")
    serve("192.168.144.2", 10073)
    print("serve is stop!")
    print('....')
示例#3
0
"""Using jsonrpcserver's built-in serve() function"""
from jsonrpcserver import method, serve


@method
def ping():
    return "pong"


if __name__ == "__main__":
    serve()
示例#4
0
    script_path =os.path.join('/root/Codes/newServer_kerasTrain/',network_name+'.py')
    # result = os.system('''python /root/Codes/newServer_kerasTrain/made_modelApp.py  -img_src %s -width %d -height %d   -test_percent %f  -validata_percent  %f  -channel_num %d     -batch_size %d -lr %f -epochs %d -save_dir %s  -model_name %s -model_id %s -model_userid %s -model_version %s -user_Optimizer %s  -ams_id  %s -jsonrpcMlClientPoint %s'''%(img_src,width,height,test_percent, validata_percent,channel_num,batch_size,lr,epochs,save_dir,model_name, model_id, model_userid, model_version,user_optimizer,ams_id,jsonrpcMlClientPoint))
    try:
        result = subprocess.call(['''python ''',script_path,'''-img_src %s -width %d -height %d   -test_percent %f  -validata_percent  %f  -channel_num %d     -batch_size %d -lr %f -epochs %d -save_dir %s  -model_name %s -model_id %s -model_userid %s -model_version %s -user_Optimizer %s  -ams_id  %s -jsonrpcMlClientPoint %s'''%(img_src,width,height,test_percent, validata_percent,channel_num,batch_size,lr,epochs,save_dir,model_name, model_id, model_userid, model_version,user_optimizer,ams_id,jsonrpcMlClientPoint)])
    except Exception as e:
        print("Unexpected Error: {}".format(e))




    print('current server ip address',jsonrpcMlClientPoint)
    print("starting executing the python scripts.......")
        #return a + b
    #Codes_path = '/root/Codes/online_train.py'
    Codes_path = '/root/Codes/uptest/made_modelApp.py'
    return  Codes_path


# # Threading HTTP-Server
# http_server = pyjsonrpc.ThreadingHttpServer(
#     server_address=('192.168.10.101', 10073),
#    RequestHandlerClass=RequestHandler
# )
# print("Starting HTTP server ...")
# print("URL: http://192.168.10.101:10073")
# http_server.serve_forever()
if __name__ =='__main__':
    print("serve is running!!!")
    serve("192.168.10.101", 10073)
    rint("serve is stop!")
示例#5
0
    dict_parameters = dict(dict_parameters)
    print("------------ wtf!!!!!---------------")
    print(type(dict_parameters), dict_parameters)
#        img_src = dict_parameters.get('img_src')
#        width = dict_parameters.get("width")
#        height = dict_parameters.get("height")
#        testDataset = dict_parameters.get("testDataset")
#        model_path = dict_parameters.get("model_path")
#        label_path = dict_parameters.get("label_path")
#        print(img_src, width, height, model_path, label_path, testDataset)
#
    try:
        back_testResult = MainApp.resutlApp(dict_parameters)
    except Exception as e:
        print("Unexpected Error: {}".format(e))

    print(back_testResult)
    return back_testResult

# Threading HTTP-Server
# http_server = pyjsonrpc.ThreadingHttpServer(
#     server_address=('192.168.10.101', 10074),
#     RequestHandlerClass=RequestHandler
# )
# print("Starting HTTP server ...")
# print("URL: http://192.168.10.101:10074")
# http_server.serve_forever()

serve('192.168.10.101', 10074)
print("URL: http://192.168.10.101:10074")
        hdfs_label = dict_parameters.get('hdfslabel')
        width = dict_parameters.get("width")
        height = dict_parameters.get("height")
        testDataset = dict_parameters.get("testDataset")
        model_path = dict_parameters.get("model_path")
        label_path = dict_parameters.get("label_path")

        print(network_name, img_src, hdfs_label, width, height, model_path,
              label_path, testDataset)

        back_testResult = MainApp.resutlApp(dict_parameters)

    except Exception as e:
        print("Unexpected Error: {}".format(e))

    print(back_testResult)
    return back_testResult


# Threading HTTP-Server
# http_server = pyjsonrpc.ThreadingHttpServer(
#     server_address=('192.168.10.101', 10074),
#     RequestHandlerClass=RequestHandler
# )
# print("Starting HTTP server ...")
# print("URL: http://192.168.10.101:10074")
# http_server.serve_forever()

serve('192.168.144.2', 10073)
print("URL: http://192.168.144.2:10073")
示例#7
0
 def start(self, port: int):
     jrpc.serve('0.0.0.0', port)
示例#8
0
 def serve_forever(self):
     serve(*self.addr)