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:
@@ -148,7 +148,7 @@ class ResourceManager(object):
|
|||||||
|
|
||||||
resp = self.api.post(url, **kwargs)
|
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)
|
self._raise_api_exception(resp)
|
||||||
|
|
||||||
if response_key is not None:
|
if response_key is not None:
|
||||||
|
|||||||
@@ -70,3 +70,17 @@ class ModelManager(base.ResourceManager):
|
|||||||
def delete(self, model_id):
|
def delete(self, model_id):
|
||||||
"""Delete a Model Model."""
|
"""Delete a Model Model."""
|
||||||
self._delete('/models/%s' % model_id)
|
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)
|
||||||
|
|||||||
@@ -225,6 +225,10 @@ def do_dataset_delete(cs, args):
|
|||||||
#
|
#
|
||||||
# model-delete <model_id>
|
# model-delete <model_id>
|
||||||
#
|
#
|
||||||
|
# model-load <model_id>
|
||||||
|
#
|
||||||
|
# model-unload <model_id>
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
def do_model_list(cs, args):
|
def do_model_list(cs, args):
|
||||||
@@ -268,6 +272,22 @@ def do_model_delete(cs, args):
|
|||||||
cs.models.delete(args.id)
|
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
|
# Learnings
|
||||||
# ~~~~~~~~
|
# ~~~~~~~~
|
||||||
|
|||||||
Reference in New Issue
Block a user