From 3aa687278413843aa6e946244b7b0fa0c2696be6 Mon Sep 17 00:00:00 2001
From: lb584 <lb584@cam.ac.uk>
Date: Wed, 19 Jun 2024 13:21:30 +0100
Subject: [PATCH] adding warning when using double tokens in configs

---
 ews/coordinator/utils/processor_utils.py                     | 5 +++++
 .../configs/coordinator/template_sys_config_EastAfrica.json  | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/ews/coordinator/utils/processor_utils.py b/ews/coordinator/utils/processor_utils.py
index 7ea9811..2ff6104 100644
--- a/ews/coordinator/utils/processor_utils.py
+++ b/ews/coordinator/utils/processor_utils.py
@@ -137,6 +137,11 @@ def parse_json_file_with_tokens(file_path: str, tokens: dict = None) -> dict:
         if tokens is not None:
             # reparse the string with any other tokens passed in as arguments
             parsed_file_string: str = Template(parsed_file_string).safe_substitute(**tokens)
+
+        if "${" in file_string:
+            logger.warning(f"\n\nUNRESOLVED TOKENS IN THE CONFIG FILE: {file_path} - THIS MAY BE BECAUSE YOU ARE DECLARING "
+                           f"VALUES WHICH INCLUDE A TOKEN, WHERE THE VALUE OF THE TOKEN ITS SELF USES A TOKEN. YOU CAN "
+                           f"NOT DECLARE TOKENS WHICH DEPEND ON OTHER TOKENS\n\n")
         # finally, parse the tokenized string as a json dict
         result = json.loads(parsed_file_string)
 
diff --git a/pipeline_resources/configs/coordinator/template_sys_config_EastAfrica.json b/pipeline_resources/configs/coordinator/template_sys_config_EastAfrica.json
index d6e0dda..73b5719 100644
--- a/pipeline_resources/configs/coordinator/template_sys_config_EastAfrica.json
+++ b/pipeline_resources/configs/coordinator/template_sys_config_EastAfrica.json
@@ -9,6 +9,6 @@
     "WorkspacePath" : "${ProjectRoot}/regions/EastAfrica/workspace",
     "ConfigsPath" : "${ProjectRoot}/code/coordinator/pipeline_resources/configs",
     "AssetsPath" : "${ProjectRoot}/regions/EastAfrica/resources/assets",
-    "LoggingConfigPath" : "${ConfigsPath}/coordinator/log_config.json",
+    "LoggingConfigPath" : "${ProjectRoot}/code/coordinator/pipeline_resources/configs/coordinator/log_config.json",
     "PLACES_SHAPE_FILE": "${ProjectRoot}/regions/EastAfrica/resources/assets/plotting/gis_data/common/places_shape/east_africa_places.shp"
 }
-- 
GitLab