Skip to content

Commit

Permalink
add email config
Browse files Browse the repository at this point in the history
  • Loading branch information
shamspias committed Apr 29, 2024
1 parent c758dcd commit 2863c8c
Showing 1 changed file with 31 additions and 19 deletions.
50 changes: 31 additions & 19 deletions cvat/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
ALLOWED_HOSTS = os.environ.get('ALLOWED_HOSTS', 'localhost,127.0.0.1').split(',')
INTERNAL_IPS = ['127.0.0.1']


def generate_secret_key():
"""
Creates secret_key.py in such a way that multiple processes calling
Expand All @@ -53,7 +54,7 @@ def generate_secret_key():
if not os.path.isdir(keys_dir):
os.mkdir(keys_dir)

secret_key_fname = 'secret_key.py' # nosec
secret_key_fname = 'secret_key.py' # nosec

with tempfile.NamedTemporaryFile(
mode='wt', dir=keys_dir, prefix=secret_key_fname + ".",
Expand All @@ -72,9 +73,10 @@ def generate_secret_key():
# Discard ours and use theirs.
pass


try:
sys.path.append(BASE_DIR)
from keys.secret_key import SECRET_KEY # pylint: disable=unused-import
from keys.secret_key import SECRET_KEY # pylint: disable=unused-import
except ModuleNotFoundError:
generate_secret_key()
from keys.secret_key import SECRET_KEY
Expand Down Expand Up @@ -169,7 +171,6 @@ def generate_secret_key():
'EXCEPTION_HANDLER': 'cvat.apps.events.handlers.handle_viewset_exception',
}


REST_AUTH = {
'REGISTER_SERIALIZER': 'cvat.apps.iam.serializers.RegisterSerializerEx',
'LOGIN_SERIALIZER': 'cvat.apps.iam.serializers.LoginSerializerEx',
Expand Down Expand Up @@ -228,7 +229,7 @@ def generate_secret_key():

# IAM settings
IAM_TYPE = 'BASIC'
IAM_BASE_EXCEPTION = None # a class which will be used by IAM to report errors
IAM_BASE_EXCEPTION = None # a class which will be used by IAM to report errors
IAM_DEFAULT_ROLE = 'user'

IAM_ADMIN_ROLE = 'admin'
Expand All @@ -240,13 +241,12 @@ def generate_secret_key():
LOGIN_URL = 'rest_login'
LOGIN_REDIRECT_URL = '/'

OBJECTS_NOT_RELATED_WITH_ORG = ['user', 'function', 'request', 'server',]
OBJECTS_NOT_RELATED_WITH_ORG = ['user', 'function', 'request', 'server', ]

# ORG settings
ORG_INVITATION_CONFIRM = 'No'
ORG_INVITATION_EXPIRY_DAYS = 7


AUTHENTICATION_BACKENDS = [
'django.contrib.auth.backends.ModelBackend',
'allauth.account.auth_backends.AuthenticationBackend',
Expand All @@ -257,11 +257,12 @@ def generate_secret_key():
ACCOUNT_AUTHENTICATION_METHOD = 'username_email'

# set UI url to redirect after a successful e-mail confirmation
#changed from '/auth/login' to '/auth/email-confirmation' for email confirmation message
# changed from '/auth/login' to '/auth/email-confirmation' for email confirmation message
ACCOUNT_EMAIL_CONFIRMATION_ANONYMOUS_REDIRECT_URL = '/auth/email-confirmation'
ACCOUNT_EMAIL_VERIFICATION_SENT_REDIRECT_URL = '/auth/email-verification-sent'
INCORRECT_EMAIL_CONFIRMATION_URL = '/auth/incorrect-email-confirmation'


# Django-RQ
# https://github.com/rq/django-rq

Expand All @@ -275,6 +276,7 @@ class CVAT_QUEUES(Enum):
ANALYTICS_REPORTS = 'analytics_reports'
CLEANING = 'cleaning'


redis_inmem_host = os.getenv('CVAT_REDIS_INMEM_HOST', 'localhost')
redis_inmem_port = os.getenv('CVAT_REDIS_INMEM_PORT', 6379)
redis_inmem_password = os.getenv('CVAT_REDIS_INMEM_PASSWORD', '')
Expand Down Expand Up @@ -328,7 +330,7 @@ class CVAT_QUEUES(Enum):
'DEFAULT_TIMEOUT': int(os.getenv('CVAT_NUCLIO_DEFAULT_TIMEOUT', 120)),
'FUNCTION_NAMESPACE': os.getenv('CVAT_NUCLIO_FUNCTION_NAMESPACE', 'nuclio'),
'INVOKE_METHOD': os.getenv('CVAT_NUCLIO_INVOKE_METHOD',
default='dashboard' if 'KUBERNETES_SERVICE_HOST' in os.environ else 'direct'),
default='dashboard' if 'KUBERNETES_SERVICE_HOST' in os.environ else 'direct'),
}

assert NUCLIO['INVOKE_METHOD'] in {'dashboard', 'direct'}
Expand Down Expand Up @@ -462,15 +464,15 @@ class CVAT_QUEUES(Enum):
'level': 'DEBUG',
'filename': os.path.join(BASE_DIR, 'logs', 'cvat_server.log'),
'formatter': 'standard',
'maxBytes': 1024*1024*50, # 50 MB
'maxBytes': 1024 * 1024 * 50, # 50 MB
'backupCount': 5,
},
'dataset_handler': {
'class': 'logging.handlers.RotatingFileHandler',
'level': 'DEBUG',
'filename': os.path.join(BASE_DIR, 'logs', 'cvat_server_dataset.log'),
'formatter': 'standard',
'maxBytes': 1024*1024*50, # 50 MB
'maxBytes': 1024 * 1024 * 50, # 50 MB
'backupCount': 3,
},
'vector': {
Expand Down Expand Up @@ -518,7 +520,7 @@ class CVAT_QUEUES(Enum):
LOGGING['loggers']['vector']['handlers'] += ['vector']

DATA_UPLOAD_MAX_MEMORY_SIZE = 100 * 1024 * 1024 # 100 MB
DATA_UPLOAD_MAX_NUMBER_FIELDS = None # this django check disabled
DATA_UPLOAD_MAX_NUMBER_FIELDS = None # this django check disabled
DATA_UPLOAD_MAX_NUMBER_FILES = None

RESTRICTIONS = {
Expand All @@ -535,13 +537,13 @@ class CVAT_QUEUES(Enum):
redis_ondisk_password = os.getenv('CVAT_REDIS_ONDISK_PASSWORD', '')

CACHES = {
'default': {
'default': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
},
'media': {
'BACKEND' : 'django.core.cache.backends.redis.RedisCache',
"LOCATION": f"redis://:{urllib.parse.quote(redis_ondisk_password)}@{redis_ondisk_host}:{redis_ondisk_port}",
'TIMEOUT' : 3600 * 24, # 1 day
'BACKEND': 'django.core.cache.backends.redis.RedisCache',
"LOCATION": f"redis://:{urllib.parse.quote(redis_ondisk_password)}@{redis_ondisk_host}:{redis_ondisk_port}",
'TIMEOUT': 3600 * 24, # 1 day
}
}

Expand All @@ -561,7 +563,7 @@ class CVAT_QUEUES(Enum):
'x-organization',
]

TUS_MAX_FILE_SIZE = 26843545600 # 25gb
TUS_MAX_FILE_SIZE = 26843545600 # 25gb
TUS_DEFAULT_CHUNK_SIZE = 104857600 # 100 mb

# This setting makes request secure if X-Forwarded-Proto: 'https' header is specified by our proxy
Expand Down Expand Up @@ -693,14 +695,14 @@ class CVAT_QUEUES(Enum):
}
}

BUCKET_CONTENT_MAX_PAGE_SIZE = 500
BUCKET_CONTENT_MAX_PAGE_SIZE = 500

IMPORT_CACHE_FAILED_TTL = timedelta(days=30)
IMPORT_CACHE_SUCCESS_TTL = timedelta(hours=1)
IMPORT_CACHE_CLEAN_DELAY = timedelta(hours=12)

ASSET_MAX_SIZE_MB = 10
ASSET_SUPPORTED_TYPES = ('image/jpeg', 'image/png', 'image/webp', 'image/gif', 'application/pdf', )
ASSET_SUPPORTED_TYPES = ('image/jpeg', 'image/png', 'image/webp', 'image/gif', 'application/pdf',)
ASSET_MAX_IMAGE_SIZE = 1920
ASSET_MAX_COUNT_PER_GUIDE = 30

Expand All @@ -709,12 +711,22 @@ class CVAT_QUEUES(Enum):
# By default, email backend is django.core.mail.backends.smtp.EmailBackend
# But it won't work without additional configuration, so we set it to None
# to check configuration and throw ImproperlyConfigured if thats a case
EMAIL_BACKEND = None
# EMAIL_BACKEND = None
# Email
EMAIL_BACKEND = os.getenv('EMAIL_BACKEND', 'django.core.mail.backends.smtp.EmailBackend')
EMAIL_HOST = os.getenv('EMAIL_HOST', 'localhost')
EMAIL_PORT = os.getenv('EMAIL_PORT', 1025)
EMAIL_FROM = os.getenv('EMAIL_FROM', '[email protected]')

EMAIL_USE_TLS = os.getenv('EMAIL_USE_TLS', True)
EMAIL_HOST_USER = os.getenv('EMAIL_HOST_USER', '[email protected]')
EMAIL_HOST_PASSWORD = os.getenv('EMAIL_HOST_PASSWORD', 'password')

ONE_RUNNING_JOB_IN_QUEUE_PER_USER = to_bool(os.getenv('ONE_RUNNING_JOB_IN_QUEUE_PER_USER', False))

# How many chunks can be prepared simultaneously during task creation in case the cache is not used
CVAT_CONCURRENT_CHUNK_PROCESSING = int(os.getenv('CVAT_CONCURRENT_CHUNK_PROCESSING', 1))

from cvat.rq_patching import update_started_job_registry_cleanup

update_started_job_registry_cleanup()

0 comments on commit 2863c8c

Please sign in to comment.