From d79f96a5b438025731ffc823e56e0539351b6c6b Mon Sep 17 00:00:00 2001 From: TheNetworkGuy Date: Mon, 16 Jun 2025 10:03:58 +0000 Subject: [PATCH 1/3] Add unittests to build process --- .github/workflows/publish-image.yml | 4 +++- .github/workflows/run_tests.yml | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish-image.yml b/.github/workflows/publish-image.yml index c18dc39..ef580f7 100644 --- a/.github/workflows/publish-image.yml +++ b/.github/workflows/publish-image.yml @@ -8,7 +8,9 @@ on: jobs: test_quality: - uses: ./.github/workflows/quality.yml + uses: ./.github/workflows/quality.yml + test_code: + uses: ./.github/workflows/run_tests.yml build: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index c434213..a22b008 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -4,6 +4,7 @@ name: Pytest code testing on: push: pull_request: + workflow_call: jobs: test_code: From 940f2d6afb97eebb5eaaa55df45b609ac55c5f2a Mon Sep 17 00:00:00 2001 From: TheNetworkGuy Date: Mon, 16 Jun 2025 11:13:36 +0000 Subject: [PATCH 2/3] Re-added some git logic to the pipeline which was lost during development --- .github/workflows/publish-image.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/publish-image.yml b/.github/workflows/publish-image.yml index ef580f7..4b224ab 100644 --- a/.github/workflows/publish-image.yml +++ b/.github/workflows/publish-image.yml @@ -5,6 +5,10 @@ on: push: branches: - main + release: + types: [published] + pull_request: + types: [opened, synchronize] jobs: test_quality: From dec2cf6996926e36d70f77ab09f99a154f349c07 Mon Sep 17 00:00:00 2001 From: TheNetworkGuy Date: Mon, 16 Jun 2025 14:04:10 +0000 Subject: [PATCH 3/3] Fixed bug in which custom config.py module was not accessed --- modules/config.py | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/modules/config.py b/modules/config.py index 9f97c83..a105892 100644 --- a/modules/config.py +++ b/modules/config.py @@ -3,7 +3,7 @@ Module for parsing configuration from the top level config.py file """ from pathlib import Path from importlib import util -from os import environ +from os import environ, path from logging import getLogger logger = getLogger(__name__) @@ -104,18 +104,25 @@ def load_env_variable(config_environvar): def load_config_file(config_default, config_file="config.py"): """Returns config from config.py file""" - # Check if config.py exists and load it - # If it does not exist, return the default config - config_path = Path(config_file) - if config_path.exists(): - dconf = config_default.copy() - # Dynamically import the config module - spec = util.spec_from_file_location("config", config_path) - config_module = util.module_from_spec(spec) - spec.loader.exec_module(config_module) - # Update DEFAULT_CONFIG with variables from the config module - for key in dconf: - if hasattr(config_module, key): - dconf[key] = getattr(config_module, key) - return dconf - return config_default + # Find the script path and config file next to it. + script_dir = path.dirname(path.dirname(path.abspath(__file__))) + config_path = Path(path.join(script_dir, config_file)) + + # If the script directory is not found, try the current working directory + if not config_path.exists(): + config_path = Path(config_file) + + # If both checks fail then fallback to the default config + if not config_path.exists(): + return config_default + + dconf = config_default.copy() + # Dynamically import the config module + spec = util.spec_from_file_location("config", config_path) + config_module = util.module_from_spec(spec) + spec.loader.exec_module(config_module) + # Update DEFAULT_CONFIG with variables from the config module + for key in dconf: + if hasattr(config_module, key): + dconf[key] = getattr(config_module, key) + return dconf