A Python gRPC client for Drucker.
Project description
# rekcurd-client
[![Build Status](https://travis-ci.com/rekcurd/drucker-client.svg?branch=master)](https://travis-ci.com/rekcurd/drucker-client)
[![PyPI version](https://badge.fury.io/py/rekcurd-client.svg)](https://badge.fury.io/py/rekcurd-client)
[![codecov](https://codecov.io/gh/rekcurd/drucker-client/branch/master/graph/badge.svg)](https://codecov.io/gh/rekcurd/drucker-client "Non-generated packages only")
[![pypi supported versions](https://img.shields.io/pypi/pyversions/rekcurd-client.svg)](https://pypi.python.org/pypi/rekcurd-client)
Rekcurd client is the project for integrating ML module. Any Rekcurd service is connectable. It can connect the Rekcurd service on Kubernetes.
## Parent Project
https://github.com/rekcurd/drucker-parent
## Components
- [Rekcurd](https://github.com/rekcurd/drucker): Project for serving ML module.
- [Rekcurd-dashboard](https://github.com/rekcurd/drucker-dashboard): Project for managing ML model and deploying ML module.
- [Rekcurd-client](https://github.com/rekcurd/drucker-client) (here): Project for integrating ML module.
## Installation
From source:
```
git clone --recursive https://github.com/rekcurd/drucker-client.git
cd drucker-client
python setup.py install
```
From [PyPi](https://pypi.org/project/rekcurd_client/) directly:
```
pip install rekcurd_client
```
## How to use
Example code is available [here](./example/sample.py).
```python
from drucker_client import DruckerWorkerClient
from drucker_client.logger import logger
host = 'localhost:5000'
client = DruckerWorkerClient(logger=logger, host=host)
input = [0,0,0,1,11,0,0,0,0,0,
0,7,8,0,0,0,0,0,1,13,
6,2,2,0,0,0,7,15,0,9,
8,0,0,5,16,10,0,16,6,0,
0,4,15,16,13,16,1,0,0,0,
0,3,15,10,0,0,0,0,0,2,
16,4,0,0]
response = client.run_predict_arrint_arrint(input)
```
When you use Kubernetes and deploy Rekcurd service via Rekcurd dashboard, you can access your Rekcurd service like the below.
```python
from drucker_client import DruckerWorkerClient
from drucker_client.logger import logger
domain = 'example.com'
app = 'drucker-sample'
env = 'development'
client = DruckerWorkerClient(logger=logger, domain=domain, app=app, env=env)
input = [0,0,0,1,11,0,0,0,0,0,
0,7,8,0,0,0,0,0,1,13,
6,2,2,0,0,0,7,15,0,9,
8,0,0,5,16,10,0,16,6,0,
0,4,15,16,13,16,1,0,0,0,
0,3,15,10,0,0,0,0,0,2,
16,4,0,0]
response = client.run_predict_arrint_arrint(input)
```
### DruckerWorkerClient
You need to use an appropriate method for your Rekcurd service. The methods are generated according to the input and output formats. *V* is the length of feature vector. *M* is the number of classes. If your algorithm is a binary classifier, you set *M* to 1. If your algorithm is a multi-class classifier, you set *M* to the number of classes.
|method |input: data<BR>(required) |input: option |output: label<BR>(required) |output: score<BR>(required) |output: option |
|:---|:---|:---|:---|:---|:---|
|run_predict_string_string |string |string (json) |string |double |string (json) |
|run_predict_string_bytes |string |string (json) |bytes |double |string (json) |
|run_predict_string_arrint |string |string (json) |int[*M*] |double[*M*] |string (json) |
|run_predict_string_arrfloat |string |string (json) |double[*M*] |double[*M*] |string (json) |
|run_predict_string_arrstring |string |string (json) |string[*M*] |double[*M*] |string (json) |
|run_predict_bytes_string |bytes |string (json) |string |double |string (json) |
|run_predict_bytes_bytes |bytes |string (json) |bytes |double |string (json) |
|run_predict_bytes_arrint |bytes |string (json) |int[*M*] |double[*M*] |string (json) |
|run_predict_bytes_arrfloat |bytes |string (json) |double[*M*] |double[*M*] |string (json) |
|run_predict_bytes_arrstring |bytes |string (json) |string[*M*] |double[*M*] |string (json) |
|run_predict_arrint_string |int[*V*] |string (json) |string |double |string (json) |
|run_predict_arrint_bytes |int[*V*] |string (json) |bytes |double |string (json) |
|run_predict_arrint_arrint |int[*V*] |string (json) |int[*M*] |double[*M*] |string (json) |
|run_predict_arrint_arrfloat |int[*V*] |string (json) |double[*M*] |double[*M*] |string (json) |
|run_predict_arrint_arrstring |int[*V*] |string (json) |string[*M*] |double[*M*] |string (json) |
|run_predict_arrfloat_string |double[*V*] |string (json) |string |double |string (json) |
|run_predict_arrfloat_bytes |double[*V*] |string (json) |bytes |double |string (json) |
|run_predict_arrfloat_arrint |double[*V*] |string (json) |int[*M*] |double[*M*] |string (json) |
|run_predict_arrfloat_arrfloat |double[*V*] |string (json) |double[*M*] |double[*M*] |string (json) |
|run_predict_arrfloat_arrstring |double[*V*] |string (json) |string[*M*] |double[*M*] |string (json) |
|run_predict_arrstring_string |string[*V*] |string (json) |string |double |string (json) |
|run_predict_arrstring_bytes |string[*V*] |string (json) |bytes |double |string (json) |
|run_predict_arrstring_arrint |string[*V*] |string (json) |int[*M*] |double[*M*] |string (json) |
|run_predict_arrstring_arrfloat |string[*V*] |string (json) |double[*M*] |double[*M*] |string (json) |
|run_predict_arrstring_arrstring |string[*V*] |string (json) |string[*M*] |double[*M*] |string (json) |
The input "option" field needs to be a json format. Any style is Ok but we have some reserved fields below.
|Field |Type |Description |
|:---|:---|:---|
|suppress_log_input |bool |True: NOT print the input and output to the log message. <BR>False (default): Print the input and output to the log message.
## Unittest
```
$ python -m unittest
```
[![Build Status](https://travis-ci.com/rekcurd/drucker-client.svg?branch=master)](https://travis-ci.com/rekcurd/drucker-client)
[![PyPI version](https://badge.fury.io/py/rekcurd-client.svg)](https://badge.fury.io/py/rekcurd-client)
[![codecov](https://codecov.io/gh/rekcurd/drucker-client/branch/master/graph/badge.svg)](https://codecov.io/gh/rekcurd/drucker-client "Non-generated packages only")
[![pypi supported versions](https://img.shields.io/pypi/pyversions/rekcurd-client.svg)](https://pypi.python.org/pypi/rekcurd-client)
Rekcurd client is the project for integrating ML module. Any Rekcurd service is connectable. It can connect the Rekcurd service on Kubernetes.
## Parent Project
https://github.com/rekcurd/drucker-parent
## Components
- [Rekcurd](https://github.com/rekcurd/drucker): Project for serving ML module.
- [Rekcurd-dashboard](https://github.com/rekcurd/drucker-dashboard): Project for managing ML model and deploying ML module.
- [Rekcurd-client](https://github.com/rekcurd/drucker-client) (here): Project for integrating ML module.
## Installation
From source:
```
git clone --recursive https://github.com/rekcurd/drucker-client.git
cd drucker-client
python setup.py install
```
From [PyPi](https://pypi.org/project/rekcurd_client/) directly:
```
pip install rekcurd_client
```
## How to use
Example code is available [here](./example/sample.py).
```python
from drucker_client import DruckerWorkerClient
from drucker_client.logger import logger
host = 'localhost:5000'
client = DruckerWorkerClient(logger=logger, host=host)
input = [0,0,0,1,11,0,0,0,0,0,
0,7,8,0,0,0,0,0,1,13,
6,2,2,0,0,0,7,15,0,9,
8,0,0,5,16,10,0,16,6,0,
0,4,15,16,13,16,1,0,0,0,
0,3,15,10,0,0,0,0,0,2,
16,4,0,0]
response = client.run_predict_arrint_arrint(input)
```
When you use Kubernetes and deploy Rekcurd service via Rekcurd dashboard, you can access your Rekcurd service like the below.
```python
from drucker_client import DruckerWorkerClient
from drucker_client.logger import logger
domain = 'example.com'
app = 'drucker-sample'
env = 'development'
client = DruckerWorkerClient(logger=logger, domain=domain, app=app, env=env)
input = [0,0,0,1,11,0,0,0,0,0,
0,7,8,0,0,0,0,0,1,13,
6,2,2,0,0,0,7,15,0,9,
8,0,0,5,16,10,0,16,6,0,
0,4,15,16,13,16,1,0,0,0,
0,3,15,10,0,0,0,0,0,2,
16,4,0,0]
response = client.run_predict_arrint_arrint(input)
```
### DruckerWorkerClient
You need to use an appropriate method for your Rekcurd service. The methods are generated according to the input and output formats. *V* is the length of feature vector. *M* is the number of classes. If your algorithm is a binary classifier, you set *M* to 1. If your algorithm is a multi-class classifier, you set *M* to the number of classes.
|method |input: data<BR>(required) |input: option |output: label<BR>(required) |output: score<BR>(required) |output: option |
|:---|:---|:---|:---|:---|:---|
|run_predict_string_string |string |string (json) |string |double |string (json) |
|run_predict_string_bytes |string |string (json) |bytes |double |string (json) |
|run_predict_string_arrint |string |string (json) |int[*M*] |double[*M*] |string (json) |
|run_predict_string_arrfloat |string |string (json) |double[*M*] |double[*M*] |string (json) |
|run_predict_string_arrstring |string |string (json) |string[*M*] |double[*M*] |string (json) |
|run_predict_bytes_string |bytes |string (json) |string |double |string (json) |
|run_predict_bytes_bytes |bytes |string (json) |bytes |double |string (json) |
|run_predict_bytes_arrint |bytes |string (json) |int[*M*] |double[*M*] |string (json) |
|run_predict_bytes_arrfloat |bytes |string (json) |double[*M*] |double[*M*] |string (json) |
|run_predict_bytes_arrstring |bytes |string (json) |string[*M*] |double[*M*] |string (json) |
|run_predict_arrint_string |int[*V*] |string (json) |string |double |string (json) |
|run_predict_arrint_bytes |int[*V*] |string (json) |bytes |double |string (json) |
|run_predict_arrint_arrint |int[*V*] |string (json) |int[*M*] |double[*M*] |string (json) |
|run_predict_arrint_arrfloat |int[*V*] |string (json) |double[*M*] |double[*M*] |string (json) |
|run_predict_arrint_arrstring |int[*V*] |string (json) |string[*M*] |double[*M*] |string (json) |
|run_predict_arrfloat_string |double[*V*] |string (json) |string |double |string (json) |
|run_predict_arrfloat_bytes |double[*V*] |string (json) |bytes |double |string (json) |
|run_predict_arrfloat_arrint |double[*V*] |string (json) |int[*M*] |double[*M*] |string (json) |
|run_predict_arrfloat_arrfloat |double[*V*] |string (json) |double[*M*] |double[*M*] |string (json) |
|run_predict_arrfloat_arrstring |double[*V*] |string (json) |string[*M*] |double[*M*] |string (json) |
|run_predict_arrstring_string |string[*V*] |string (json) |string |double |string (json) |
|run_predict_arrstring_bytes |string[*V*] |string (json) |bytes |double |string (json) |
|run_predict_arrstring_arrint |string[*V*] |string (json) |int[*M*] |double[*M*] |string (json) |
|run_predict_arrstring_arrfloat |string[*V*] |string (json) |double[*M*] |double[*M*] |string (json) |
|run_predict_arrstring_arrstring |string[*V*] |string (json) |string[*M*] |double[*M*] |string (json) |
The input "option" field needs to be a json format. Any style is Ok but we have some reserved fields below.
|Field |Type |Description |
|:---|:---|:---|
|suppress_log_input |bool |True: NOT print the input and output to the log message. <BR>False (default): Print the input and output to the log message.
## Unittest
```
$ python -m unittest
```
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
drucker_client-0.4.5.tar.gz
(20.7 kB
view details)
Built Distribution
File details
Details for the file drucker_client-0.4.5.tar.gz
.
File metadata
- Download URL: drucker_client-0.4.5.tar.gz
- Upload date:
- Size: 20.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe6d4782b47389b8224824c390bf459e9a6000130de37086db6be5ff4d8ba1f2 |
|
MD5 | c72a2d1af47ae3ea984ab7ef6c026c9b |
|
BLAKE2b-256 | 3a0a235cac0febe996630e53365b1da3534259b0a44bd538e5a8dcaced751239 |
File details
Details for the file drucker_client-0.4.5-py2.py3-none-any.whl
.
File metadata
- Download URL: drucker_client-0.4.5-py2.py3-none-any.whl
- Upload date:
- Size: 21.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 66107d5308640d67a7ce10312d72b865dd7f69c3035a8c535049ea07d242d471 |
|
MD5 | 7a0d474b7612d09ac8c11c54a423f7ba |
|
BLAKE2b-256 | 4a4db9c1d3b2370a9af1ded4e467f0cfac01b20404198cff38508b78ce4e08e5 |