From f2e9a3ccbfad0ae4580ec3c6b869e34848fb0e34 Mon Sep 17 00:00:00 2001 From: David Joy <10147749+dmjoy@users.noreply.github.com> Date: Wed, 6 Dec 2023 16:11:47 -0500 Subject: [PATCH] Fixed setting the loglevel in CLI scripts --- CHANGELOG.md | 4 ++++ align_system/cli/run_action_based_align_system.py | 4 +++- align_system/cli/run_action_based_chat_baseline.py | 4 +++- align_system/cli/run_align_system.py | 4 +++- align_system/cli/run_chat_baseline.py | 4 +++- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f9e73dda..afc343d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm * Added `allow_extraneous` option to `format_template` function to ignore extraneous kwargs +### Fixed + +* Fixed setting the `loglevel` in CLI scripts + ## Version 0.2.3 diff --git a/align_system/cli/run_action_based_align_system.py b/align_system/cli/run_action_based_align_system.py index df156725..61bdd45f 100644 --- a/align_system/cli/run_action_based_align_system.py +++ b/align_system/cli/run_action_based_align_system.py @@ -92,7 +92,9 @@ def run_action_based_align_system(interface, algorithm_kwargs=None, similarity_measure="bert", loglevel="INFO"): - log.setLevel(loglevel) + # Set log level on root logger (such that child loggers respect + # the set log level) + logging.getLogger().setLevel(loglevel) scenario = interface.start_scenario() scenario_dict = scenario.to_dict() diff --git a/align_system/cli/run_action_based_chat_baseline.py b/align_system/cli/run_action_based_chat_baseline.py index 9f0cf579..d13c60e6 100644 --- a/align_system/cli/run_action_based_chat_baseline.py +++ b/align_system/cli/run_action_based_chat_baseline.py @@ -74,7 +74,9 @@ def run_action_based_chat_system(interface, align_to_target=False, answer_attempts=5, loglevel="INFO"): - log.setLevel(loglevel) + # Set log level on root logger (such that child loggers respect + # the set log level) + logging.getLogger().setLevel(loglevel) scenario = interface.start_scenario() scenario_dict = scenario.to_dict() diff --git a/align_system/cli/run_align_system.py b/align_system/cli/run_align_system.py index 9be6e5b8..f7169a7b 100644 --- a/align_system/cli/run_align_system.py +++ b/align_system/cli/run_align_system.py @@ -63,7 +63,9 @@ def run_align_system(interface, algorithm_kwargs=None, similarity_measure="bert", loglevel="INFO"): - log.setLevel(loglevel) + # Set log level on root logger (such that child loggers respect + # the set log level) + logging.getLogger().setLevel(loglevel) scenario = interface.start_scenario() scenario_dict = scenario.to_dict() diff --git a/align_system/cli/run_chat_baseline.py b/align_system/cli/run_chat_baseline.py index 8cb7153c..7642b4af 100644 --- a/align_system/cli/run_chat_baseline.py +++ b/align_system/cli/run_chat_baseline.py @@ -61,7 +61,9 @@ def run_custom_system(interface, precision, align_to_target, loglevel="INFO"): - log.setLevel(loglevel) + # Set log level on root logger (such that child loggers respect + # the set log level) + logging.getLogger().setLevel(loglevel) log.info('Creating algorithm') algorithm = Llama2SingleKDMAADM(hf_model=model, precision=precision)