-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathconfig.py
654 lines (559 loc) · 22.7 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
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
# -*- coding: utf-8 -*-
#
# Copyright (C) 2018 CERN.
#
# CERN Analysis Preservation is free software; you can redistribute it
# and/or modify it under the terms of the MIT License; see LICENSE file
# for more details.
"""Default configuration for CERN Analysis Preservation."""
import copy
import os
from datetime import timedelta
from os.path import dirname, join
import requests
from flask import request
from flask_principal import RoleNeed
from invenio_deposit import config as deposit_config
from invenio_deposit.config import DEPOSIT_REST_SORT_OPTIONS
from invenio_deposit.scopes import write_scope
from invenio_deposit.utils import check_oauth2_scope
from invenio_oauthclient.contrib.cern import REMOTE_APP as CERN_REMOTE_APP
from invenio_records_rest.config import RECORDS_REST_ENDPOINTS
from invenio_records_rest.facets import terms_filter
from invenio_records_rest.utils import allow_all, deny_all
from jsonresolver import JSONResolver
from jsonresolver.contrib.jsonref import json_loader_factory
from cap.modules.deposit.permissions import (AdminDepositPermission,
CreateDepositPermission,
ReadDepositPermission)
from cap.modules.oauthclient.contrib.cern import disconnect_handler
from cap.modules.oauthclient.rest_handlers import (authorized_signup_handler,
signup_handler)
from cap.modules.records.permissions import ReadRecordPermission
from cap.modules.search.facets import nested_filter, prefix_filter
def _(x):
"""Identity function used to trigger string extraction."""
return x
# ************************************ #
# GOOD TO KNOW!
#
# Enviromental variables with INVENIO_ prefix
# will override variables set in the config.py
# ex.
# ZENODO_ACCESS_TOKEN = 'CHANGE_ME'
# will be overriden if INVENIO_ZENODO_ACCESS_TOKEN
# is set in the ENVIRONMENT running the app
#
# ************************************ #
# Cache
# =========
#: Redis Cache Host
CACHE_REDIS_HOST = os.environ.get("CACHE_REDIS_HOST", "localhost")
#: Redis Cache Port
CACHE_REDIS_PORT = os.environ.get("CACHE_REDIS_PORT", 6379)
#: Redis Cache base url
CACHE_REDIS_BASE_URL = "redis://{0}:{1}".format(
CACHE_REDIS_HOST, CACHE_REDIS_PORT)
#: URL of Redis db.
CACHE_REDIS_URL = "{0}/0".format(CACHE_REDIS_BASE_URL)
# Accounts
# ========
#: Redis session storage URL.
ACCOUNTS_SESSION_REDIS_URL = '{0}/1'.format(CACHE_REDIS_BASE_URL)
# Rate limiting
# =============
#: Storage for ratelimiter.
# TODO FIX for deployments
RATELIMIT_STORAGE_URL = 'redis://localhost:6379/3'
# I18N
# ====
#: Default language
BABEL_DEFAULT_LANGUAGE = 'en'
#: Default time zone
BABEL_DEFAULT_TIMEZONE = 'Europe/Zurich'
#: Other supported languages (do not include the default language in list).
I18N_LANGUAGES = [('fr', _('French'))]
# Email configuration
# ===================
#: Email address for support.
#: Disable email sending by default.
MAIL_DEBUG = False
MAIL_SUPPRESS_SEND = True
# Accounts
# ========
#: Allow user to confirm their email address.
SECURITY_CONFIRMABLE = False
"""Allow users to login without first confirming their email address."""
SECURITY_LOGIN_WITHOUT_CONFIRMATION = True
"""Disable sending registration email."""
SECURITY_SEND_REGISTER_EMAIL = False
#: Email address used as sender of account registration emails.
SECURITY_EMAIL_SENDER = SUPPORT_EMAIL
#: Email subject for account registration emails.
SECURITY_EMAIL_SUBJECT_REGISTER = _("Welcome to CERN Analysis Preservation!")
# Celery configuration
# ====================
BROKER_URL = 'amqp://guest:guest@localhost:5672/'
#: URL of message broker for Celery (default is RabbitMQ).
CELERY_BROKER_URL = 'amqp://guest:guest@localhost:5672/'
#: URL of backend for result storage (default is Redis).
CELERY_RESULT_BACKEND = 'redis://localhost:6379/2'
#: Scheduled tasks configuration (aka cronjobs).
CELERY_BEAT_SCHEDULE = {
'indexer': {
'task': 'invenio_indexer.tasks.process_bulk_queue',
'schedule': timedelta(minutes=5),
},
'accounts': {
'task': 'invenio_accounts.tasks.clean_session_table',
'schedule': timedelta(minutes=60),
},
'cadi_sync': {
'task': 'cap.modules.experiments.tasks.cms.synchronize_with_cadi',
'schedule': timedelta(days=1),
},
'ping_webhooks': {
'task': 'cap.modules.repos.tasks.ping_webhooks',
'schedule': timedelta(hours=12),
},
'das_harvester': {
'task': 'cap.modules.experiments.tasks.cms.harvest_das',
'schedule': timedelta(days=1),
},
}
#: Accepted content types, used for serializing objects
#: when sending tasks to Celery (json default in 4.0)
# CELERY_ACCEPT_CONTENT = ['pickle', 'json']
# Database
# ========
#: Database URI including user and password
SQLALCHEMY_DATABASE_URI = os.environ.get(
'APP_SQLALCHEMY_DATABASE_URI',
'postgresql+psycopg2://cap:cap@localhost/cap')
# JSONSchemas
# ===========
#: Hostname used in URLs for local JSONSchemas.
JSONSCHEMAS_HOST = 'analysispreservation.cern.ch'
SCHEMAS_DEPOSIT_PREFIX = 'deposits/records/'
SCHEMAS_RECORD_PREFIX = 'records/'
SCHEMAS_OPTIONS_PREFIX = 'options/'
# Flask configuration
# ===================
# See details on
# http://flask.pocoo.org/docs/0.12/config/#builtin-configuration-values
#: Secret key - each installation (dev, production, ...) needs a separate key.
#: It should be changed before deploying.
SECRET_KEY = 'CHANGE_ME'
#: Max upload size for form data via application/mulitpart-formdata.
MAX_CONTENT_LENGTH = 100 * 1024 * 1024 # 100 MiB
#: Sets cookie with the secure flag by default
SESSION_COOKIE_SECURE = False
#: Since HAProxy and Nginx route all requests no matter the host header
#: provided, the allowed hosts variable is set to localhost. In production it
#: should be set to the correct host and it is strongly recommended to only
#: route correct hosts to the application.
APP_ALLOWED_HOSTS = [
'localhost',
'analysispreservation.web.cern.ch',
'analysispreservation.cern.ch',
'analysispreservation-dev.web.cern.ch',
'analysispreservation-dev.cern.ch',
'analysispreservation-qa.web.cern.ch',
'analysispreservation-qa.cern.ch'
]
if os.environ.get('DEV_HOST', False):
APP_ALLOWED_HOSTS.append(os.environ.get('DEV_HOST'))
# OAI-PMH
# =======
OAISERVER_ID_PREFIX = 'oai:analysispreservation.cern.ch:'
# Debug
# =====
# Flask-DebugToolbar is by default enabled when the application is running in
# debug mode. More configuration options are available at
# https://flask-debugtoolbar.readthedocs.io/en/latest/#configuration
#: Switches off incept of redirects by Flask-DebugToolbar.
DEBUG_TB_INTERCEPT_REDIRECTS = False
# =======================================================================
# =======================================================================
# =======================================================================
DEBUG_MODE = os.environ.get('DEBUG_MODE')
DEBUG = True if DEBUG_MODE == 'True' else False
if DEBUG:
REST_ENABLE_CORS = True
APP_ENABLE_SECURE_HEADERS = False
# Path to app root dir
APP_ROOT = os.path.dirname(os.path.abspath(__file__))
#: Default cache type.
CACHE_TYPE = "redis"
#: Default cache URL for sessions.
ACCESS_SESSION_REDIS_HOST = os.environ.get('APP_ACCESS_SESSION_REDIS_HOST',
'localhost')
#: Cache for storing access restrictions
ACCESS_CACHE = 'cap.modules.cache:current_cache'
#: E-Groups for superuser rights
SUPERUSER_EGROUPS = [
RoleNeed('[email protected]'),
RoleNeed('[email protected]'),
]
# Records
# =======
#: Records sort/facets options
RECORDS_REST_SORT_OPTIONS = dict(records=dict(
bestmatch=dict(
title=_('Best match'),
fields=['_score'],
order=1,
),
mostrecent=dict(
title=_('Most recent'),
fields=['_updated'],
default_order='desc',
order=2,
),
))
RECORDS_REST_SORT_OPTIONS.update(DEPOSIT_REST_SORT_OPTIONS)
#: Record search facets.
# for aggregations, only ones starting with facet_ will be displayed on a page
CAP_FACETS = {
'aggs': {
# 'facet_type': {
# 'terms': {
# 'field': '_type'
# }
# },
'facet_cms_working_group': {
'terms': {
'size': 30,
'script': 'doc.containsKey("cadi_id") ? doc["basic_info.cadi_id"].value?.substring(0,3) : null' # noqa
}
},
'facet_cadi_status': {
'terms': {
'field': 'cadi_info.status'
}
},
'particles': {
'nested': {
'path': 'main_measurements.signal_event_selection.physics_objects' # noqa
},
'aggs': {
'facet_physics_objects': {
'terms': {
'field': 'main_measurements.signal_event_selection'
'.physics_objects.object',
'exclude': '',
},
'aggs': {
'doc_count': {
'reverse_nested': {}
},
'facet_physics_objects_type': {
'terms': {
'field': 'main_measurements'
'.signal_event_selection'
'.physics_objects'
'.object_type.keyword'
},
'aggs': {
'doc_count': {
'reverse_nested': {}
}
},
},
},
},
},
},
},
'post_filters': {
# 'type': terms_filter('_type'),
'cms_working_group': prefix_filter('basic_info.cadi_id'),
'cadi_status': terms_filter('cadi_info.status'),
'physics_objects': nested_filter(
'main_measurements.signal_event_selection.physics_objects',
'main_measurements.signal_event_selection.physics_objects.object',
),
'physics_objects_type': nested_filter(
'main_measurements.signal_event_selection.physics_objects',
'main_measurements.signal_event_selection.physics_objects'
'.object_type.keyword',
),
},
}
RECORDS_REST_FACETS = {'deposits': CAP_FACETS, 'records': CAP_FACETS}
#: Records REST API endpoints.
RECORDS_REST_ENDPOINTS = copy.deepcopy(RECORDS_REST_ENDPOINTS)
RECORDS_REST_ENDPOINTS['recid'].update({
'record_class': 'cap.modules.records.api:CAPRecord',
'pid_fetcher': 'cap_record_fetcher',
'search_class': 'cap.modules.records.search:CAPRecordSearch',
'search_factory_imp': 'cap.modules.search.query:cap_search_factory',
'record_serializers': {
'application/json': ('cap.modules.records.serializers'
':record_json_v1_response'),
'application/basic+json': ('cap.modules.records.serializers'
':basic_json_v1_response'),
'application/form+json': ('cap.modules.records.serializers'
':record_form_json_v1_response')
},
'search_serializers': {
'application/json': ('cap.modules.records.serializers'
':record_json_v1_search'),
'application/basic+json': ('cap.modules.records.serializers'
':basic_json_v1_search'),
},
'read_permission_factory_imp': check_oauth2_scope(
lambda record: ReadRecordPermission(record).can(), write_scope.id),
'links_factory_imp': 'cap.modules.records.links:links_factory',
})
#: Default api endpoint for LHCb db
GRAPHENEDB_URL = 'http://datadependency.cern.ch:7474'
#: Account-REST Configuration
ACCOUNTS_REST_READ_ROLE_PERMISSION_FACTORY = deny_all
"""Default get role permission factory: reject any request."""
ACCOUNTS_REST_UPDATE_ROLE_PERMISSION_FACTORY = deny_all
"""Default update role permission factory: reject any request."""
ACCOUNTS_REST_DELETE_ROLE_PERMISSION_FACTORY = deny_all
"""Default delete role permission factory: reject any request."""
ACCOUNTS_REST_READ_ROLES_LIST_PERMISSION_FACTORY = deny_all
"""Default list roles permission factory: reject any request."""
ACCOUNTS_REST_CREATE_ROLE_PERMISSION_FACTORY = deny_all
"""Default create role permission factory: reject any request."""
ACCOUNTS_REST_ASSIGN_ROLE_PERMISSION_FACTORY = deny_all
"""Default assign role to user permission factory: reject any request."""
ACCOUNTS_REST_UNASSIGN_ROLE_PERMISSION_FACTORY = deny_all
"""Default unassign role from user permission factory: reject any request."""
ACCOUNTS_REST_READ_USER_ROLES_LIST_PERMISSION_FACTORY = deny_all
"""Default list users roles permission factory: reject any request."""
ACCOUNTS_REST_READ_USER_PROPERTIES_PERMISSION_FACTORY = allow_all
"""Default read user properties permission factory: reject any request."""
ACCOUNTS_REST_UPDATE_USER_PROPERTIES_PERMISSION_FACTORY = deny_all
"""Default modify user properties permission factory: reject any request."""
ACCOUNTS_REST_READ_USERS_LIST_PERMISSION_FACTORY = allow_all
"""Default list users permission factory: reject any request."""
# Search
# ======
#: Default API endpoint for search UI.
SEARCH_UI_SEARCH_API = '/api/deposits'
#: Default ElasticSearch hosts
es_user = os.environ.get('ELASTICSEARCH_USER')
es_password = os.environ.get('ELASTICSEARCH_PASSWORD')
if es_user and es_password:
es_params = dict(
http_auth=(es_user, es_password),
use_ssl=str(os.environ.get('ELASTICSEARCH_USE_SSL')).lower() == 'true',
verify_certs=str(
os.environ.get('ELASTICSEARCH_VERIFY_CERTS')).lower() == 'true',
url_prefix=os.environ.get('ELASTICSEARCH_URL_PREFIX', ''),
)
else:
es_params = {}
SEARCH_ELASTIC_HOSTS = [
dict(host=os.environ.get('ELASTICSEARCH_HOST', 'localhost'),
port=int(os.environ.get('ELASTICSEARCH_PORT', '9200')),
**es_params)
]
SEARCH_GET_MAPPINGS_IMP = 'cap.modules.schemas.imp.get_mappings'
# Admin
# ========
ADMIN_PERMISSION_FACTORY = \
'cap.modules.access.permissions.admin_permission_factory'
# Logging
# =======
#: CERN OAuth configuration
CERN_APP_CREDENTIALS = {
'consumer_key': os.environ.get('INVENIO_CERN_APP_CREDENTIALS_KEY'),
'consumer_secret': os.environ.get('INVENIO_CERN_APP_CREDENTIALS_SECRET')
}
# Update CERN OAuth handlers - due to REST - mostly only redirect urls
# and error flashing
CERN_REMOTE_APP.update(
dict(
authorized_handler=authorized_signup_handler,
disconnect_handler=disconnect_handler,
))
CERN_REMOTE_APP['signup_handler']['view'] = signup_handler
#: Defintion of OAuth client applications.
OAUTHCLIENT_REMOTE_APPS = dict(cern=CERN_REMOTE_APP, )
# JSON Schemas
# ============
#: Path to where JSON metadata exist
JSON_METADATA_PATH = "/_metadata"
JSONSCHEMAS_ENDPOINT = '/schemas'
JSONSCHEMAS_RESOLVE_SCHEMA = True
JSONSCHEMAS_LOADER_CLS = json_loader_factory(
JSONResolver(plugins=[
'cap.modules.schemas.resolvers', 'cap.modules.schemas.resolvers_api'
], ))
# WARNING: Do not share the secret key - especially do not commit it to
# version control.
SECRET_KEY = "changeme"
# LHCb
# ========
#: Ana's database
LHCB_ANA_DB = 'http://datadependency.cern.ch'
LHCB_GETCOLLISIONDATA_URL = '{0}/getRecoStripSoft?propass='.format(LHCB_ANA_DB)
LHCB_GETPLATFORM_URL = '{0}/getPlatform?app='.format(LHCB_ANA_DB)
# CMS
# ========
#: Kerberos credentials
CMS_USER_PRINCIPAL = os.environ.get('APP_CMS_USER_PRINCIPAL')
CMS_USER_KEYTAB = os.environ.get('APP_CMS_USER_KEYTAB')
CMS_CONVENERS_EGROUP = 'cms-phys-conveners-{wg}@cern.ch'
#: CADI database
CADI_AUTH_URL = 'https://icms.cern.ch/tools/api/cadiLine/BPH-13-009'
CADI_GET_CHANGES_URL = 'https://icms.cern.ch/tools/api/updatedCadiLines/'
CADI_GET_ALL_URL = 'https://icms.cern.ch/tools/api/viewCadiLines'
CADI_GET_RECORD_URL = 'https://icms.cern.ch/tools/api/cadiLine/{id}'
# ATLAS
# ========
#: Glance database
GLANCE_CLIENT_ID = os.environ.get('APP_GLANCE_CLIENT_ID')
GLANCE_CLIENT_PASSWORD = os.environ.get('APP_GLANCE_CLIENT_PASSWORD')
#: Glance API URLs
GLANCE_GET_TOKEN_URL = \
'https://oraweb.cern.ch/ords/atlr/atlas_authdb/oauth/token'
GLANCE_GET_ALL_URL = \
'https://oraweb.cern.ch/ords/atlr/atlas_authdb/atlas/analysis/analysis/?client_name=cap' # noqa
GLANCE_GET_BY_ID_URL = \
'https://oraweb.cern.ch/ords/atlr/atlas_authdb/atlas/analysis/analysis/?client_name=cap&id={id}' # noqa
# Deposit
# ============
#: Default jsonschema for deposit
DEPOSIT_DEFAULT_JSONSCHEMA = 'deposits/records/lhcb-v0.0.1.json'
#: Default schemanform for deposit
DEPOSIT_DEFAULT_SCHEMAFORM = 'json/deposits/records/lhcb-v0.0.1.json'
#: Search api url for deposit
DEPOSIT_SEARCH_API = '/api/deposits'
#: Files api url for deposit
DEPOSIT_FILES_API = '/api/files'
DEPOSIT_PID_MINTER = 'cap_record_minter'
DEPOSIT_REST_ENDPOINTS = copy.deepcopy(deposit_config.DEPOSIT_REST_ENDPOINTS)
_PID = 'pid(depid,record_class="cap.modules.deposit.api:CAPDeposit")'
DEPOSIT_UI_SEARCH_INDEX = '*'
# DEPOSIT_PID_MINTER is used on publish method in deposit class
DEPOSIT_REST_ENDPOINTS['depid'].update({
'pid_type': 'depid',
'pid_minter': 'cap_deposit_minter',
'pid_fetcher': 'cap_deposit_fetcher',
'record_class': 'cap.modules.deposit.api:CAPDeposit',
'record_loaders': {
'application/json': 'cap.modules.deposit.loaders:json_v1_loader',
'application/json-patch+json': lambda: request.get_json(force=True),
},
'record_serializers': {
'application/json': ('cap.modules.deposit.serializers'
':deposit_json_v1_response'),
'application/basic+json': ('cap.modules.records.serializers'
':basic_json_v1_response'),
'application/permissions+json': ('cap.modules.records.serializers'
':permissions_json_v1_response'),
'application/form+json': ('cap.modules.deposit.serializers'
':deposit_form_json_v1_response'),
'application/repositories+json': ('cap.modules.records.serializers'
':repositories_json_v1_response')
},
'search_serializers': {
'application/json': ('cap.modules.deposit.serializers'
':deposit_json_v1_search'),
'application/basic+json': ('cap.modules.records.serializers'
':basic_json_v1_search')
},
'files_serializers': {
'application/json': ('cap.modules.deposit.serializers:files_response'),
},
'search_class': 'cap.modules.deposit.search:CAPDepositSearch',
'search_factory_imp': 'cap.modules.search.query:cap_search_factory',
'item_route': '/deposits/<{0}:pid_value>'.format(_PID),
'file_list_route': '/deposits/<{0}:pid_value>/files'.format(_PID),
'file_item_route':
'/deposits/<{0}:pid_value>/files/<path:key>'.format(_PID),
'create_permission_factory_imp': check_oauth2_scope(
lambda record: CreateDepositPermission(record).can(), write_scope.id),
'read_permission_factory_imp': check_oauth2_scope(
lambda record: ReadDepositPermission(record).can(), write_scope.id),
'update_permission_factory_imp': allow_all,
'delete_permission_factory_imp': check_oauth2_scope(
lambda record: AdminDepositPermission(record).can(), write_scope.id),
'links_factory_imp': 'cap.modules.deposit.links:links_factory',
})
# Datadir
# =======
DATADIR = join(dirname(__file__), 'data')
# Files
# ===========
FILES_REST_PERMISSION_FACTORY = \
'cap.modules.deposit.permissions:files_permission_factory'
# Grab files max size
FILES_URL_MAX_SIZE = (2**20) * 5000
# Header for updating file tags
FILES_REST_FILE_TAGS_HEADER = 'X-CAP-File-Tags'
# Indexer
# =======
#: Flag for not replacing refs when creating deposit
INDEXER_REPLACE_REFS = False
# LHCB DB files location
# ======================
LHCB_DB_FILES_LOCATION = os.environ.get(
'APP_LHCB_FILES_LOCATION',
os.path.join(APP_ROOT, 'modules/experiments/static/example_lhcb/'))
EXPERIMENTS_RESOURCES_LOCATION = os.environ.get(
'APP_EXPERIMENTS_RESOURCES_LOCATION',
os.path.join(APP_ROOT, 'modules/experiments/static'))
# Disable JWT token
ACCOUNTS_JWT_ENABLE = False
# Github and Gitlab oauth tokens
# ==============================
GITHUB_OAUTH_ACCESS_TOKEN = os.environ.get('APP_GITHUB_OAUTH_ACCESS_TOKEN')
GITLAB_OAUTH_ACCESS_TOKEN = os.environ.get('APP_GITLAB_OAUTH_ACCESS_TOKEN')
# Reana server url
# ================
REANA_ACCESS_TOKEN = {
'ATLAS': os.environ.get('APP_REANA_ATLAS_ACCESS_TOKEN'),
'ALICE': os.environ.get('APP_REANA_ALICE_ACCESS_TOKEN'),
'CMS': os.environ.get('APP_REANA_CMS_ACCESS_TOKEN'),
'LHCb': os.environ.get('APP_REANA_LHCb_ACCESS_TOKEN')
}
# Keytabs
KEYTABS_LOCATION = os.environ.get('APP_KEYTABS_LOCATION', '/etc/keytabs')
KRB_PRINCIPALS = {'CADI': (CMS_USER_PRINCIPAL, CMS_USER_KEYTAB)}
CERN_CERTS_PEM = os.environ.get('APP_CERN_CERTS_PEM')
# Zenodo
# ======
ZENODO_SERVER_URL = os.environ.get('APP_ZENODO_SERVER_URL',
'https://zenodo.org/api')
ZENODO_ACCESS_TOKEN = os.environ.get('APP_ZENODO_ACCESS_TOKEN', 'CHANGE_ME')
# Endpoints
# =========
DEPOSIT_UI_ENDPOINT = '{scheme}://{host}/drafts/{pid_value}'
RECORDS_UI_ENDPOINT = '{scheme}://{host}/published/{pid_value}'
# Webhooks & ngrok init
# =====================
# In order to debug webhooks, we need a tunnel to our local instance
# so we make sure that we have an ngrok tunnel running, and add it
# to the allowed hosts (to enable requests)
TEST_WITH_NGROK = os.environ.get('CAP_TEST_WITH_NGROK', 'False')
if DEBUG and TEST_WITH_NGROK == 'True':
try:
resp = requests.get('http://localhost:4040/api/tunnels',
headers={'Content-Type': 'application/json'})
NGROK_HOST = resp.json()['tunnels'][0]['public_url']
APP_ALLOWED_HOSTS.append(NGROK_HOST.split('//')[-1])
WEBHOOK_NGROK_URL = '{}/repos/event'.format(NGROK_HOST)
print('* Webhook url at {}'.format(WEBHOOK_NGROK_URL))
except Exception as e:
print('Cannot fetch ngrok host.\n'
'Use CAP_TEST_WITH_NGROK=False if dont want to use it.\n'
f'Exception: {str(e)}.')
WEBHOOK_ENDPOINT = 'cap_repos.get_webhook_event'
LOGGING_FS_LOGFILE = os.environ.get('CAP_LOG_FILE')
# SENTRY_DSN = 'CHANGE_ME'
"""Set SENTRY_DSN environment variable."""
LOGGING_SENTRY_PYWARNINGS = False
"""Enable logging of Python warnings to Sentry."""
LOGGING_SENTRY_CELERY = True
"""Configure Celery to send logging to Sentry."""
DB_EXTRA_PLUGINS = ['sqlalchemy_continuum.plugins.ActivityPlugin']