Online Prediction

This patch allows user to load a Prediction Model
in advance for online prediction.

In online prediction,
user can retrieve a predicted data immediately.

implements blueprint online-prediction

Change-Id: Ic65fb8ba4eabdbd460d1f0c99fa2972cb64f3aa9
This commit is contained in:
Hiroyuki Eguchi 2017-01-07 14:37:33 +09:00
parent 605814a6fd
commit fb749976fa
3 changed files with 35 additions and 1 deletions

View File

@ -148,7 +148,7 @@ class ResourceManager(object):
resp = self.api.post(url, **kwargs)
if resp.status_code != 202:
if resp.status_code != 202 and resp.status_code != 200:
self._raise_api_exception(resp)
if response_key is not None:

View File

@ -70,3 +70,17 @@ class ModelManager(base.ResourceManager):
def delete(self, model_id):
"""Delete a Model Model."""
self._delete('/models/%s' % model_id)
def load(self, model_id):
"""Load a Model."""
url = '/models/%s/action' % model_id
body = {'os-load': None}
self._post(url, body)
def unload(self, model_id):
"""Unload a Model."""
url = '/models/%s/action' % model_id
body = {'os-unload': None}
self._post(url, body)

View File

@ -225,6 +225,10 @@ def do_dataset_delete(cs, args):
#
# model-delete <model_id>
#
# model-load <model_id>
#
# model-unload <model_id>
#
def do_model_list(cs, args):
@ -268,6 +272,22 @@ def do_model_delete(cs, args):
cs.models.delete(args.id)
@utils.arg('id',
metavar='<model_id>',
help='ID of the model to load.')
def do_model_load(cs, args):
"""Load a model for online prediction."""
cs.models.load(args.id)
@utils.arg('id',
metavar='<model_id>',
help='ID of the model to unload.')
def do_model_unload(cs, args):
"""Unload a model."""
cs.models.unload(args.id)
#
# Learnings
# ~~~~~~~~