Team Ai
Apppublic

PCNUSMSE/transcript_service

sourceHugging Faceapache-2.0updated 1mo agoView on Hugging Face
0likes
config.cpython-310.pyc50 linesDownload Raw Back to __pycache__
1o

2E��h�@s�dZddlZddlmZddlmZmZmZddlZddl	m3Z4ddlmZddlm
Z
Gdd	�d	e�ZGd5d�de�ZGdd
�d
e�ZGdd�de�ZGdd�de�ZGdd�d�Ze�adefdd�Zddeedefdd�ZdS)uv配置管理模块6 7提供应用程序配置的加载和管理功能。8支持多环境配置和环境变量覆盖。9�N)�Path)�Any�Dict�Optional)�Field)�BaseSettings)�SettingsConfigDictc@s�eZdZUdZedddddd�ZdZeed	<d10Z	eed<dZ11eed<d
Zeed<dZ
eed<dZeed<dZeed<dZeed<dS)�	AppConfigu应用程序配置ZAPP_�.env�utf-8F�ignore�Z12env_prefixZenv_fileZenv_file_encodingZcase_sensitive�extrau音频转文字服务�namez1.0.0�version�debugz	127.0.0.1�hosti��portl�
max_file_size�d�max_files_count��concurrent_tasksN)�__name__�13__module__�__qualname__�__doc__r�model_configr�str�__annotations__rr�boolrr�intrrr�r"r"�@/Users/chengpeng/MyProject/transcript_service/src/core/config.pyr	s"14�r	c@s�eZdZUdZedddddd�Zedd	d15�Zee	d<eddd16�Z17ee	d
<eddd18�Zee	d<eddd19�Zee	d<dZ
ee	d<dZee	d<dZee	d<dZee	d<dS)�	OSSConfigu	OSS配置ZOSS_r20rFrr
.uOSS服务端点��description�endpointu访问密钥ID�
access_key_idu访问密钥密码�access_key_secretu存储桶名称�bucket_name�,�upload_timeout��url_expire_hoursz21temp/audio�temp_prefix��auto_cleanup_daysN)rrrrrrrr'rrr(r)r*r,r!r.r/r1r"r"r"r#r$$s"22�r$c@s�eZdZUdZedddddd�Zedd	d23�Zee	d<dZ24ee	d
<dZee	d<dZe
e	d<dZe
e	d<dZe
e	d<ddgZeee	d<dS)�DashScopeConfigu阿里云百炼API配置Z25DASHSCOPE_r26rFrr
.u	API密钥r%�api_keyz%https://dashscope.aliyuncs.com/api/v1�base_urlz
paraformer-v2�modelr+�timeout��max_retriesr�retry_delay�zh�en�language_hintsN)rrrrrrrr3rrr4r5r6r!r8r9r<�listr"r"r"r#r28s 27�r2c@sHeZdZUdZedddddd�ZdZeed	<d28Z	eed<dZ29eed
<dS)�30TaskConfigu任务配置ZTASK_r31rFrr
��status_check_intervali�max_processing_timei��32queue_sizeN)rrrrrrr@r!rrArBr"r"r"r#r>Ks33�r>c@sTeZdZUdZedddddd�ZdZeed	<d34Z	eed<dZ35eed
<dZeed<dS)�
LoggingConfigu日志配置ZLOGGING_r36rFrr
�INFO�levelZ37structured�formatZ10MB�
file_max_sizer�backup_countN)
rrrrrrrErrrFrGrHr!r"r"r"r#rCZs38�rCc@sdeZdZdZddeefdd�Zdeeeffdd�Z	de39fd	d40�Zde41fdd�Zde42fd
d�Z
dS)�Configu配置管理器N�environmentcCs~|pt�dd�|_|��|_tdi|j�di���|_t�|_	t43�|_tdi|j�di���|_
tdi|j�di���|_dS)uz初始化配置管理器44        45        Args:46            environment: 环境名称(development/production)47        ZENVIRONMENTZdevelopment�app�task�loggingNr")�os�getenvrJ�_load_configZ_config_datar	�getrKr$�ossr2Z	dashscoper>rLrCrM)�selfrJr"r"r#�__init__ms48zConfig.__init__�returncCsxtt�jjjdd}||j�d�}|��std|����t|ddd��
}t�|�Wd�S1s5wYdS)	u加载配置文件�configZenvironmentsz.yamlu配置文件不存在: �rr)�encodingN)	r�__file__�parentrJ�exists�FileNotFoundError�open�yamlZ	safe_load)rSZ49config_dirZconfig_file�filer"r"r#rP�s$�zConfig._load_configcCstt�jjjS)u获取项目根目录)rrYrZ)rSr"r"r#�get_project_root�szConfig.get_project_rootcC�|��d}|jdd�|S)u获取日志目录�logsT��exist_ok�r`�mkdir)rS�logs_dirr"r"r#�get_logs_dir��zConfig.get_logs_dircCra)u获取临时文件目录�tempTrcre)rSZtemp_dirr"r"r#�get_temp_dir�rizConfig.get_temp_dir�N)rrrrrrrTrrrPrr`rhrkr"r"r"r#rIjsrIrUcCstS)u获取配置实例)rVr"r"r"r#�50get_config�srmrJcCst|�atS)u重新加载配置)rIrV)rJr"r"r#�
reload_config�srnrl)rrN�pathlibr�typingrrrr^ZpydanticrZpydantic_settingsrrr	r$r2r>rCrIrVrmrrnr"r"r"r#�<module>s"5