Skip to content

Commit 819372f

Browse files
committed
fix(client): fix missing dependencies and unsafe pickle usage
1 parent 2e9a00a commit 819372f

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,11 @@ test:
100100
analysis:
101101
python -m pip install -e .[analysis]
102102

103+
client:
104+
python -m pip install -e .[client]
105+
103106
all:
104-
python -m pip install -e .[pywinpty,dev,lint,docs,package,test,analysis,rl]
107+
python -m pip install -e .[pywinpty,dev,lint,docs,package,test,analysis,rl,client]
105108

106109
install: prerequisite dependencies
107110

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ analysis = [
101101
"plotly",
102102
"statsmodels",
103103
]
104+
client = [
105+
"python-socketio<6",
106+
"tables",
107+
]
104108

105109
# In the process of releasing a new version, when checking the manylinux package with twine, an error is reported:
106110
# InvalidDistribution: Invalid distribution metadata: unrecognized or malformed field 'license-file'

qlib/data/client.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22
# Licensed under the MIT License.
33

44

5-
from __future__ import division
6-
from __future__ import print_function
5+
from __future__ import division, print_function
6+
7+
import json
78

89
import socketio
910

1011
import qlib
12+
1113
from ..config import C
1214
from ..log import get_module_logger
13-
import pickle
1415

1516

1617
class Client:
@@ -96,7 +97,7 @@ def request_callback(*args):
9697
self.logger.debug("connected")
9798
# The pickle is for passing some parameters with special type(such as
9899
# pd.Timestamp)
99-
request_content = {"head": head_info, "body": pickle.dumps(request_content, protocol=C.dump_protocol_version)}
100+
request_content = {"head": head_info, "body": json.dumps(request_content, default=str)}
100101
self.sio.on(request_type + "_response", request_callback)
101102
self.logger.debug("try sending")
102103
self.sio.emit(request_type + "_request", request_content)

0 commit comments

Comments
 (0)