This class stores server config parameters in a way that can be easily extended for new config file types.
| 166 | |
| 167 | |
| 168 | class ServerConfig(BaseSettings): |
| 169 | """This class stores server config parameters in a way that |
| 170 | can be easily extended for new config file types. |
| 171 | """ |
| 172 | |
| 173 | model_config = SettingsConfigDict( |
| 174 | env_prefix="optimade_", |
| 175 | extra="allow", |
| 176 | env_file_encoding="utf-8", |
| 177 | case_sensitive=False, |
| 178 | validate_assignment=True, |
| 179 | ) |
| 180 | |
| 181 | debug: Annotated[ |
| 182 | bool, |
| 183 | Field( |
| 184 | description="Turns on Debug Mode for the OPTIMADE Server implementation", |
| 185 | ), |
| 186 | ] = False |
| 187 | |
| 188 | insert_test_data: Annotated[ |
| 189 | bool, |
| 190 | Field( |
| 191 | description=( |
| 192 | "Insert test data into each collection on server initialisation. If true, " |
| 193 | "the configured backend will be populated with test data on server start. " |
| 194 | "Should be disabled for production usage." |
| 195 | ), |
| 196 | ), |
| 197 | ] = True |
| 198 | |
| 199 | insert_from_jsonl: Annotated[ |
| 200 | Path | None, |
| 201 | Field( |
| 202 | description=( |
| 203 | "The absolute path to an OPTIMADE JSONL file to use to initialize the database. " |
| 204 | "A unique index will be created over the ID to avoid duplication over multiple runs." |
| 205 | ) |
| 206 | ), |
| 207 | ] = None |
| 208 | |
| 209 | exit_after_insert: Annotated[ |
| 210 | bool, Field(description="Exit the API after inserting data") |
| 211 | ] = False |
| 212 | |
| 213 | create_default_index: Annotated[ |
| 214 | bool, |
| 215 | Field( |
| 216 | description=( |
| 217 | "Whether to create a set of default indices " |
| 218 | "for supporting databases after inserting JSONL data." |
| 219 | ) |
| 220 | ), |
| 221 | ] = False |
| 222 | |
| 223 | gzip: Annotated[ |
| 224 | GZipConfig, |
| 225 | Field(description="Configuration options for GZip compression."), |