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

Function loadModelFromDB

go/model/model.go:254–271  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

252// statement, and unzip the SQLFlow working directory, which contains
253// the TensorFlow model, into directory cwd if cwd is not "".
254func 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

Callers 1

LoadFunction · 0.85

Calls 3

DumpDBModelFunction · 0.85
ExtractMetaFromTarballFunction · 0.85
loadTarFunction · 0.85

Tested by

no test coverage detected