-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
40 lines (28 loc) · 1.16 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""Configurate the behaviour of the app.
"""
from joblib import Memory
from pydantic import (
BaseSettings,
Field,
)
class AppSettings(BaseSettings):
OMDB_API_KEY: str = Field(..., env='OMDB_API_KEY')
# Telegram notifications
TELEGRAM_BOT_TOKEN: str = Field(..., env='TELEGRAM_BOT_TOKEN')
TELEGRAM_CHAT_ID: int = Field(..., env='TELEGRAM_CHAT_ID')
# Celery broker
CELERY_BROKER_URL: str = Field('amqp://localhost', env='CELERY_BROKER_URL')
CELERY_RESULT_URL: str = Field('db+sqlite:///results.sqlite', # SQlite for local development
env='CELERY_RESULT_URL')
CELERY_BROKER_POOL_LIMIT: int = Field(10, env='CELERY_BROKER_POOL_LIMIT')
# Internals
request_cooldown_time: float = Field(0.3, env='REQUEST_COOLDOWN_TIME')
number_threads: int = Field(2, env='NUMBER_THREADS')
class Config:
env_file = '.env'
env_file_encoding = 'utf-8'
default_config = AppSettings()
SUPPORTED_LOCATION_CODES = ["de_DE", "de_AT", "de_CH", "en_GB", "fr_FR",
"ru_RU", "en_US", "en_NL"]
# 100MB cache
memory = Memory(".cache", verbose=0, bytes_limit=1024*1024*100)