MCPcopy Create free account
hub / github.com/sql-machine-learning/sqlflow / TestPredictCodegen

Function TestPredictCodegen

go/codegen/pai/codegen_test.go:142–162  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

140}
141
142func TestPredictCodegen(t *testing.T) {
143 a := assert.New(t)
144 ir := ir.MockPredStmt(ir.MockTrainStmt(false))
145
146 os.Setenv("SQLFLOW_OSS_CHECKPOINT_CONFIG", "{\"host\": \"h.com\", \"arn\": \"acs:ram::9527:role\"}")
147 defer os.Unsetenv("SQLFLOW_OSS_CHECKPOINT_CONFIG")
148 sess := mockSession()
149 ossModelPath := "iris/sqlflow/my_dnn_model"
150 scriptPath := "file:///tmp/task.tar.gz"
151 paramsPath := "file:///tmp/params.txt"
152 paiTFCode, paiCmd, _, e := Predict(ir, sess, scriptPath, paramsPath, "my_dnn_model", ossModelPath, "", model.TENSORFLOW)
153 a.NoError(e)
154 a.False(hasUnknownParameters(paiTFCode, knownPredictParams))
155 tfCode, err := tensorflow.Pred(ir, sess)
156 a.NoError(err)
157
158 a.True(hasExportedLocal(tfCode))
159 a.False(hasUnknownParameters(tfCode, knownPredictParams))
160 expectedPAICmd := fmt.Sprintf("pai -name tensorflow1150 -project algo_public_dev -DmaxHungTimeBeforeGCInSeconds=0 -DjobName=sqlflow_my_dnn_model -Dtags=dnn -Dscript=%s -DentryFile=entry.py -Dtables=odps://iris/tables/predict -Doutputs=odps://iris/tables/predict -DhyperParameters=\"%s\" -DcheckpointDir='oss://sqlflow-models/iris/sqlflow/my_dnn_model/?role_arn=acs:ram::9527:role/pai2ossproject&host=h.com' -DgpuRequired='0'", scriptPath, paramsPath)
161 a.Equal(expectedPAICmd, paiCmd)
162}

Callers

nothing calls this directly

Calls 7

MockPredStmtFunction · 0.92
MockTrainStmtFunction · 0.92
PredFunction · 0.92
PredictFunction · 0.85
hasUnknownParametersFunction · 0.85
hasExportedLocalFunction · 0.85
mockSessionFunction · 0.70

Tested by

no test coverage detected