# Path: jubakit/base.py
# class BaseService(object):
#   """
#   Service provides an interface to machine learning features.
#   """
# 
#   def __init__(self, host='127.0.0.1', port=9199, cluster='', timeout=0):
#     """
#     Creates a new service that connects to the exsiting server.
#     """
#     self._host = host
#     self._port = port
#     self._cluster = cluster
#     self._timeout = timeout
#     self._embedded = False
#     self._backend = None
# 
#   def __del__(self):
#     # Invoke the backend destructor as fast as possible.
#     self._backend = None
# 
#   @classmethod
#   def name(cls):
#     """
#     Subclasses (Classifier, NearestNeighbor, ... etc.) must override this
#     method and return its service name (classifier, nearest_neighbor, ... etc.)
#     """
#     #return 'classifier'
#     raise NotImplementedError()
# 
#   @classmethod
#   def _client_class(cls):
#     """
#     Subclasses must override this method and return the client class.
#     """
#     #return jubatus.classifier.client.Classifier
#     raise NotImplementedError()
# 
#   @classmethod
#   def _embedded_class(cls):
#     """
#     Subclasses must override this method and return the embedded class.
#     """
#     #return jubatus.embedded.Classifier
#     raise NotImplementedError()
# 
#   @classmethod
#   def run(cls, config, port=None, embedded=False):
#     """
#     Runs a new standalone server or embedded instance and returns the
#     service instance.
#     """
#     if embedded:
#       backend = _ServiceBackendEmbedded(cls._embedded_class(), config)
#       service = cls()
#       service._backend = backend
#       service._embedded = True
#     else:
#       backend = _ServiceBackend(cls.name(), config, port)
#       _logger.info('service %s started on port %d', cls.name(), backend.port)
#       service = cls('127.0.0.1', backend.port)
#       service._backend = backend
#     return service
# 
#   def _client(self):
#     if self._embedded:
#       return self._backend.model
#     return self._client_class()(self._host, self._port, self._cluster, self._timeout)
# 
#   def _shell(self, **kwargs):
#     if self._embedded:
#       raise RuntimeError('embedded service does not support shell')
# 
#     return JubaShell(
#       host=self._host,
#       port=self._port,
#       cluster=self._cluster,
#       service=self.name(),
#       timeout=self._timeout,
#       keepalive=True,
#       **kwargs
#     )
# 
#   def stop(self):
#     """
#     Stops the backend process if exists.
#     """
#     if self._backend is not None:
#       return self._backend.stop()
# 
#   def clear(self):
#     """
#     Clears the model.
#     """
#     if not self._client().clear():
#       raise RuntimeError('failed to clear model')
#     _logger.info('model cleared')
# 
#   def save(self, name, path=None):
#     """
#     Saves the model using `name`.  If `path` is specified, copy the saved
#     model file to local `path`.
#     """
#     self._client().save(name)
#     _logger.info('model saved: %s', name)
#     # TODO copy source from `jubafetch` and make path option work.
# 
#   def load(self, name, path=None):
#     """
#     Loads the model using `name`.  If `path` is specified, copy the model
#     file from local `path` to remote location.
#     """
#     if not self._client().load(name):
#       raise RuntimeError('failed to load model: {0}'.format(name))
#     _logger.info('model loaded: %s', name)
#     # TODO copy source from `jubafetch` and make path option work.
# 
#   def get_status(self):
#     """
#     Returns the status of this server.  In distributed mode, returns statuses
#     of all members.
#     """
#     if self._embedded:
#       return {'127.0.0.1_0': self._backend.get_status()}
#     return self._client().get_status()
# 
#   def shell(self, **kwargs):
#     """
#     Starts an interactive shell session for this service.
#     """
#     self._shell(**kwargs).interact()
# 
#   def __repr__(self):
#     if self._embedded:
#       return '<jubakit: Embedded Service ({0})>'.format(self.name())
#     return '<jubakit: RPC Service ({0}) [{1}@{2}:{3}]{4}>'.format(
#            self.name(), self._cluster, self._host, self._port,
#            ', started by jubakit' if self._backend else '')


from jubakit.base import BaseService
import jubatus
import jubatus.embedded
# -*- coding: utf-8 -*-

"""
*Dumb* Service is a kind of temporary implementations of Services.
They are defined just for convenience.

Unlike *Real* Services (Classifier, Anomaly, ...) which are defined
in each file (classifier.py, anomaly.py, ...), Dumb Services cannot
handle Datasets and Schemas.

Each service has a field called ``CONFIG``, which provides a default
config data structure for the service.  So you can use jubakit to start
a Jubatus server processe, then directly use the raw Client class to
make RPC calls.

  >>> from jubakit.dumb import Stat
  >>> service = Stat.run(Stat.CONFIG)
  >>> client = service._client()
  >>> client.push('x', 12)
"""

from __future__ import absolute_import, division, print_function, unicode_literals




# Path: jubakit/base.py
# class BaseService(object):
#   """
#   Service provides an interface to machine learning features.
#   """
# 
#   def __init__(self, host='127.0.0.1', port=9199, cluster='', timeout=0):
#     """
#     Creates a new service that connects to the exsiting server.
#     """
#     self._host = host
#     self._port = port
#     self._cluster = cluster
#     self._timeout = timeout
#     self._embedded = False
#     self._backend = None
# 
#   def __del__(self):
#     # Invoke the backend destructor as fast as possible.
#     self._backend = None
# 
#   @classmethod
#   def name(cls):
#     """
#     Subclasses (Classifier, NearestNeighbor, ... etc.) must override this
#     method and return its service name (classifier, nearest_neighbor, ... etc.)
#     """
#     #return 'classifier'
#     raise NotImplementedError()
# 
#   @classmethod
#   def _client_class(cls):
#     """
#     Subclasses must override this method and return the client class.
#     """
#     #return jubatus.classifier.client.Classifier
#     raise NotImplementedError()
# 
#   @classmethod
#   def _embedded_class(cls):
#     """
#     Subclasses must override this method and return the embedded class.
#     """
#     #return jubatus.embedded.Classifier
#     raise NotImplementedError()
# 
#   @classmethod
#   def run(cls, config, port=None, embedded=False):
#     """
#     Runs a new standalone server or embedded instance and returns the
#     service instance.
#     """
#     if embedded:
#       backend = _ServiceBackendEmbedded(cls._embedded_class(), config)
#       service = cls()
#       service._backend = backend
#       service._embedded = True
#     else:
#       backend = _ServiceBackend(cls.name(), config, port)
#       _logger.info('service %s started on port %d', cls.name(), backend.port)
#       service = cls('127.0.0.1', backend.port)
#       service._backend = backend
#     return service
# 
#   def _client(self):
#     if self._embedded:
#       return self._backend.model
#     return self._client_class()(self._host, self._port, self._cluster, self._timeout)
# 
#   def _shell(self, **kwargs):
#     if self._embedded:
#       raise RuntimeError('embedded service does not support shell')
# 
#     return JubaShell(
#       host=self._host,
#       port=self._port,
#       cluster=self._cluster,
#       service=self.name(),
#       timeout=self._timeout,
#       keepalive=True,
#       **kwargs
#     )
# 
#   def stop(self):
#     """
#     Stops the backend process if exists.
#     """
#     if self._backend is not None:
#       return self._backend.stop()
# 
#   def clear(self):
#     """
#     Clears the model.
#     """
#     if not self._client().clear():
#       raise RuntimeError('failed to clear model')
#     _logger.info('model cleared')
# 
#   def save(self, name, path=None):
#     """
#     Saves the model using `name`.  If `path` is specified, copy the saved
#     model file to local `path`.
#     """
#     self._client().save(name)
#     _logger.info('model saved: %s', name)
#     # TODO copy source from `jubafetch` and make path option work.
# 
#   def load(self, name, path=None):
#     """
#     Loads the model using `name`.  If `path` is specified, copy the model
#     file from local `path` to remote location.
#     """
#     if not self._client().load(name):
#       raise RuntimeError('failed to load model: {0}'.format(name))
#     _logger.info('model loaded: %s', name)
#     # TODO copy source from `jubafetch` and make path option work.
# 
#   def get_status(self):
#     """
#     Returns the status of this server.  In distributed mode, returns statuses
#     of all members.
#     """
#     if self._embedded:
#       return {'127.0.0.1_0': self._backend.get_status()}
#     return self._client().get_status()
# 
#   def shell(self, **kwargs):
#     """
#     Starts an interactive shell session for this service.
#     """
#     self._shell(**kwargs).interact()
# 
#   def __repr__(self):
#     if self._embedded:
#       return '<jubakit: Embedded Service ({0})>'.format(self.name())
#     return '<jubakit: RPC Service ({0}) [{1}@{2}:{3}]{4}>'.format(
#            self.name(), self._cluster, self._host, self._port,
#            ', started by jubakit' if self._backend else '')


# Path: jubakit/dumb.py
from jubakit.base import BaseService
import jubatus
import jubatus.embedded

# -*- coding: utf-8 -*-

"""
*Dumb* Service is a kind of temporary implementations of Services.
They are defined just for convenience.

Unlike *Real* Services (Classifier, Anomaly, ...) which are defined
in each file (classifier.py, anomaly.py, ...), Dumb Services cannot
handle Datasets and Schemas.

Each service has a field called ``CONFIG``, which provides a default
config data structure for the service.  So you can use jubakit to start
a Jubatus server processe, then directly use the raw Client class to
make RPC calls.

  >>> from jubakit.dumb import Stat
  >>> service = Stat.run(Stat.CONFIG)
  >>> client = service._client()
  >>> client.push('x', 12)
"""

from __future__ import absolute_import, division, print_function, unicode_literals




class Bandit(BaseService):