Commit 2b2e7faa authored by Robin's avatar Robin

specs now cached

parent 93150026
......@@ -16,8 +16,8 @@ ENV READ_SPECS_FROM_DISK=False
ENV READ_BLUEPRINTS_FROM_DISK=False
ENV PLATFORM_ENDPOINT=172.18.1.9:1026
ENV PLATFORM_ENDPOINT_HISTORIC=172.18.1.9:1026
ENV SPECS_BASE_PATH=https://gitlab.distantaccess.com/naiades/dmv_public/-/raw/master/specs
ENV REMOTE_SPECS_BASE_PATH=https://gitlab.distantaccess.com/naiades/dmv_public/-/raw/master/specs
# ENV SIGNATURE_SERVICE_ENDPOINT=TBD
#________________________________________
RUN useradd -ms /bin/bash naiades
......
......@@ -2,7 +2,21 @@
import os
SPECS_BASE_PATH = "https://gitlab.distantaccess.com/naiades/dmv_public/-/raw/master/specs"
DEPLOYMENT_ENV = 'PROD' # PROD or DEV
APP_CONFIG = {
'SPECS_TIMEOUT_SEC': os.environ.get('SPECS_TIMEOUT_SEC', 10),
'PLATFORM_TIMEOUT_SEC': os.environ.get('PLATFORM_TIMEOUT_SEC', 10),
'READ_SPECS_FROM_DISK': bool(os.environ.get('READ_SPECS_FROM_DISK', False)),
'READ_BLUEPRINTS_FROM_DISK': bool(os.environ.get('READ_BLUEPRINTS_FROM_DISK', False)),
'PLATFORM_ENDPOINT': os.environ.get('PLATFORM_ENDPOINT'),
'PLATFORM_ENDPOINT_HISTORIC': os.environ.get('PLATFORM_ENDPOINT_HISTORIC'),
'SIGNATURE_SERVICE_ENDPOINT': '',
'BLUEPRINTS_ABS_PATH': os.environ.get('BLUEPRINTS_ABS_PATH', '/home/naiades/specs/'),
'SPECS_ABS_PATH': os.environ.get('SPECS_ABS_PATH', '/home/naiades/specs/'),
'REMOTE_SPECS_BASE_PATH': os.environ.get('REMOTE_SPECS_BASE_PATH'),
}
def get_resource_urls() -> dict:
......@@ -23,47 +37,35 @@ def get_resource_urls() -> dict:
specs_url_convention = RESOURCE_CONFIG["NAME_CONVENTIONS"]["URL_CONFIGNAME_CONVENTIONS"]["SPECS"]
blueprint_url_convention = RESOURCE_CONFIG["NAME_CONVENTIONS"]["URL_CONFIGNAME_CONVENTIONS"]["BLUEPRINTS"]
base_path = APP_CONFIG['REMOTE_SPECS_BASE_PATH']
for modelname in USED_MODELS:
specs_url = specs_url_convention.format(modelname=modelname.upper())
blueprint_ld_url = blueprint_url_convention.format(modeltype='LD', modelname=modelname.upper())
blueprint_v2_url = blueprint_url_convention.format(modeltype='V2', modelname=modelname.upper())
urls[specs_url] = f'{SPECS_BASE_PATH}/{specs_file_convention.format(modelname=modelname)}'
urls[blueprint_ld_url] = f'{SPECS_BASE_PATH}/{blueprint_file_convention.format(modeltype="LD",modelname=modelname)}'
urls[blueprint_v2_url] = f'{SPECS_BASE_PATH}/{blueprint_file_convention.format(modeltype="V2",modelname=modelname)}'
urls[specs_url] = f'{base_path}/{specs_file_convention.format(modelname=modelname)}'
urls[blueprint_ld_url] = f'{base_path}/{blueprint_file_convention.format(modeltype="LD",modelname=modelname)}'
urls[blueprint_v2_url] = f'{base_path}/{blueprint_file_convention.format(modeltype="V2",modelname=modelname)}'
return urls
DEPLOYMENT_ENV = 'DEV' # PROD or DEV
APP_CONFIG = {
'SPECS_TIMEOUT_SEC': os.environ.get('SPECS_TIMEOUT_SEC', 10),
'PLATFORM_TIMEOUT_SEC': os.environ.get('PLATFORM_TIMEOUT_SEC', 10),
'READ_SPECS_FROM_DISK': bool(os.environ.get('READ_SPECS_FROM_DISK', False)),
'READ_BLUEPRINTS_FROM_DISK': bool(os.environ.get('READ_BLUEPRINTS_FROM_DISK', False)),
'PLATFORM_ENDPOINT': os.environ.get('PLATFORM_ENDPOINT'),
'PLATFORM_ENDPOINT_HISTORIC': os.environ.get('PLATFORM_ENDPOINT_HISTORIC'),
'BLUEPRINTS_ABS_PATH': os.environ.get('BLUEPRINTS_ABS_PATH', '/home/naiades/specs/'),
'SPECS_ABS_PATH': os.environ.get('SPECS_ABS_PATH', '/home/naiades/specs/')
}
RESOURCE_CONFIG = {
# example: modelname = FlowerBed
# example: modeltype = LD / V2
"NAME_CONVENTIONS": {
# modelname Case sensitive e.g. FlowerBed, modeltype Uppercase e.g. LD or V2
# modelname Camelcase e.g. FlowerBed,
# modeltype Uppercase e.g. LD or V2
"FILE_NAME_CONVENTIONS": {
"SPECS": 'Specs_{modelname}.json',
"BLUEPRINTS": "{modeltype}_Blueprint_{modelname}.json",
# ""
},
# Upper Case
# modelname && modeltype Upper Case
"URL_CONFIGNAME_CONVENTIONS": {
"SPECS": 'SPECS_{modelname}_URL',
"BLUEPRINTS": '{modeltype}_BLUEPRINT_{modelname}_URL'
},
# Upper Case
# modelname && modeltype Upper Case
"CACHE_NAME_CONVENTIONS": {
"SPECS": 'SPECS_{modelname}',
"BLUEPRINTS": "{modeltype}_BLUEPRINT_{modelname}",
......
This diff is collapsed.
......@@ -236,7 +236,8 @@ class Connector(object):
"""
try:
blueprint_url = current_app.config["URL_RESOURCES"]["URL_NAME_CONVENTIONS"]["BLUEPRINTS"]
i = 0
blueprint_url = RESOURCE_CONFIG["NAME_CONVENTIONS"]["URL_CONFIGNAME_CONVENTIONS"]["BLUEPRINTS"]
blueprint_url = blueprint_url.format(modeltype=model_version.upper(),
modelname=model_type.upper()) # '{modeltype}_BLUEPRINT_{modelname}_URL'
url = URL_RESOURCES[blueprint_url]
......@@ -418,7 +419,7 @@ def load_url_resources(model_name: str = '*'):
ValidationException: in error case during loading
"""
current_app.logger.warning(f'<<{__name__}>> Start loading url resources for `{model_name}` to cache.')
current_app.logger.info(f'<<{__name__}>> Start loading url resources for `{model_name}` to cache.')
conn = Connector(reads_from_disk=current_app.config['READ_SPECS_FROM_DISK'])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment