From e357f532204c4265c5b3818aad6095f0722960b4 Mon Sep 17 00:00:00 2001 From: ChrisFajardo-TRI <85368718+ChrisFajardo-TRI@users.noreply.github.com> Date: Thu, 11 Aug 2022 12:54:35 -0700 Subject: [PATCH] recipe path derived from file structure so that configs can be loaded from any working directory --- vidar/utils/config.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/vidar/utils/config.py b/vidar/utils/config.py index 23c8d1b..f3f479c 100644 --- a/vidar/utils/config.py +++ b/vidar/utils/config.py @@ -14,6 +14,15 @@ from vidar.utils.types import is_dict, is_list, is_namespace +RECIPE_DIR = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + os.pardir, + os.pardir, + 'configs', + 'recipes' +) + + def cfg_has(*args): """ Check if a key is in configuration @@ -198,7 +207,7 @@ def recursive_recipe(cfg, super_key=None): if is_dict(cfg[key]): cfg[key] = recursive_recipe(cfg[key], super_key=key) elif key == 'recipe': - recipe = 'configs/recipes/' + cfg.pop(key) + recipe = os.path.join(RECIPE_DIR, cfg.pop(key)) if '|' in recipe: recipe, super_key = recipe.split('|') recipe = read_config(recipe + '.yaml')