예제 #1
0
def unregister(stub, model_name):
    try:
        response = stub.UnregisterModel(management_pb2.UnregisterModelRequest(model_name=model_name))
        print(f"Model {model_name} unregistered successfully")
    except grpc.RpcError as e:
        print(f"Failed to unregister model {model_name}.")
        print(str(e.details()))
        exit(1)
예제 #2
0
def test_inference_apis():
    with open(os.path.dirname(__file__) + inference_data_json, 'rb') as f:
        test_data = json.loads(f.read())

    for item in test_data:
        if item['url'].startswith('{{mar_path_'):
            path = test_utils.mar_file_table[item['url'][2:-2]]
        else:
            path = item['url']

        managment_stub = test_gRPC_utils.get_management_stub()
        response = managment_stub.RegisterModel(
            management_pb2.RegisterModelRequest(url=path,
                                                initial_workers=item['worker'],
                                                synchronous=bool(
                                                    item['synchronous']),
                                                model_name=item['model_name']))

        print(response.msg)

        model_input = os.path.dirname(__file__) + "/../" + item['file']
        prediction = __infer(test_gRPC_utils.get_inference_stub(),
                             item['model_name'], model_input)

        print("Prediction is : ", str(prediction))

        if 'expected' in item:
            try:
                prediction = literal_eval(prediction)
            except SyntaxError:
                pass

            if isinstance(prediction, list) and 'tolerance' in item:
                assert len(prediction) == len(item['expected'])
                for i in range(len(prediction)):
                    assert __get_change(
                        prediction[i], item['expected'][i]) < item['tolerance']
            elif isinstance(prediction, dict) and 'tolerance' in item:
                assert len(prediction) == len(item['expected'])
                for key in prediction:
                    assert __get_change(
                        prediction[key],
                        item['expected'][key]) < item['tolerance']
            else:
                assert str(prediction) == str(item['expected'])

        response = managment_stub.UnregisterModel(
            management_pb2.UnregisterModelRequest(
                model_name=item['model_name'], ))

        print(response.msg)
예제 #3
0
def unregister(stub, model_name):
    response = stub.UnregisterModel(
        management_pb2.UnregisterModelRequest(model_name=model_name))
    return response