(t *testing.T)
| 115 | } |
| 116 | |
| 117 | func 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 | |
| 142 | func TestPredictCodegen(t *testing.T) { |
| 143 | a := assert.New(t) |
nothing calls this directly
no test coverage detected