userIdc2024 commited on
Commit
af8055f
·
verified ·
1 Parent(s): 15063fc

Update core/settings.py

Browse files
Files changed (1) hide show
  1. core/settings.py +0 -91
core/settings.py CHANGED
@@ -10,22 +10,6 @@ from pydantic_settings import BaseSettings, JsonConfigSettingsSource
10
  from core.logger import logger
11
 
12
 
13
- def load_json_config(json_file: str) -> Dict[str, Any]:
14
- try:
15
- file_path = os.path.join('/mnt/secrets-store', json_file)
16
- if os.path.exists(file_path):
17
- logger.info(f"The file from dataclasses import dataclass
18
- import os
19
- import os
20
- from typing import Dict, Any, Optional
21
-
22
- from dotenv import dotenv_values
23
- from pydantic import BaseModel, ConfigDict
24
- from pydantic_settings import BaseSettings, JsonConfigSettingsSource
25
-
26
- from core.logger import logger
27
-
28
-
29
  def load_env_config():
30
  if GlobalConfig().APP_ENV == "dev":
31
  return dotenv_values()
@@ -82,81 +66,6 @@ class GlobalConfig(BaseSettings):
82
  GEMINI_API_KEY: Optional[str] = None
83
 
84
 
85
- # Custom
86
- NEW_BASE: Optional[str] = None
87
-
88
- # Load configurations
89
- config_data = get_config()
90
- cnf = GlobalConfig(**config_data)
91
- app_cnf = cnf.APP_CONFIG
92
- is located at: {file_path}")
93
- else:
94
- logger.error("JSON file not found.")
95
- except FileNotFoundError:
96
- logger.error("Secrets file not found.")
97
- return {}
98
- return JsonConfigSettingsSource(settings_cls=GlobalConfig, json_file=file_path).json_data
99
-
100
-
101
- def load_env_config():
102
- if GlobalConfig().APP_ENV == "dev":
103
- return dotenv_values()
104
- else:
105
- return dict(os.environ)
106
-
107
-
108
- def get_config() -> Dict[str, Any]:
109
- json_config = load_json_config('config.json')
110
- env_config = load_env_config()
111
-
112
- config_model = GlobalConfig.model_construct()
113
-
114
-
115
- final_config = {**config_model.model_dump(), **env_config, **json_config}
116
-
117
- return final_config
118
-
119
- class AppConfig(BaseModel):
120
- """Application configurations."""
121
-
122
- app_name: str = "Creative AdGenesis"
123
- app_version: str = "0.1.0"
124
- app_description: str = (
125
- "Creative AdGenesis"
126
- )
127
- debug_mode: bool = False
128
-
129
-
130
- class GlobalConfig(BaseSettings):
131
- """Typed global core object."""
132
- APP_CONFIG: AppConfig = AppConfig()
133
- model_config = ConfigDict(extra="ignore")
134
-
135
- # Environment
136
- APP_ENV: Optional[str] = "dev"
137
- DEBUG: Optional[bool] = False
138
-
139
- MONGO_HOST: Optional[str] = None
140
- MONGO_USERNAME: Optional[str] = None
141
- MONGO_PASSWORD: Optional[str] = None
142
- MONGO_DB: Optional[str] = None
143
-
144
-
145
- # Cloudflare R2
146
- R2_BUCKET_NAME: Optional[str] = None
147
- R2_ACCESS_KEY: Optional[str] = None
148
- R2_SECRET_KEY: Optional[str] = None
149
- R2_ENDPOINT: Optional[str] = None
150
-
151
-
152
- # OpenAI
153
- OPENAI_API_KEY: Optional[str] = None
154
-
155
- # Replicate
156
- REPLICATE_API_KEY: Optional[str] = None
157
- GEMINI_API_KEY: Optional[str] = None
158
-
159
-
160
  # Custom
161
  NEW_BASE: Optional[str] = None
162
 
 
10
  from core.logger import logger
11
 
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  def load_env_config():
14
  if GlobalConfig().APP_ENV == "dev":
15
  return dotenv_values()
 
66
  GEMINI_API_KEY: Optional[str] = None
67
 
68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  # Custom
70
  NEW_BASE: Optional[str] = None
71