def input_fn()

in script/inference.py [0:0]


def input_fn(request_body, content_type):
    """
    The SageMaker XGBoost model server receives the request data body and the content type,
    and invokes the `input_fn`.

    Return a DMatrix (an object that can be passed to predict_fn).
    """

    if content_type == "text/csv":        
        df = pd.read_csv(StringIO(request_body), header=None)
        X = preprocess.transform(df)
        
        X_csv = StringIO()
        pd.DataFrame(X).to_csv(X_csv, header=False, index=False)
        req_transformed = X_csv.getvalue().replace('\n', '')
                
        return xgb_encoders.csv_to_dmatrix(req_transformed)
    else:
        raise ValueError(
            "Content type {} is not supported.".format(content_type)
        )