From 9388cf522cc6cf65744fb51e8f772804ebf166b8 Mon Sep 17 00:00:00 2001 From: MialLewis <95620982+MialLewis@users.noreply.github.com> Date: Tue, 19 Dec 2023 11:06:34 +0000 Subject: [PATCH] enable setting of config dir by env var --- .github/workflows/pr_workflow.yml | 4 +++- EVSVesuvio/scripts/handle_config.py | 13 +++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr_workflow.yml b/.github/workflows/pr_workflow.yml index bbf33f79..fc48cf67 100644 --- a/.github/workflows/pr_workflow.yml +++ b/.github/workflows/pr_workflow.yml @@ -38,7 +38,9 @@ jobs: # Runs System tests - name: Run EVSVesuvio Analysis System Tests - run: python -m unittest discover -s ./EVSVesuvio/system_tests + run: | + export VESUVIOPROPERTIES=$(pwd)/EVSVesuvio/config/vesuvio.user.properties + python -m unittest discover -s ./EVSVesuvio/system_tests - name: Run EVSVesuvio Calibration Unit Tests run: | diff --git a/EVSVesuvio/scripts/handle_config.py b/EVSVesuvio/scripts/handle_config.py index c3cb394c..52ad014f 100644 --- a/EVSVesuvio/scripts/handle_config.py +++ b/EVSVesuvio/scripts/handle_config.py @@ -1,8 +1,7 @@ import os from shutil import copyfile, copytree, ignore_patterns -VESUVIO_CONFIG_PATH = os.path.join(os.path.expanduser("~"), ".mvesuvio") -VESUVIO_CONFIG_FILE = "vesuvio.user.properties" +VESUVIO_CONFIG_PATH, VESUVIO_CONFIG_FILE = __parse_properties_env_var() VESUVIO_INPUTS_FILE = "analysis_inputs.py" VESUVIO_PACKAGE_PATH = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) MANTID_CONFIG_FILE = "Mantid.user.properties" @@ -117,3 +116,13 @@ def check_dir_exists(type, path): print(f"Directory of {type} could not be found at location: {path}") return False return True + + +def __parse_properties_env_var(): + env_var = os.getenv('VESUVIOPROPERTIES') + if env_var: + config_path, config_file = os.path.split(env_var) + else: + config_path = os.path.join(os.path.expanduser("~"), ".mvesuvio") + config_file = "vesuvio.user.properties" + return config_path, config_file \ No newline at end of file