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

Function TestTrainCodegen

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

Source from the content-addressed store, hash-verified

115}
116
117func TestTrainCodegen(t *testing.T) {
118 a := assert.New(t)
119 trainStmt := ir.MockTrainStmt(false)
120
121 os.Setenv("SQLFLOW_OSS_CHECKPOINT_CONFIG", "{\"host\": \"h.com\", \"arn\": \"acs:ram::9527:role\"}")
122 defer os.Unsetenv("SQLFLOW_OSS_CHECKPOINT_CONFIG")
123
124 sess := mockSession()
125 ossModelPath := "iris/sqlflow/my_dnn_model"
126 scriptPath := "file:///tmp/task.tar.gz"
127 paramsPath := "file:///tmp/params.txt"
128 paiTFCode, paiCmd, _, e := Train(trainStmt, sess, scriptPath, paramsPath, "my_dnn_model", ossModelPath, "", "")
129 a.NoError(e)
130
131 tfCode, err := tensorflow.Train(trainStmt, sess)
132 a.NoError(err)
133
134 a.True(strings.Contains(paiTFCode, tfCode))
135 a.True(hasExportedLocal(tfCode))
136 a.False(hasUnknownParameters(paiTFCode, knownTrainParams))
137
138 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/train,odps://iris/tables/test -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)
139 a.Equal(expectedPAICmd, paiCmd)
140}
141
142func TestPredictCodegen(t *testing.T) {
143 a := assert.New(t)

Callers

nothing calls this directly

Calls 6

MockTrainStmtFunction · 0.92
TrainFunction · 0.92
hasExportedLocalFunction · 0.85
hasUnknownParametersFunction · 0.85
mockSessionFunction · 0.70
TrainFunction · 0.70

Tested by

no test coverage detected