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

Method ExecuteExplain

go/executor/pai.go:344–403  ·  view source on GitHub ↗
(cl *ir.ExplainStmt)

Source from the content-addressed store, hash-verified

342}
343
344func (s *paiExecutor) ExecuteExplain(cl *ir.ExplainStmt) error {
345 // TODO(typhoonzero): Do **NOT** create tmp table when the select statement is like:
346 // "SELECT fields,... FROM table"
347 dbName, tableName, err := createTmpTableFromSelect(cl.Select, s.Session.DbConnStr)
348 if err != nil {
349 return err
350 }
351 cl.TmpExplainTable = strings.Join([]string{dbName, tableName}, ".")
352 defer dropTmpTables([]string{cl.TmpExplainTable}, s.Session.DbConnStr)
353
354 ossModelPath, e := getModelPath(cl.ModelName, s.Session)
355 if e != nil {
356 return e
357 }
358
359 currProject, err := database.GetDatabaseName(s.Session.DbConnStr)
360 if err != nil {
361 return err
362 }
363 modelType, estimator, err := getOSSSavedModelType(ossModelPath, currProject)
364 if err != nil {
365 return err
366 }
367 // format resultTable name to "db.table" to let the codegen form a submitting
368 // argument of format "odps://project/tables/table_name"
369 // PAIML do not need to create explain result manually, PAI will
370 // create the result table.
371 if cl.Into != "" && modelType != model.PAIML {
372 resultTableParts := strings.Split(cl.Into, ".")
373 if len(resultTableParts) == 1 {
374 cl.Into = fmt.Sprintf("%s.%s", currProject, cl.Into)
375 }
376 db, err := database.OpenAndConnectDB(s.Session.DbConnStr)
377 if err != nil {
378 return err
379 }
380 defer db.Close()
381 err = createExplainResultTable(db, cl, cl.Into, modelType, estimator)
382 if err != nil {
383 return err
384 }
385 }
386 scriptPath := fmt.Sprintf("file://%s/%s", s.Cwd, tarball)
387 paramsPath := fmt.Sprintf("file://%s/%s", s.Cwd, paramsFile)
388 if err := createPAIHyperParamFile(s.Cwd, paramsFile, ossModelPath); err != nil {
389 return err
390 }
391 expn, e := pai.Explain(cl, s.Session, scriptPath, paramsPath, cl.ModelName, ossModelPath, s.Cwd, modelType)
392 if e != nil {
393 return e
394 }
395
396 if e = s.submitPAITask(expn.Code, expn.PaiCmd, expn.Requirements, estimator); e != nil {
397 return e
398 }
399 if img, e := expn.Draw(); e == nil {
400 s.Writer.Write(Figures{img, ""})
401 }

Callers

nothing calls this directly

Calls 13

submitPAITaskMethod · 0.95
GetDatabaseNameFunction · 0.92
OpenAndConnectDBFunction · 0.92
ExplainFunction · 0.92
createTmpTableFromSelectFunction · 0.85
dropTmpTablesFunction · 0.85
getModelPathFunction · 0.85
getOSSSavedModelTypeFunction · 0.85
createExplainResultTableFunction · 0.85
createPAIHyperParamFileFunction · 0.85
DrawMethod · 0.80
CloseMethod · 0.45

Tested by

no test coverage detected