package eas

import (
	"fmt"
	"testing"

	"gitlab.alibaba-inc.com/pai_biz_arch/pairec/algorithm/eas/tf"
)

func TestTFRequest(t *testing.T) {

	request := &tf.PredictRequest{}

	fv := make([]float32, 1485)
	for k := range fv {
		fv[k] = 0.1
	}

	image := tf.ArrayProto{
		Dtype:      tf.ArrayDataType_DT_FLOAT,
		ArrayShape: &tf.ArrayShape{Dim: []int64{1, 1485}},
		FloatVal:   fv,
	}

	request.Inputs = make(map[string]*tf.ArrayProto)
	request.Inputs["user_feature"] = &image
	/**
	request.Inputs["Placeholder_1"] = &tf.ArrayProto{
		Dtype:      tf.ArrayDataType_DT_FLOAT,
		ArrayShape: &tf.ArrayShape{Dim: []int64{1, 1}},
		FloatVal:   []float32{0.1},
	}
	**/

	req := TFRequest{}
	req.SetUrl("http://1276757891219814.cn-beijing.pai-eas.aliyuncs.com/api/predict/tensorflow_demo4")
	req.SetAuth("ZjNjODNjYzVmZjZlNTRhZGY1ZWFkOWNiMmI3NjEzZmU5OWIwOTM3Yw==")
	req.SetSignatureName("serving_default")
	req.SetTimeout(1000)

	response, err := req.Invoke(request)
	if err != nil {
		t.Error(err)
	}
	fmt.Println(response)
}
