Skip to content

Commit e21cac4

Browse files
author
Venu
authored
Merge pull request #102 from deep-compute/remove_pickle_protocol
Removing support of pickle protocol
2 parents 9621f67 + d5ea0f7 commit e21cac4

File tree

6 files changed

+8
-43
lines changed

6 files changed

+8
-43
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ deploy:
99
- LICENSE
1010
- kwikapi/api.py
1111
- kwikapi/__init__.py
12-
name: kwikapi-0.5.13
13-
tag_name: 0.5.13
12+
name: kwikapi-0.5.14
13+
tag_name: 0.5.14
1414
true:
1515
repo: deep-compute/kwikapi
1616
- provider: pypi

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ $ wget "http://localhost:8888/api/v1/streaming_request_test" --post-file /tmp/nu
425425
```
426426

427427
### Protocol handling
428-
KwikAPI supports JSON, Messagepack, Pickle and Numpy protocols
428+
KwikAPI supports JSON, Messagepack and Numpy protocols
429429

430430
#### KwikAPI also supports custom protocols instead of using existing protocols
431431
```python
@@ -513,7 +513,6 @@ ex:
513513
```bash
514514
$ wget "http://localhost:8888/api/v1/add" --header="X-KwikAPI-Protocol: messagepack" --post-file /tmp/data.msgpack
515515
$ wget "http://localhost:8888/api/v1/subtract" --header="X-KwikAPI-Protocol: json" --post-data '{"a": 10, "b": 20}'
516-
$ wget "http://localhost:8888/api/v1/add" --header="X-KwikAPI-Protocol: pickle" --post-file /tmp/data.pickle
517516
$ wget "http://localhost:8888/api/v1/add" --header="X-KwikAPI-Protocol: numpy" --post-file /tmp/data.numpy
518517
$ wget "http://localhost:8888/api/v1/add?a=10&b=20" --header="X-KwikAPI-Protocol: raw"
519518
```
@@ -612,7 +611,7 @@ print(c.namespace.add(a=10, b=10))
612611

613612
# Parameters can be changed that are passed to the Client object
614613

615-
print(c(version='v2', protocol='pickle').namespace.add(a=10, b=10))
614+
print(c(version='v2', protocol='messagepack').namespace.add(a=10, b=10))
616615
```
617616

618617
Streaming response is handled by passing the parameter `stream` as True.

kwikapi/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from .api import MockRequest, BaseRequest, BaseResponse, Request
33

44
from .protocols import BaseProtocol, JsonProtocol, MessagePackProtocol
5-
from .protocols import PickleProtocol, NumpyProtocol
5+
from .protocols import NumpyProtocol
66
from .protocols import PROTOCOLS
77

88
from .client import Client, DNSCache

kwikapi/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def map_url(self, url):
4343

4444

4545
class Client:
46-
DEFAULT_PROTOCOL = "pickle"
46+
DEFAULT_PROTOCOL = "messagepack"
4747

4848
def __init__(
4949
self,

kwikapi/protocols.py

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import ast
22
import abc
33
import json
4-
import pickle
54
import msgpack
65
import numpy as np
76

@@ -42,7 +41,6 @@ def should_wrap():
4241
While returning the response the,
4342
kwikapi will wrap the response as -
4443
{success: value, result: value}
45-
4644
This method, can used in above situation,
4745
if no wrapping is required,
4846
override this method in the protocol class.
@@ -107,32 +105,6 @@ def get_mime_type():
107105
return "application/x-msgpack"
108106

109107

110-
class PickleProtocol(BaseProtocol):
111-
@staticmethod
112-
def get_name():
113-
return "pickle"
114-
115-
@staticmethod
116-
def serialize(data):
117-
return pickle.dumps(data)
118-
119-
@staticmethod
120-
def deserialize(data):
121-
return pickle.loads(data)
122-
123-
@classmethod
124-
def deserialize_stream(cls, data):
125-
raise StreamingNotSupported(cls.get_name())
126-
127-
@classmethod
128-
def get_record_separator(cls):
129-
raise StreamingNotSupported(cls.get_name())
130-
131-
@staticmethod
132-
def get_mime_type():
133-
return "application/pickle"
134-
135-
136108
class RawProtocol(BaseProtocol):
137109
@staticmethod
138110
def get_name():
@@ -227,13 +199,7 @@ def get_mime_type():
227199

228200
PROTOCOLS = dict(
229201
(p.get_name(), p)
230-
for p in [
231-
JsonProtocol,
232-
MessagePackProtocol,
233-
PickleProtocol,
234-
NumpyProtocol,
235-
RawProtocol,
236-
]
202+
for p in [RawProtocol, JsonProtocol, NumpyProtocol, MessagePackProtocol]
237203
)
238204

239205
DEFAULT_PROTOCOL = JsonProtocol.get_name()

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from setuptools import setup, find_packages
22

3-
version = "0.5.13"
3+
version = "0.5.14"
44
setup(
55
name="kwikapi",
66
version=version,

0 commit comments

Comments
 (0)