mirror of
https://github.com/langgenius/dify.git
synced 2026-01-14 06:07:33 +08:00
Some checks are pending
Build and Push API & Web / build (api, DIFY_API_IMAGE_NAME, linux/amd64, build-api-amd64) (push) Waiting to run
Build and Push API & Web / build (api, DIFY_API_IMAGE_NAME, linux/arm64, build-api-arm64) (push) Waiting to run
Build and Push API & Web / build (web, DIFY_WEB_IMAGE_NAME, linux/amd64, build-web-amd64) (push) Waiting to run
Build and Push API & Web / build (web, DIFY_WEB_IMAGE_NAME, linux/arm64, build-web-arm64) (push) Waiting to run
Build and Push API & Web / create-manifest (api, DIFY_API_IMAGE_NAME, merge-api-images) (push) Blocked by required conditions
Build and Push API & Web / create-manifest (web, DIFY_WEB_IMAGE_NAME, merge-web-images) (push) Blocked by required conditions
Main CI Pipeline / Check Changed Files (push) Waiting to run
Main CI Pipeline / API Tests (push) Blocked by required conditions
Main CI Pipeline / Web Tests (push) Blocked by required conditions
Main CI Pipeline / Style Check (push) Waiting to run
Main CI Pipeline / VDB Tests (push) Blocked by required conditions
Main CI Pipeline / DB Migration Test (push) Blocked by required conditions
Signed-off-by: -LAN- <laipz8200@outlook.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
34 lines
997 B
Python
34 lines
997 B
Python
import logging
|
|
from functools import lru_cache
|
|
from pathlib import Path
|
|
from typing import Any
|
|
|
|
import yaml # type: ignore
|
|
from yaml import YAMLError
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
def _load_yaml_file(*, file_path: str):
|
|
if not file_path or not Path(file_path).exists():
|
|
raise FileNotFoundError(f"File not found: {file_path}")
|
|
|
|
with open(file_path, encoding="utf-8") as yaml_file:
|
|
try:
|
|
yaml_content = yaml.safe_load(yaml_file)
|
|
return yaml_content
|
|
except Exception as e:
|
|
raise YAMLError(f"Failed to load YAML file {file_path}: {e}") from e
|
|
|
|
|
|
@lru_cache(maxsize=128)
|
|
def load_yaml_file_cached(file_path: str) -> Any:
|
|
"""
|
|
Cached version of load_yaml_file for static configuration files.
|
|
Only use for files that don't change during runtime (e.g., position files)
|
|
|
|
:param file_path: the path of the YAML file
|
|
:return: an object of the YAML content
|
|
"""
|
|
return _load_yaml_file(file_path=file_path)
|