chore: Import cloudpickle Optional

This commit is contained in:
Fangyin Cheng 2024-09-06 09:00:48 +08:00
parent f8ce7d4580
commit 9042ee238d
3 changed files with 34 additions and 7 deletions

View File

@ -36,7 +36,7 @@ def initialize_components(
system_app.register(
DefaultExecutorFactory, max_workers=param.default_thread_pool_size
)
system_app.register(DefaultScheduler)
system_app.register(DefaultScheduler, scheduler_enable=CFG.SCHEDULER_ENABLED)
system_app.register_instance(controller)
system_app.register(ConnectorManager)

View File

@ -2,12 +2,12 @@ import inspect
from io import StringIO
from typing import Any, Dict, Optional, TextIO
import cloudpickle
def check_serializable(
obj: Any, obj_name: str = "Object", error_msg: str = "Object is not serializable"
):
import cloudpickle
try:
cloudpickle.dumps(obj)
except Exception as e:
@ -27,6 +27,8 @@ class SerializabilityInspector:
self.stream.write(f"{indent}{message}\n")
def inspect(self, obj: Any, name: str, depth: int = 3) -> bool:
import cloudpickle
self.log(f"Inspecting '{name}'")
self.indent_level += 1

View File

@ -190,10 +190,15 @@ def get_cpu_avx_support() -> Tuple[OSType, AVXType]:
print("Current platform is windows, use avx2 as default cpu architecture")
elif system == "Linux":
os_type = OSType.LINUX
result = subprocess.run(
["lscpu"], stdout=subprocess.PIPE, stderr=subprocess.PIPE
)
output = result.stdout.decode()
if os.path.exists("/etc/alpine-release"):
# For Alpine, we'll check /proc/cpuinfo directly
with open("/proc/cpuinfo", "r") as f:
output = f.read()
else:
result = subprocess.run(
["lscpu"], stdout=subprocess.PIPE, stderr=subprocess.PIPE
)
output = result.stdout.decode()
elif system == "Darwin":
os_type = OSType.DARWIN
result = subprocess.run(
@ -443,6 +448,7 @@ def core_requires():
"termcolor",
# https://github.com/eosphoros-ai/DB-GPT/issues/551
# TODO: remove pandas dependency
# alpine can't install pandas by default
"pandas==2.0.3",
# numpy should less than 2.0.0
"numpy>=1.21.0,<2.0.0",
@ -459,6 +465,8 @@ def core_requires():
"SQLAlchemy>=2.0.25,<2.0.29",
# for cache
"msgpack",
# for AWEL operator serialization
"cloudpickle",
# for cache
# TODO: pympler has not been updated for a long time and needs to
# find a new toolkit.
@ -500,6 +508,22 @@ def core_requires():
"graphviz",
# For security
"cryptography",
# For high performance RPC communication in code execution
"pyzmq",
]
def code_execution_requires():
"""
pip install "dbgpt[code]"
Code execution dependencies. For building a docker image.
"""
setup_spec.extras["code"] = setup_spec.extras["core"] + [
"pyzmq",
"msgpack",
# for AWEL operator serialization
"cloudpickle",
]
@ -715,6 +739,7 @@ def init_install_requires():
core_requires()
code_execution_requires()
torch_requires()
llama_cpp_requires()
quantization_requires()