forked from NatLabRockies/REopt_API
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev_settings.py
More file actions
165 lines (135 loc) · 4.25 KB
/
dev_settings.py
File metadata and controls
165 lines (135 loc) · 4.25 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# REopt®, Copyright (c) Alliance for Sustainable Energy, LLC. See also https://github.com/NREL/REopt_API/blob/master/LICENSE.
from keys import *
import sys
import os
import django
import rollbar
"""
Django settings for reopt_api project.
Generated by 'django-admin startproject' using Django 2.2.
For more information on this file, see
https://docs.djangoproject.com/en/2.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.2/ref/settings/
"""
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = secret_key_
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
ALLOWED_HOSTS = ['*']
# Application definition
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'reo',
'summary',
'tastypie',
'proforma',
'resilience_stats',
'futurecosts',
'django_celery_results',
'django_extensions',
'reoptjl',
'ghpghx'
)
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'rollbar.contrib.django.middleware.RollbarNotifierMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
)
ROOT_URLCONF = 'reopt_api.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'reopt_api.wsgi.application'
ROLLBAR = {
'access_token': rollbar_access_token,
'environment': 'development',
'root': BASE_DIR,
'enabled':True
}
# Database
if 'test' in sys.argv or os.environ.get('APP_ENV') == 'local':
ROLLBAR['enabled'] = False
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'reopt',
'USER': 'reopt',
'PASSWORD': 'reopt',
'OPTIONS': {
'options': '-c search_path=public'
},
"HOST": os.environ.get("SQL_HOST", "localhost"),
"PORT": os.environ.get("SQL_PORT", "5432"),
}
}
else:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'HOST': dev_database_host,
'NAME': dev_database_name,
'OPTIONS': {
'options': '-c search_path=reopt_api'
},
'USER': dev_user,
'PASSWORD': dev_user_password,
}
}
# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/
rollbar.init(**ROLLBAR)
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Results backend
CELERY_RESULT_BACKEND = 'django-db'
# celery task registration
CELERY_IMPORTS = (
'reo.api',
'reo.scenario',
'reo.process_results',
'reo.src.run_jump_model',
'resilience_stats.outage_simulator_LF',
'futurecosts.api',
'futurecosts.tasks',
'reoptjl.api',
'reoptjl.src.run_jump_model'
)
if 'test' in sys.argv:
CELERY_TASK_ALWAYS_EAGER = True
CELERY_TASK_EAGER_PROPAGATES_EXCEPTIONS = False
CELERY_WORKER_MAX_MEMORY_PER_CHILD = 4000000 # 4 GB
# Static files (used for Proforma xlsx)
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = '/static/'
APPEND_SLASH = False
TASTYPIE_ALLOW_MISSING_SLASH = True
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "reopt_api.dev_settings")
django.setup()