add aksk check (#5273)
Some checks failed
CE Compile Job / ce_job_pre_check (push) Has been cancelled
CE Compile Job / print_ce_job_pre_check_outputs (push) Has been cancelled
CE Compile Job / FD-Clone-Linux (push) Has been cancelled
CE Compile Job / Show Code Archive Output (push) Has been cancelled
CE Compile Job / BUILD_SM8090 (push) Has been cancelled
CE Compile Job / BUILD_SM8689 (push) Has been cancelled
CE Compile Job / CE_UPLOAD (push) Has been cancelled
Deploy GitHub Pages / deploy (push) Has been cancelled

This commit is contained in:
kevin
2025-11-28 14:28:24 +08:00
committed by GitHub
parent 7bafcf1df3
commit 2d69d91ab8
3 changed files with 87 additions and 3 deletions

View File

@@ -969,13 +969,26 @@ def check_download_links(bos_client, links, timeout=1):
def init_bos_client():
from baidubce.auth.bce_credentials import BceCredentials
from baidubce.bce_client_configuration import BceClientConfiguration
from baidubce.exception import BceHttpClientError, BceServerError
from baidubce.services.bos.bos_client import BosClient
cfg = BceClientConfiguration(
credentials=BceCredentials(envs.ENCODE_FEATURE_BOS_AK, envs.ENCODE_FEATURE_BOS_SK),
endpoint=envs.ENCODE_FEATURE_ENDPOINT,
)
return BosClient(cfg)
try:
client = BosClient(cfg)
client.list_buckets(max_keys=1)
except BceServerError as e:
if e.status_code == 403:
raise Exception("BOS authentication failed: Invalid AK/SK") from e
raise Exception(f"BOS connection failed: {str(e)}") from e
except BceHttpClientError as e:
raise Exception(f"Invalid BOS endpoint configuration: {str(e)}") from e
except Exception as e:
raise Exception(f"BOS client validation error: {str(e)}") from e
return client
def download_from_bos(bos_client, bos_links, retry: int = 0):