From 819372f001a05c93dd53dc00b2c21c40b52eec44 Mon Sep 17 00:00:00 2001 From: SunsetWolf Date: Wed, 17 Dec 2025 14:44:07 +0000 Subject: [PATCH] fix(client): fix missing dependencies and unsafe pickle usage --- Makefile | 5 ++++- pyproject.toml | 4 ++++ qlib/data/client.py | 9 +++++---- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 6564c4247..e348ee0fd 100644 --- a/Makefile +++ b/Makefile @@ -100,8 +100,11 @@ test: analysis: python -m pip install -e .[analysis] +client: + python -m pip install -e .[client] + all: - python -m pip install -e .[pywinpty,dev,lint,docs,package,test,analysis,rl] + python -m pip install -e .[pywinpty,dev,lint,docs,package,test,analysis,rl,client] install: prerequisite dependencies diff --git a/pyproject.toml b/pyproject.toml index d8d8c833b..d89edab66 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -101,6 +101,10 @@ analysis = [ "plotly", "statsmodels", ] +client = [ + "python-socketio<6", + "tables", +] # In the process of releasing a new version, when checking the manylinux package with twine, an error is reported: # InvalidDistribution: Invalid distribution metadata: unrecognized or malformed field 'license-file' diff --git a/qlib/data/client.py b/qlib/data/client.py index a9b4b2edf..488f5698e 100644 --- a/qlib/data/client.py +++ b/qlib/data/client.py @@ -2,15 +2,16 @@ # Licensed under the MIT License. -from __future__ import division -from __future__ import print_function +from __future__ import division, print_function + +import json import socketio import qlib + from ..config import C from ..log import get_module_logger -import pickle class Client: @@ -96,7 +97,7 @@ class Client: self.logger.debug("connected") # The pickle is for passing some parameters with special type(such as # pd.Timestamp) - request_content = {"head": head_info, "body": pickle.dumps(request_content, protocol=C.dump_protocol_version)} + request_content = {"head": head_info, "body": json.dumps(request_content, default=str)} self.sio.on(request_type + "_response", request_callback) self.logger.debug("try sending") self.sio.emit(request_type + "_request", request_content)