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

Method ExecutePredict

go/executor/pai.go:300–342  ·  view source on GitHub ↗
(cl *ir.PredictStmt)

Source from the content-addressed store, hash-verified

298}
299
300func (s *paiExecutor) ExecutePredict(cl *ir.PredictStmt) error {
301 // TODO(typhoonzero): Do **NOT** create tmp table when the select statement is like:
302 // "SELECT fields,... FROM table"
303 dbName, tableName, err := createTmpTableFromSelect(cl.Select, s.Session.DbConnStr)
304 if err != nil {
305 return err
306 }
307 cl.TmpPredictTable = strings.Join([]string{dbName, tableName}, ".")
308 defer dropTmpTables([]string{cl.TmpPredictTable}, s.Session.DbConnStr)
309
310 currProject, err := database.GetDatabaseName(s.Session.DbConnStr)
311 if err != nil {
312 return err
313 }
314 // format resultTable name to "db.table" to let the codegen form a submitting
315 // argument of format "odps://project/tables/table_name"
316 resultTableParts := strings.Split(cl.ResultTable, ".")
317 if len(resultTableParts) == 1 {
318 cl.ResultTable = fmt.Sprintf("%s.%s", currProject, cl.ResultTable)
319 }
320 if e := createPredictionResultTable(cl, s.Db, s.Session); e != nil {
321 return e
322 }
323
324 ossModelPath, e := getModelPath(cl.Using, s.Session)
325 if e != nil {
326 return e
327 }
328 modelType, estimator, err := getOSSSavedModelType(ossModelPath, currProject)
329 if err != nil {
330 return err
331 }
332 scriptPath := fmt.Sprintf("file://%s/%s", s.Cwd, tarball)
333 paramsPath := fmt.Sprintf("file://%s/%s", s.Cwd, paramsFile)
334 if err := createPAIHyperParamFile(s.Cwd, paramsFile, ossModelPath); err != nil {
335 return err
336 }
337 code, paiCmd, requirements, e := pai.Predict(cl, s.Session, scriptPath, paramsPath, cl.Using, ossModelPath, s.Cwd, modelType)
338 if e != nil {
339 return e
340 }
341 return s.submitPAITask(code, paiCmd, requirements, estimator)
342}
343
344func (s *paiExecutor) ExecuteExplain(cl *ir.ExplainStmt) error {
345 // TODO(typhoonzero): Do **NOT** create tmp table when the select statement is like:

Callers

nothing calls this directly

Calls 9

submitPAITaskMethod · 0.95
GetDatabaseNameFunction · 0.92
PredictFunction · 0.92
createTmpTableFromSelectFunction · 0.85
dropTmpTablesFunction · 0.85
getModelPathFunction · 0.85
getOSSSavedModelTypeFunction · 0.85
createPAIHyperParamFileFunction · 0.85

Tested by

no test coverage detected