Open JonnoFTW opened 8 years ago
@oxtopus @vitaly-krugl Do either of you have any advice about saving OPF models into MySQL?
@JonnoFTW, @rhyolight: assuming a BLOB can accommodate large models that can be upwards of a Gig or more (uncompressed): an OPF model has the save(...)
method for saving a model to a specified directory in the filesystem. For example, see https://github.com/numenta/numenta-apps/blob/1a1e2bea770b94577a175f21e4441fa6212a7b05/htmengine/htmengine/model_checkpoint_mgr/model_checkpoint_mgr.py#L389-L392. You might then want to tar and compress the directory contents using a fast compression algorithm, such as LZ4, before sending it to the database.
For loading the model, you would get the tar/compressed image from the database, uncompress and un-tar it; then use ModelFactory.loadFromCheckpoint
to load the model into memory like this: https://github.com/numenta/numenta-apps/blob/1a1e2bea770b94577a175f21e4441fa6212a7b05/htmengine/htmengine/model_checkpoint_mgr/model_checkpoint_mgr.py#L465
The models need to be periodically stored in a database using a BLOB (since nupic models can be converted to a string using cPickle).
Code might look something like this:
We also need to take into account the fact that the OPF CLA model needs some extra serialization: https://github.com/numenta/nupic/blob/master/src%2Fnupic%2Fframeworks%2Fopf%2Fclamodel.py?ts=4#L1286-L1306 This data could probably be stored in a second BLOB column.
Basically, I propose the following behaviour (subject to feedback):
GET
,PUSH
orreset
API call is made to a model that is not in memory, the server will attempt to retrieve the model by its GUID from the database and then perform the requested action.Other questions: