From 302042f557083cc583ba3dd9f161a68e6fa1f086 Mon Sep 17 00:00:00 2001 From: Matthew Richards Date: Fri, 30 Apr 2021 09:04:45 +0000 Subject: [PATCH] #228: Make certain config options optional - Explained in the docstring --- datagateway_api/common/config.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/datagateway_api/common/config.py b/datagateway_api/common/config.py index 80665aab..79746318 100644 --- a/datagateway_api/common/config.py +++ b/datagateway_api/common/config.py @@ -46,24 +46,27 @@ def _check_config_items_exist(self): """ A function to check that all config options exist before getting too far into the setup of the API. This check takes the backend into account, meaning only - the config options for the backend used is required - - Config options used for testing are not checked here as they should only be used - during tests, not in the typical running of the API + the config options for the backend used is required. If a config option is missing, this will be picked up in `get_config_value()` by exiting the application + + Config options used for testing are not checked here as they should only be used + during tests, not in the typical running of the API. + + Some options used when running the API (host, debug_mode etc.) aren't mandatory + when running the API in production (these options aren't used in the `wsgi.py` + entrypoint). As a result, they're not present in `config_keys`. However, they + are required when using `main.py` as an entrypoint. In any case of these + specific missing config options when using that entrypoint, they are checked at + API startup so any missing options will be caught quickly. """ # These keys are non-backend specific and therefore are mandatory for all uses config_keys = [ APIConfigOptions.BACKEND, - APIConfigOptions.DEBUG_MODE, - APIConfigOptions.FLASK_RELOADER, APIConfigOptions.GENERATE_SWAGGER, - APIConfigOptions.HOST, APIConfigOptions.LOG_LEVEL, APIConfigOptions.LOG_LOCATION, - APIConfigOptions.PORT, ] if self.get_config_value(APIConfigOptions.BACKEND) == "python_icat":