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

Function TestModelFileStore

go/model/model_test.go:74–95  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

72}
73
74func TestModelFileStore(t *testing.T) {
75 a := assert.New(t)
76 ws, dst := mockModelDir(a)
77 defer os.RemoveAll(ws)
78 defer os.RemoveAll(dst)
79 model := &Model{workDir: ws}
80 session := database.GetSessionFromTestingDB()
81 modelURI := fmt.Sprintf("file://%s/model", dst)
82
83 err := model.Save(modelURI, session)
84 a.NoError(err)
85 a.True(file.Exists(path.Join(dst, "model.tar.gz")))
86
87 model, err = Load(modelURI, dst, nil)
88 a.NoError(err)
89 a.True(file.Exists(path.Join(dst, "model.txt")))
90 a.True(file.Exists(path.Join(dst, modelMetaFileName)))
91 meta, err := ioutil.ReadFile(path.Join(dst, modelMetaFileName))
92 a.NoError(err)
93 a.Equal(modelMeta, string(meta))
94 a.Equal("tf.estimator.BoostedTreesClassifier", model.GetMetaAsString("estimator"))
95}
96
97func TestModelDBStore(t *testing.T) {
98 a := assert.New(t)

Callers

nothing calls this directly

Calls 5

SaveMethod · 0.95
GetMetaAsStringMethod · 0.95
GetSessionFromTestingDBFunction · 0.92
mockModelDirFunction · 0.85
LoadFunction · 0.85

Tested by

no test coverage detected