/
base.py
689 lines (559 loc) · 26.7 KB
/
base.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
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
"""
Base settings for VarFish project.
For more information on this file, see
https://docs.djangoproject.com/en/dev/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/dev/ref/settings/
"""
import environ
import sys
from dotenv import load_dotenv
SITE_PACKAGE = "varfish"
ROOT_DIR = environ.Path(__file__) - 3 # (varfish/config/settings/base.py - 3 = varfish/)
APPS_DIR = ROOT_DIR.path("varfish")
# Check whether we are running tsts (this is important to use models and not materialized views in tests).
IS_TESTING = len(sys.argv) > 1 and sys.argv[1] == "test"
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#task-always-eager
CELERY_TASK_ALWAYS_EAGER = False
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#task-eager-propagates
CELERY_TASK_EAGER_PROPAGATES = False
# Load environment from .env file if available.
load_dotenv()
# Load operating system environment variables and then prepare to use them
env = environ.Env()
# .env file, should load only in development environment
READ_DOT_ENV_FILE = env.bool("DJANGO_READ_DOT_ENV_FILE", default=False)
if READ_DOT_ENV_FILE:
# Operating System Environment variables have precedence over variables defined in the .env file,
# that is to say variables from the .env files will only be used if not defined
# as environment variables.
env_file = str(ROOT_DIR.path(".env"))
print("Loading : {}".format(env_file))
env.read_env(env_file)
print("The .env file has been loaded. See base.py for more information")
# APP CONFIGURATION
# ------------------------------------------------------------------------------
DJANGO_APPS = [
# Technically, django-su is a third party app, but must be before ``django.contrib.admin``
"django_su",
# Default Django apps:
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.sites",
"django.contrib.messages",
"django.contrib.staticfiles",
"django.contrib.humanize", # Handy template tags
# Useful template tags:
# 'django.contrib.humanize',
# Admin
"django.contrib.admin",
]
THIRD_PARTY_APPS = [
"crispy_forms", # Form layouts
"rules.apps.AutodiscoverRulesConfig",
"djangoplugins",
"pagedown",
"markupfield",
"rest_framework",
"knox",
"aldjemy",
"adminalerts",
"userprofile.apps.UserprofileConfig",
"projectroles.apps.ProjectrolesConfig",
"timeline.apps.TimelineConfig",
"siteinfo.apps.SiteinfoConfig",
"docs", # For the online user documentation/manual
"dal",
"dal_select2",
"httpproxy",
"encrypted_model_fields",
"rest_framework_httpsignature",
"webpack_loader",
]
# Apps specific for this project go here.
LOCAL_APPS = [
# custom users app
"varfish.users.apps.UsersConfig",
# Your stuff: custom apps go here
"clinvar.apps.ClinvarConfig",
"clinvar_export.apps.ClinvarExportConfig",
"cohorts.apps.CohortsConfig",
"conservation.apps.ConservationConfig",
"dbsnp.apps.DbsnpConfig",
"frequencies.apps.FrequenciesConfig",
"hgmd.apps.HgmdConfig",
"geneinfo.apps.GeneinfoConfig",
"importer.apps.ImporterConfig",
"genomicfeatures.apps.GenomicFeaturesConfig",
"pathways.apps.PathwaysConfig",
"variants.apps.VariantsConfig",
"bgjobs.apps.BgjobsConfig",
"var_stats_qc.apps.VarStatsQcConfig",
"templatetags.apps.TemplatetagsConfig",
"svdbs.apps.SvDbsConfig",
"svs.apps.SvsConfig",
"extra_annos.apps.ExtraAnnosConfig",
"tokens.apps.TokensConfig",
"maintenance.apps.MaintenanceConfig",
"regmaps.apps.RegmapsConfig",
"beaconsite.apps.BeaconsiteConfig",
]
# See: https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
# Django-docs Settings
# ------------------------------------------------------------------------------
# Note: for serving to work, the docs have to be built after deployment.
DOCS_ROOT = ROOT_DIR.path("docs_manual/_build/html/")
# DOCS_ACCESS = 'public' # default
# Bump the default number of fields in forms.
DATA_UPLOAD_MAX_NUMBER_FIELDS = env.int("DATA_UPLOAD_MAX_NUMBER_FIELDS", 100_000)
# MIDDLEWARE CONFIGURATION
# ------------------------------------------------------------------------------
MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]
# MIGRATIONS CONFIGURATION
# ------------------------------------------------------------------------------
MIGRATION_MODULES = {"sites": "varfish.contrib.sites.migrations"}
# DEBUG
# ------------------------------------------------------------------------------
# See: https://docs.djangoproject.com/en/dev/ref/settings/#debug
DEBUG = env.bool("DJANGO_DEBUG", False)
# KIOSK-MODE RELATED
# ------------------------------------------------------------------------------
# Enable/disable kiosk mode.
KIOSK_MODE = env.bool("VARFISH_KIOSK_MODE", False)
# Name of top-level category with kiosk cases.
KIOSK_CAT = "VarFish Kiosk"
# Name of project below that Kategory (mandatory structure from SODAR core).
KIOSK_PROJ_PREFIX = "Cases"
# Define conda path for loading varfish-annotator environment
KIOSK_CONDA_PATH = env.str("VARFISH_KIOSK_CONDA_PATH", "")
# Varfish Annotator database path
KIOSK_VARFISH_ANNOTATOR_DB_PATH = env.str("VARFISH_KIOSK_VARFISH_ANNOTATOR_DB_PATH", "")
# Varfish Annotator ensembl ser path
KIOSK_VARFISH_ANNOTATOR_ENSEMBL_SER_PATH = env.str(
"VARFISH_KIOSK_VARFISH_ANNOTATOR_ENSEMBL_SER_PATH", ""
)
# Varfish Annotator refseq ser path
KIOSK_VARFISH_ANNOTATOR_REFSEQ_SER_PATH = env.str(
"VARFISH_KIOSK_VARFISH_ANNOTATOR_REFSEQ_SER_PATH", ""
)
# Varfish Annotator reference path
KIOSK_VARFISH_ANNOTATOR_REFERENCE_PATH = env.str(
"VARFISH_KIOSK_VARFISH_ANNOTATOR_REFERENCE_PATH", ""
)
# Varfish Annotator release
KIOSK_VARFISH_ANNOTATOR_RELEASE = env.str("VARFISH_KIOSK_VARFISH_ANNOTATOR_RELEASE", "GRCh37")
# Activate Kiosk mode in project roles
PROJECTROLES_KIOSK_MODE = KIOSK_MODE
# FIXTURE CONFIGURATION
# ------------------------------------------------------------------------------
# See: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-FIXTURE_DIRS
FIXTURE_DIRS = (str(APPS_DIR.path("fixtures")),)
# EMAIL CONFIGURATION
# ------------------------------------------------------------------------------
EMAIL_BACKEND = env("DJANGO_EMAIL_BACKEND", default="django.core.mail.backends.smtp.EmailBackend")
EMAIL_SENDER = env("EMAIL_SENDER", default="noreply@example.com")
EMAIL_SUBJECT_PREFIX = env("EMAIL_SUBJECT_PREFIX", default="")
# MANAGER CONFIGURATION
# ------------------------------------------------------------------------------
# See: https://docs.djangoproject.com/en/dev/ref/settings/#admins
ADMINS = [
("""Oliver Stolpe""", "oliver.stolpe@bihealth.de"),
("""Manuel Holtgrewe""", "manuel.holtgrewe@bihealth.de"),
]
# See: https://docs.djangoproject.com/en/dev/ref/settings/#managers
MANAGERS = ADMINS
# DATABASE CONFIGURATION
# ------------------------------------------------------------------------------
# See: https://docs.djangoproject.com/en/dev/ref/settings/#databases
# Uses django-environ to accept uri format
# See: https://django-environ.readthedocs.io/en/latest/#supported-types
DATABASES = {"default": env.db("DATABASE_URL", default="postgres:///varfish")}
DATABASES["default"]["ATOMIC_REQUESTS"] = False
# SENTRY CONFIGURATION
# ------------------------------------------------------------------------------
if env.bool("ENABLE_SENTRY", default=False):
import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration
SENTRY_DSN = "%s?verify_ssl=0" % env.str("SENTRY_DSN")
sentry_sdk.init(SENTRY_DSN, integrations=[DjangoIntegration()])
# ALDJEMY CONFIGURATION
# ------------------------------------------------------------------------------
# We have to do some fixes to the Aldjemy data types...
def fixed_array_type(field):
import aldjemy.table
import sqlalchemy.dialects.postgresql
data_types = aldjemy.table.DATA_TYPES
internal_type = field.base_field.get_internal_type()
# currently no support for multi-dimensional arrays
if internal_type in data_types and internal_type != "ArrayField":
sub_type = data_types[internal_type](field)
else:
raise RuntimeError("Unsupported array element type")
return sqlalchemy.dialects.postgresql.ARRAY(sub_type)
import sqlalchemy.dialects.postgresql
ALDJEMY_DATA_TYPES = {
"ArrayField": lambda field: fixed_array_type(field),
"UUIDField": lambda _: sqlalchemy.dialects.postgresql.UUID(as_uuid=True),
"JSONField": lambda _: sqlalchemy.dialects.postgresql.JSONB,
"BinaryField": lambda _: sqlalchemy.dialects.postgresql.BYTEA,
}
# We need to tell Aldjemy that we're using the psycopg2 driver so the correct
# SQL Alchemy connection dialect is used.
ALDJEMY_ENGINES = {"postgres": "postgresql+psycopg2"}
# GENERAL CONFIGURATION
# ------------------------------------------------------------------------------
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# In a Windows environment this must be set to your system time zone.
TIME_ZONE = "UTC"
# See: https://docs.djangoproject.com/en/dev/ref/settings/#language-code
LANGUAGE_CODE = "en-us"
# See: https://docs.djangoproject.com/en/dev/ref/settings/#site-id
SITE_ID = 1
# See: https://docs.djangoproject.com/en/dev/ref/settings/#use-i18n
USE_I18N = True
# See: https://docs.djangoproject.com/en/dev/ref/settings/#use-l10n
USE_L10N = True
# See: https://docs.djangoproject.com/en/dev/ref/settings/#use-tz
USE_TZ = True
# SITE CONFIGURATION
# ------------------------------------------------------------------------------
# Hosts/domain names that are valid for this site
# See https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
ALLOWED_HOSTS = env.list("DJANGO_ALLOWED_HOSTS", default=["varfish.bihealth.org"])
# END SITE CONFIGURATION
# TEMPLATE CONFIGURATION
# ------------------------------------------------------------------------------
# See: https://docs.djangoproject.com/en/dev/ref/settings/#templates
TEMPLATES = [
{
# See: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-TEMPLATES-BACKEND
"BACKEND": "django.template.backends.django.DjangoTemplates",
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-dirs
"DIRS": [str(APPS_DIR.path("templates"))],
"OPTIONS": {
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-debug
"debug": DEBUG,
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-loaders
# https://docs.djangoproject.com/en/dev/ref/templates/api/#loader-types
"loaders": [
"django.template.loaders.filesystem.Loader",
"django.template.loaders.app_directories.Loader",
],
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-context-processors
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.template.context_processors.i18n",
"django.template.context_processors.media",
"django.template.context_processors.static",
"django.template.context_processors.tz",
"django.contrib.messages.context_processors.messages",
# Your stuff: custom template context processors go here
"projectroles.context_processors.urls_processor",
"django_su.context_processors.is_su",
],
},
}
]
# See: http://django-crispy-forms.readthedocs.io/en/latest/install.html#template-packs
CRISPY_TEMPLATE_PACK = "bootstrap4"
# STATIC FILE CONFIGURATION
# ------------------------------------------------------------------------------
# See: https://docs.djangoproject.com/en/dev/ref/settings/#static-root
STATIC_ROOT = str(ROOT_DIR("staticfiles"))
# See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url
STATIC_URL = "/static/"
# See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#std:setting-STATICFILES_DIRS
STATICFILES_DIRS = [str(APPS_DIR.path("static"))]
# See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#staticfiles-finders
STATICFILES_FINDERS = [
"django.contrib.staticfiles.finders.FileSystemFinder",
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
]
# MEDIA CONFIGURATION
# ------------------------------------------------------------------------------
# See: https://docs.djangoproject.com/en/dev/ref/settings/#media-root
MEDIA_ROOT = str(APPS_DIR("media"))
# See: https://docs.djangoproject.com/en/dev/ref/settings/#media-url
MEDIA_URL = "/media/"
# URL Configuration
# ------------------------------------------------------------------------------
ROOT_URLCONF = "config.urls"
# See: https://docs.djangoproject.com/en/dev/ref/settings/#wsgi-application
WSGI_APPLICATION = "config.wsgi.application"
# PASSWORD STORAGE SETTINGS
# ------------------------------------------------------------------------------
# See https://docs.djangoproject.com/en/dev/topics/auth/passwords/#using-argon2-with-django
PASSWORD_HASHERS = [
"django.contrib.auth.hashers.Argon2PasswordHasher",
"django.contrib.auth.hashers.PBKDF2PasswordHasher",
"django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher",
"django.contrib.auth.hashers.BCryptSHA256PasswordHasher",
"django.contrib.auth.hashers.BCryptPasswordHasher",
]
# PASSWORD VALIDATION
# https://docs.djangoproject.com/en/dev/ref/settings/#auth-password-validators
# ------------------------------------------------------------------------------
AUTH_PASSWORD_VALIDATORS = [
{"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator"},
{"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator"},
{"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator"},
{"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator"},
]
# AUTHENTICATION CONFIGURATION
# ------------------------------------------------------------------------------
AUTHENTICATION_BACKENDS = [
"rules.permissions.ObjectPermissionBackend",
"django.contrib.auth.backends.ModelBackend",
"django_su.backends.SuBackend",
]
# Some really nice defaults
# Custom user app defaults
# Select the correct user model
AUTH_USER_MODEL = "users.User"
LOGIN_REDIRECT_URL = "home"
LOGIN_URL = "login"
# SLUGLIFIER
AUTOSLUG_SLUGIFY_FUNCTION = "slugify.slugify"
# Location of root django.contrib.admin URL, use {% url 'admin:index' %}
ADMIN_URL = r"^admin/"
# Celery
# ------------------------------------------------------------------------------
if USE_TZ:
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-timezone
CELERY_TIMEZONE = TIME_ZONE
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-broker_url
CELERY_BROKER_URL = env.str("CELERY_BROKER_URL", "redis://localhost:6379/0")
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-result_backend
CELERY_RESULT_BACKEND = CELERY_BROKER_URL
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-accept_content
CELERY_ACCEPT_CONTENT = ["json"]
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-task_serializer
CELERY_TASK_SERIALIZER = "json"
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-result_serializer
CELERY_RESULT_SERIALIZER = "json"
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#task-time-limit
CELERYD_TASK_TIME_LIMIT = 5 * 60
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#task-soft-time-limit
CELERYD_TASK_SOFT_TIME_LIMIT = 60
# Varfish: Base
# ------------------------------------------------------------------------------
# Yes, we want ForeinKey(unique=True), thank you very much.
SILENCED_SYSTEM_CHECKS = ["fields.W342"]
# Use URLs to represent files in DRF.
UPLOADED_FILES_USE_URL = True
# Set the number of partitions to create for the "SmallVariants" table. This
# setting will be interpreted in the initial migration that creates the small
# variant table. It must not be changed afterwards.
VARFISH_PARTITION_MODULUS_SMALLVARIANT = env.int("VARFISH_PARTITION_MODULUS_SMALLVARIANT", 1024)
# The same for structural variant tables
VARFISH_PARTITION_MODULUS_SVS = env.int(
"VARFISH_PARTITION_MODULUS_SMALLVARIANT", VARFISH_PARTITION_MODULUS_SMALLVARIANT
)
# Text to display on the login page.
VARFISH_LOGIN_PAGE_TEXT = env.str("VARFISH_LOGIN_PAGE_TEXT", "")
# Key to use for the encryption of secrets such as the secret RSA keys used by
# the beaconsite module. Losing/changing means losing all encrypted data. While
# DJANGO_SECRET_KEY can be changed and only session data is lost, this is worse.
#
# Leave blank to use no secret key.
FIELD_ENCRYPTION_KEY = env.str(
"FIELD_ENCRYPTION_KEY", "_XRAzgLd6NHj8G4q9FNV0p3Um9g4hy8BPBN-AL0JWO0="
)
# Varfish: Exomiser
# ------------------------------------------------------------------------------
# Enable exomiser configuration, default is disabled.
VARFISH_ENABLE_EXOMISER_PRIORITISER = env.bool("VARFISH_ENABLE_EXOMISER_PRIORITISER", default=False)
# Configure URL to API
VARFISH_EXOMISER_PRIORITISER_API_URL = env.str("VARFISH_EXOMISER_PRIORITISER_API_URL", "")
# Configure maximal number of genes to send to Exomiser API
VARFISH_EXOMISER_PRIORITISER_MAX_GENES = env.int("VARFISH_EXOMISER_PRIORITISER_MAX_GENES", 1000)
# Varfish: CADD
# ------------------------------------------------------------------------------
# Note well that while VarFish is released under a permissive open source license
# the CADD score is only freely available for non-commercial use.
# Enable CADD prioritization.
VARFISH_ENABLE_CADD = env.bool("VARFISH_ENABLE_CADD", default=False)
# Configure URL to CADD REST API
VARFISH_CADD_REST_API_URL = env.str("VARFISH_CADD_REST_API_URL", "")
# CADD version to use with CADD REST API.
VARFISH_CADD_REST_API_CADD_VERSION = env.str("VARFISH_CADD_REST_API_CADD_VERSION", "v1.6")
# Configure maximal number of genes to send to Exomiser API
VARFISH_CADD_MAX_VARS = env.int("VARFISH_CADD_MAX_VARS", 5000)
# Enable submission of variants to CADD server.
VARFISH_ENABLE_CADD_SUBMISSION = env.bool("VARFISH_ENABLE_CADD_SUBMISSION", default=False)
# CADD version to use for for submission
VARFISH_CADD_SUBMISSION_RELEASE = env.str("VARFISH_CADD_SUBMISSION_RELEASE", default="GRCh37-v1.6")
# Varfish: MutationTaster URL
VARFISH_MUTATIONTASTER_REST_API_URL = env.str(
"VARFISH_MUTATIONTASTER_REST_API_URL", "https://www.mutationdistiller.org/MTc/MT_API.cgi"
)
VARFISH_MUTATIONTASTER_BATCH_VARS = env.int("VARFISH_MUTATIONTASTER_BATCH_VARS", 50)
VARFISH_MUTATIONTASTER_MAX_VARS = env.int("VARFISH_MUTATIONTASTER_MAX_VARS", 500)
# VarfFish: Enable SPANR
VARFISH_ENABLE_SPANR_SUBMISSION = env.bool("VARFISH_ENABLE_SPANR_SUBMISSION", False)
# Varfish: UMD URL
VARFISH_UMD_REST_API_URL = env.str(
"VARFISH_UMD_REST_API_URL", "http://umd-predictor.eu/webservice.php"
)
# Varfish: extra annotations.
VARFISH_ENABLE_EXTRA_ANNOS = env.bool("VARFISH_ENABLE_EXTRA_ANNOS", False)
# Varfish: Jannovar
# ------------------------------------------------------------------------------
# Enable Jannovar configuration, default is disabled.
VARFISH_ENABLE_JANNOVAR = env.bool("VARFISH_ENABLE_JANNOVAR", default=False)
# Configure URL to Jannovar REST API
VARFISH_JANNOVAR_REST_API_URL = env.str("VARFISH_JANNOVAR_REST_API_URL", "")
# Varfish: SVs
# ------------------------------------------------------------------------------
# Configure experimental SV filtration feature.
VARFISH_ENABLE_SVS = env.bool("VARFISH_ENABLE_SVS", default=False)
# Varfish: GAGH Beacon
# ------------------------------------------------------------------------------
# Enabling or disabling Beacon site.
VARFISH_ENABLE_BEACON_SITE = env.bool("VARFISH_ENABLE_BEACON_SITE", default=False)
# Your common stuff: Below this line define 3rd party library settings
# ------------------------------------------------------------------------------
REST_FRAMEWORK = {
"DEFAULT_AUTHENTICATION_CLASSES": (
"rest_framework.authentication.BasicAuthentication",
"rest_framework.authentication.SessionAuthentication",
"knox.auth.TokenAuthentication",
)
}
if KIOSK_MODE:
SITE_TITLE = "VarFish (Kiosk)"
else:
SITE_TITLE = "VarFish"
SITE_SUBTITLE = env.str("SITE_SUBTITLE", "Beta")
SITE_INSTANCE_TITLE = env.str("SITE_INSTANCE_TITLE", "Deployment Instance Name")
PROJECTROLES_SECRET_LENGTH = 32
PROJECTROLES_INVITE_EXPIRY_DAYS = env.int("PROJECTROLES_INVITE_EXPIRY_DAYS", 14)
PROJECTROLES_SEND_EMAIL = env.bool("PROJECTROLES_SEND_EMAIL", False)
PROJECTROLES_HELP_HIGHLIGHT_DAYS = 7
PROJECTROLES_ENABLE_SEARCH = True
PROJECTROLES_SEARCH_PAGINATION = 5
SODAR_API_DEFAULT_VERSION = "0.1"
SODAR_API_MEDIA_TYPE = "application/vnd.bihealth.sodar+json"
PROJECTROLES_SITE_MODE = env.str("PROJECTROLES_SITE_MODE", "TARGET")
PROJECTROLES_TARGET_CREATE = env.bool("PROJECTROLES_TARGET_CREATE", True)
PROJECTROLES_ADMIN_OWNER = env.str("PROJECTROLES_DEFAULT_ADMIN", "admin")
PROJECTROLES_DEFAULT_ADMIN = env.str("PROJECTROLES_DEFAULT_ADMIN", "admin")
PROJECTROLES_EMAIL_SENDER_REPLY = env.bool("PROJECTROLES_EMAIL_SENDER_REPLY", False)
# Allow showing and synchronizing local non-admin users
PROJECTROLES_ALLOW_LOCAL_USERS = env.bool("PROJECTROLES_ALLOW_LOCAL_USERS", False)
PROJECTROLES_HIDE_APP_LINKS = ["svs"]
# Whether or not to sync from remote (disable only locally).
VARFISH_PROJECTROLES_SYNC_REMOTE = env.bool("VARFISH_PROJECTROLES_SYNC_REMOTE", True)
ENABLED_BACKEND_PLUGINS = ["timeline_backend"]
ENABLED_BACKEND_PLUGINS += env.list("ENABLED_BACKEND_PLUGINS", None, [])
def set_logging(debug):
return {
"version": 1,
"disable_existing_loggers": False,
"formatters": {"simple": {"format": "%(asctime)s [%(levelname)s] %(name)s: %(message)s"}},
"handlers": {
"console": {"level": "DEBUG", "class": "logging.StreamHandler", "formatter": "simple"}
},
"loggers": {
"projectroles": {"level": "INFO", "handlers": ["console"], "propagate": True,},
},
}
LOGGING = set_logging(DEBUG)
ENABLE_LDAP = env.bool("ENABLE_LDAP", False)
ENABLE_LDAP_SECONDARY = env.bool("ENABLE_LDAP_SECONDARY", False)
if ENABLE_LDAP:
import itertools
import ldap
from django_auth_ldap.config import LDAPSearch
# Default values
LDAP_DEFAULT_CONN_OPTIONS = {ldap.OPT_REFERRALS: 0}
LDAP_DEFAULT_FILTERSTR = "(sAMAccountName=%(user)s)"
LDAP_DEFAULT_ATTR_MAP = {"first_name": "givenName", "last_name": "sn", "email": "mail"}
# Primary LDAP server
AUTH_LDAP_SERVER_URI = env.str("AUTH_LDAP_SERVER_URI", None)
AUTH_LDAP_BIND_DN = env.str("AUTH_LDAP_BIND_DN", None)
AUTH_LDAP_BIND_PASSWORD = env.str("AUTH_LDAP_BIND_PASSWORD", None)
AUTH_LDAP_CONNECTION_OPTIONS = LDAP_DEFAULT_CONN_OPTIONS
AUTH_LDAP_USER_SEARCH = LDAPSearch(
env.str("AUTH_LDAP_USER_SEARCH_BASE", None), ldap.SCOPE_SUBTREE, LDAP_DEFAULT_FILTERSTR
)
AUTH_LDAP_USER_ATTR_MAP = LDAP_DEFAULT_ATTR_MAP
AUTH_LDAP_USERNAME_DOMAIN = env.str("AUTH_LDAP_USERNAME_DOMAIN", None)
AUTH_LDAP_DOMAIN_PRINTABLE = env.str("AUTH_LDAP_DOMAIN_PRINTABLE", None)
AUTHENTICATION_BACKENDS = tuple(
itertools.chain(("projectroles.auth_backends.PrimaryLDAPBackend",), AUTHENTICATION_BACKENDS)
)
# Secondary LDAP server
if ENABLE_LDAP_SECONDARY:
AUTH_LDAP2_SERVER_URI = env.str("AUTH_LDAP2_SERVER_URI", None)
AUTH_LDAP2_BIND_DN = env.str("AUTH_LDAP2_BIND_DN", None)
AUTH_LDAP2_BIND_PASSWORD = env.str("AUTH_LDAP2_BIND_PASSWORD", None)
AUTH_LDAP2_CONNECTION_OPTIONS = LDAP_DEFAULT_CONN_OPTIONS
AUTH_LDAP2_USER_SEARCH = LDAPSearch(
env.str("AUTH_LDAP2_USER_SEARCH_BASE", None), ldap.SCOPE_SUBTREE, LDAP_DEFAULT_FILTERSTR
)
AUTH_LDAP2_USER_ATTR_MAP = LDAP_DEFAULT_ATTR_MAP
AUTH_LDAP2_USERNAME_DOMAIN = env.str("AUTH_LDAP2_USERNAME_DOMAIN")
AUTH_LDAP2_DOMAIN_PRINTABLE = env.str("AUTH_LDAP2_DOMAIN_PRINTABLE", None)
AUTHENTICATION_BACKENDS = tuple(
itertools.chain(
("projectroles.auth_backends.SecondaryLDAPBackend",), AUTHENTICATION_BACKENDS
)
)
# URL to redirect after the login.
# Default: "/"
DJANGO_SU_LOGIN_REDIRECT_URL = "/"
# URL to redirect after the logout.
# Default: "/"
DJANGO_SU_LOGOUT_REDIRECT_URL = "/"
# A function to specify the perms that the user must have can use su
# Default: None
DJANGO_SU_LOGIN_CALLBACK = None
# A function to override the django.contrib.auth.login(request, user)
# function so you can set session data, etc.
# Default: None
DJANGO_SU_CUSTOM_LOGIN_ACTION = None
# STORAGE CONFIGURATION
# ------------------------------------------------------------------------------
# Uploaded Media Files
# ------------------------
# See: http://django-storages.readthedocs.io/en/latest/index.html
ENABLE_S3 = env.bool("VARFISH_USE_S3", False)
if ENABLE_S3:
INSTALLED_APPS += ["storages"]
AWS_ACCESS_KEY_ID = env.str("AWS_ACCESS_KEY_ID")
AWS_AUTO_CREATE_BUCKET = env.bool("AWS_AUTO_CREATE_BUCKET", True)
AWS_SECRET_ACCESS_KEY = env.str("AWS_SECRET_ACCESS_KEY")
AWS_STORAGE_BUCKET_NAME = env.str("AWS_STORAGE_BUCKET_NAME")
AWS_S3_ENDPOINT_URL = env.str("AWS_S3_ENDPOINT_URL", None)
AWS_AUTO_CREATE_BUCKET = True
AWS_QUERYSTRING_AUTH = False
AWS_DEFAULT_ACL = None
# AWS cache settings, don't change unless you know what you're doing:
AWS_EXPIRY = 60 * 60 * 24 * 7
# TODO See: https://github.com/jschneier/django-storages/issues/47
# Revert the following and use str after the above-mentioned bug is fixed in
# either django-storage-redux or boto
control = "max-age=%d, s-maxage=%d, must-revalidate" % (AWS_EXPIRY, AWS_EXPIRY)
AWS_HEADERS = {"Cache-Control": bytes(control, encoding="latin-1")}
# URL that handles the media served from MEDIA_ROOT, used for managing
# stored files.
MEDIA_URL = "http://localhost/-minio/%s/" % AWS_STORAGE_BUCKET_NAME
DEFAULT_FILE_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"
# WEBPACK / VUE.JS CONFIGURATION
# ------------------------------------------------------------------------------
WEBPACK_LOADER = {"VARFISH_VUE": {"STATS_FILE": ROOT_DIR("varfish/vueapp/webpack-stats.json"),}}