Ejemplo n.º 1
0
def run_send_feedback(args):
    """
    Do a semd-feedback call to the Seldon API

    Parameters
    ----------
    args
       Command line args

    """
    contract = json.load(open(args.contract, "r"))
    contract = unfold_contract(contract)
    sc = get_seldon_client(args)
    if args.grpc:
        transport = "grpc"
    else:
        transport = "rest"

    for i in range(args.n_requests):
        batch = generate_batch(contract, args.batch_size, "features")
        response_predict = sc.predict(data=batch,
                                      deployment_name=args.deployment)
        response_feedback = sc.feedback(
            prediction_request=response_predict.request,
            prediction_response=response_predict.response,
            reward=1.0,
            deployment_name=args.deployment,
            transport=transport,
        )
        if args.prnt:
            print(f"RECEIVED RESPONSE:\n{response_feedback}\n")
Ejemplo n.º 2
0
def run_predict(args):
    """
    Make a prediction call to the Seldon API

    Parameters
    ----------
    args
       Command line args

    """
    contract = json.load(open(args.contract, "r"))
    contract = unfold_contract(contract)
    feature_names = [feature["name"] for feature in contract["features"]]

    sc = get_seldon_client(args)
    if args.grpc:
        transport = "grpc"
    else:
        transport = "rest"
    payload_type = "tensor" if args.tensor else "ndarray"

    for i in range(args.n_requests):
        batch = generate_batch(contract, args.batch_size, "features")
        if args.prnt:
            print(f"{'-' * 40}\nSENDING NEW REQUEST:\n")
            print(batch)
        response_predict = sc.predict(
            data=batch,
            deployment_name=args.deployment,
            names=feature_names,
            payload_type=payload_type,
        )
        if args.prnt:
            print(f"RECEIVED RESPONSE:\n{response_predict.response}\n")
Ejemplo n.º 3
0
def run_predict(args):
    """
    Make a prediction call to the Seldon API
    Parameters
    ----------
    args
       Command line args

    """
    contract = json.load(open(args.contract, 'r'))
    contract = unfold_contract(contract)
    feature_names = [feature["name"] for feature in contract["features"]]

    sc = get_seldon_client(args)
    if args.grpc:
        transport = "grpc"
    else:
        transport = "rest"

    for i in range(args.n_requests):
        batch = generate_batch(contract, args.batch_size, 'features')
        response_predict = sc.predict(data=batch,
                                      deployment_name=args.deployment)
        if args.prnt:
            print("RECEIVED RESPONSE:")
            print(response_predict)
            print()