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

Function Load

go/model/model.go:96–118  ·  view source on GitHub ↗

Load unzip a saved model to a directory on the local filesystem. When dst=="", we do not unzip model data, just extract the model meta

(modelURI, dst string, db *database.DB)

Source from the content-addressed store, hash-verified

94// Load unzip a saved model to a directory on the local filesystem.
95// When dst=="", we do not unzip model data, just extract the model meta
96func Load(modelURI, dst string, db *database.DB) (*Model, error) {
97 // FIXME(typhoonzero): unify arguments with save, use session,
98 // so that can pass oss credentials too.
99 if strings.Contains(modelURI, "://") {
100 uriParts := strings.Split(modelURI, "://")
101 if len(uriParts) == 2 {
102 // oss:// or file://
103 if uriParts[0] == "file" {
104 dir, file := path.Split(uriParts[1])
105 return loadTar(dir, file, dst)
106 } else if uriParts[0] == "oss" {
107 return nil, fmt.Errorf("load model from oss is not supported now")
108 }
109 } else {
110 return nil, fmt.Errorf("error modelURI format: %s", modelURI)
111 }
112 } else if strings.Contains(modelURI, "/") {
113 // general model zoo urls like some-domain.com:port/model_name:tag
114 // download traind model and extract to dst
115 return loadModelFromZoo(modelURI, dst)
116 }
117 return loadModelFromDB(db, modelURI, dst)
118}
119
120func downloadModel(modelZooServerAddr,
121 modelName, modelTag string, tmpFile *os.File) error {

Callers 4

loadModelMetaFunction · 0.92
ExecuteShowTrainMethod · 0.92
TestModelFileStoreFunction · 0.85
TestModelDBStoreFunction · 0.85

Calls 4

loadTarFunction · 0.85
loadModelFromZooFunction · 0.85
loadModelFromDBFunction · 0.85
ErrorfMethod · 0.80

Tested by 2

TestModelFileStoreFunction · 0.68
TestModelDBStoreFunction · 0.68