loadModelFromDB reads from the given sqlfs table for the train select statement, and unzip the SQLFlow working directory, which contains the TensorFlow model, into directory cwd if cwd is not "".
(db *database.DB, table, cwd string)
| 252 | // statement, and unzip the SQLFlow working directory, which contains |
| 253 | // the TensorFlow model, into directory cwd if cwd is not "". |
| 254 | func loadModelFromDB(db *database.DB, table, cwd string) (*Model, error) { |
| 255 | unzipModel := cwd != "" |
| 256 | if cwd == "" { |
| 257 | var err error |
| 258 | if cwd, err = ioutil.TempDir("/tmp", "sqlflow_models"); err != nil { |
| 259 | return nil, err |
| 260 | } |
| 261 | defer os.RemoveAll(cwd) |
| 262 | } |
| 263 | tarFile, err := DumpDBModel(db, table, cwd) |
| 264 | if err != nil { |
| 265 | return nil, err |
| 266 | } |
| 267 | if !unzipModel { |
| 268 | return ExtractMetaFromTarball(tarFile, cwd) |
| 269 | } |
| 270 | return loadTar(path.Dir(tarFile), path.Base(tarFile), cwd) |
| 271 | } |
| 272 | |
| 273 | // DumpDBModel dumps a model tarball from database to local |
| 274 | // file system and return the file name |
no test coverage detected