diff --git a/datagateway_api/config.json.example b/datagateway_api/config.json.example deleted file mode 100644 index 1b86bf57..00000000 --- a/datagateway_api/config.json.example +++ /dev/null @@ -1,29 +0,0 @@ -{ - "datagateway_api": { - "extension": "/datagateway-api", - "backend": "python_icat", - "client_cache_size": 5, - "client_pool_init_size": 2, - "client_pool_max_size": 5, - "db_url": "mysql+pymysql://icatdbuser:icatdbuserpw@localhost:3306/icatdb", - "icat_url": "https://localhost:8181", - "icat_check_cert": false - }, - "search_api": { - "extension": "/search-api", - "icat_url": "https://localhost:8181", - "icat_check_cert": false, - "mechanism": "anon", - "username": "", - "password": "" - }, - "flask_reloader": false, - "log_level": "WARN", - "log_location": "/home/runner/work/datagateway-api/datagateway-api/logs.log", - "debug_mode": false, - "generate_swagger": false, - "host": "127.0.0.1", - "port": "5000", - "test_user_credentials": {"username": "root", "password": "pw"}, - "test_mechanism": "simple" -} diff --git a/datagateway_api/src/common/config.py b/datagateway_api/src/common/config.py index f51aadf1..39a30e39 100644 --- a/datagateway_api/src/common/config.py +++ b/datagateway_api/src/common/config.py @@ -1,4 +1,4 @@ -import json, yaml +import yaml import logging from pathlib import Path import sys @@ -186,17 +186,9 @@ def load(cls, path=Path(__file__).parent.parent.parent / "config.yaml"): :param path: path to the configuration file :return: APIConfig model object that contains the config data """ - log = logging.getLogger() try: - jpath = path.parent / "config.json" #Maybe move this to parameters? Will doing it like this break anything? - if path.exists(): - with open(path, encoding="utf-8") as target: + with open(path, encoding="utf-8") as target: data = yaml.safe_load(target) - - elif jpath.exists(): - log.warn("DEPRECATED: Using a JSON config file is deprecated and may be removed in an upcoming version. Please use a yaml config file instead.") #Does this message need to exist? - with open(jpath, encoding="utf-8") as target: - data = json.load(target) return cls(**data) except (IOError, ValidationError) as error: sys.exit(f"An error occurred while trying to load the config data: {error}")