mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-12-24 13:28:13 +08:00
add checker (#4711)
This commit is contained in:
@@ -944,6 +944,37 @@ def get_logger(name, file_name=None, without_formater=False, print_to_console=Fa
|
||||
return FastDeployLogger().get_logger(name, file_name, without_formater, print_to_console)
|
||||
|
||||
|
||||
def check_download_links(bos_client, links, timeout=1):
|
||||
"""
|
||||
check bos download links
|
||||
"""
|
||||
for link in links:
|
||||
try:
|
||||
if link.startswith("bos://"):
|
||||
link = link.replace("bos://", "")
|
||||
|
||||
bucket_name = "/".join(link.split("/")[1:-1])
|
||||
object_key = link.split("/")[-1]
|
||||
response = bos_client.get_object_meta_data(bucket_name, object_key)
|
||||
assert (
|
||||
int(response.metadata.content_length) > 0
|
||||
), f"bos download length error, {response.metadata.content_length}"
|
||||
except Exception as e:
|
||||
return f"link {link} download error: {str(e)}"
|
||||
return None
|
||||
|
||||
|
||||
def init_bos_client():
|
||||
from baidubce.auth.bce_credentials import BceCredentials
|
||||
from baidubce.bce_client_configuration import BceClientConfiguration
|
||||
from baidubce.services.bos.bos_client import BosClient
|
||||
|
||||
cfg = BceClientConfiguration(
|
||||
credentials=BceCredentials(envs.ENCODE_FEATURE_BOS_AK, envs.ENCODE_FEATURE_BOS_SK), endpoint="bj.bcebos.com"
|
||||
)
|
||||
return BosClient(cfg)
|
||||
|
||||
|
||||
llm_logger = get_logger("fastdeploy", "fastdeploy.log")
|
||||
data_processor_logger = get_logger("data_processor", "data_processor.log")
|
||||
scheduler_logger = get_logger("scheduler", "scheduler.log")
|
||||
|
||||
Reference in New Issue
Block a user