Преглед на файлове

fix: mypy checks violation in AzureBlobStorage (#13215)

tags/0.15.3
Bowen Liang преди 9 месеца
родител
ревизия
9e1457c2c3
No account linked to committer's email address
променени са 1 файла, в които са добавени 4 реда и са изтрити 2 реда
  1. 4
    2
      api/extensions/storage/azure_blob_storage.py

+ 4
- 2
api/extensions/storage/azure_blob_storage.py Целия файл

from collections.abc import Generator from collections.abc import Generator
from datetime import UTC, datetime, timedelta from datetime import UTC, datetime, timedelta
from typing import Optional


from azure.identity import DefaultAzureCredential
from azure.identity import ChainedTokenCredential, DefaultAzureCredential
from azure.storage.blob import AccountSasPermissions, BlobServiceClient, ResourceTypes, generate_account_sas from azure.storage.blob import AccountSasPermissions, BlobServiceClient, ResourceTypes, generate_account_sas


from configs import dify_config from configs import dify_config
self.account_name = dify_config.AZURE_BLOB_ACCOUNT_NAME self.account_name = dify_config.AZURE_BLOB_ACCOUNT_NAME
self.account_key = dify_config.AZURE_BLOB_ACCOUNT_KEY self.account_key = dify_config.AZURE_BLOB_ACCOUNT_KEY


self.credential: Optional[ChainedTokenCredential] = None
if self.account_key == "managedidentity": if self.account_key == "managedidentity":
self.credential = DefaultAzureCredential() self.credential = DefaultAzureCredential()
else: else:


def _sync_client(self): def _sync_client(self):
if self.account_key == "managedidentity": if self.account_key == "managedidentity":
return BlobServiceClient(account_url=self.account_url, credential=self.credential)
return BlobServiceClient(account_url=self.account_url, credential=self.credential) # type: ignore


cache_key = "azure_blob_sas_token_{}_{}".format(self.account_name, self.account_key) cache_key = "azure_blob_sas_token_{}_{}".format(self.account_name, self.account_key)
cache_result = redis_client.get(cache_key) cache_result = redis_client.get(cache_key)

Loading…
Отказ
Запис