From d32c158c12c5e2600df2e49f38109a8434827719 Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Fri, 10 Jan 2025 18:23:48 -0600 Subject: [PATCH] Remove + operators from multiline string concats (#922) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Pull Request ## Title Remove + operators from multiline string concats --- ## Description - Closes #919 --- ## Type of Change - 🔄 Refactor --- --- .../tests/launcher_parse_args_test.py | 32 +++++++++---------- .../mlos_bench/tests/launcher_run_test.py | 20 ++++++------ .../bayesian_optimizers/smac_optimizer.py | 4 +-- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/mlos_bench/mlos_bench/tests/launcher_parse_args_test.py b/mlos_bench/mlos_bench/tests/launcher_parse_args_test.py index 2b848d281a..6294ee8bf3 100644 --- a/mlos_bench/mlos_bench/tests/launcher_parse_args_test.py +++ b/mlos_bench/mlos_bench/tests/launcher_parse_args_test.py @@ -144,11 +144,11 @@ def test_launcher_args_parse_1(config_paths: list[str]) -> None: + " ".join(config_paths) + " --num-trial-runners 5" + " --service services/remote/mock/mock_auth_service.jsonc" - + " services/remote/mock/mock_remote_exec_service.jsonc" - + " --scheduler schedulers/sync_scheduler.jsonc" - + f" --environment {ENV_CONF_PATH}" - + " --globals globals/global_test_config.jsonc" - + " --globals globals/global_test_extra_config.jsonc" + " services/remote/mock/mock_remote_exec_service.jsonc" + " --scheduler schedulers/sync_scheduler.jsonc" + f" --environment {ENV_CONF_PATH}" + " --globals globals/global_test_config.jsonc" + " --globals globals/global_test_extra_config.jsonc" " --test_global_value_2 from-args" ) launcher = _get_launcher(__name__, cli_args) @@ -203,15 +203,15 @@ def test_launcher_args_parse_2(config_paths: list[str]) -> None: cli_args = ( " ".join([f"--config-path {config_path}" for config_path in config_paths]) + f" --config {config_file}" - + " --service services/remote/mock/mock_auth_service.jsonc" - + " --service services/remote/mock/mock_remote_exec_service.jsonc" - + f" --globals {globals_file}" - + " --experiment_id MockeryExperiment" - + " --no-teardown" - + " --random-init" - + " --random-seed 1234" - + " --trial-config-repeat-count 5" - + " --max_trials 200" + " --service services/remote/mock/mock_auth_service.jsonc" + " --service services/remote/mock/mock_remote_exec_service.jsonc" + f" --globals {globals_file}" + " --experiment_id MockeryExperiment" + " --no-teardown" + " --random-init" + " --random-seed 1234" + " --trial-config-repeat-count 5" + " --max_trials 200" ) launcher = _get_launcher(__name__, cli_args) # Check some additional features of the the parent service @@ -294,8 +294,8 @@ def test_launcher_args_parse_3(config_paths: list[str]) -> None: cli_args = ( " ".join([f"--config-path {config_path}" for config_path in config_paths]) + f" --config {config_file}" - + f" --globals {globals_file}" - + " --max-suggestions 10" # check for - to _ conversion too + f" --globals {globals_file}" + " --max-suggestions 10" # check for - to _ conversion too ) launcher = _get_launcher(__name__, cli_args) diff --git a/mlos_bench/mlos_bench/tests/launcher_run_test.py b/mlos_bench/mlos_bench/tests/launcher_run_test.py index bd3a147452..61c4679f02 100644 --- a/mlos_bench/mlos_bench/tests/launcher_run_test.py +++ b/mlos_bench/mlos_bench/tests/launcher_run_test.py @@ -54,8 +54,8 @@ def _launch_main_app( (return_code, _stdout, _stderr) = local_exec_service.local_exec( [ "./mlos_bench/mlos_bench/run.py" - + " --config_path ./mlos_bench/mlos_bench/tests/config/" - + f" {cli_config} --log_file '{log_path}'" + " --config_path ./mlos_bench/mlos_bench/tests/config/" + f" {cli_config} --log_file '{log_path}'" ], cwd=root_path, ) @@ -84,8 +84,8 @@ def test_launch_main_app_bench(root_path: str, local_exec_service: LocalExecServ root_path, local_exec_service, " --config cli/mock-bench.jsonc" - + " --trial_config_repeat_count 5" - + " --mock_env_seed -1", # Deterministic Mock Environment. + " --trial_config_repeat_count 5" + " --mock_env_seed -1", # Deterministic Mock Environment. [ f"^{_RE_DATE} run\\.py:\\d+ " + r"_main INFO Final score: \{'score': 67\.40\d+\}\s*$", ], @@ -103,9 +103,9 @@ def test_launch_main_app_bench_values( root_path, local_exec_service, " --config cli/mock-bench.jsonc" - + " --tunable_values tunable-values/tunable-values-example.jsonc" - + " --trial_config_repeat_count 5" - + " --mock_env_seed -1", # Deterministic Mock Environment. + " --tunable_values tunable-values/tunable-values-example.jsonc" + " --trial_config_repeat_count 5" + " --mock_env_seed -1", # Deterministic Mock Environment. [ f"^{_RE_DATE} run\\.py:\\d+ " + r"_main INFO Final score: \{'score': 67\.11\d+\}\s*$", ], @@ -120,9 +120,9 @@ def test_launch_main_app_opt(root_path: str, local_exec_service: LocalExecServic root_path, local_exec_service, "--config cli/mock-opt.jsonc" - + " --trial_config_repeat_count 3" - + " --max_suggestions 3" - + " --mock_env_seed 42", # Noisy Mock Environment. + " --trial_config_repeat_count 3" + " --max_suggestions 3" + " --mock_env_seed 42", # Noisy Mock Environment. [ # Iteration 1: Expect first value to be the baseline f"^{_RE_DATE} mlos_core_optimizer\\.py:\\d+ " diff --git a/mlos_core/mlos_core/optimizers/bayesian_optimizers/smac_optimizer.py b/mlos_core/mlos_core/optimizers/bayesian_optimizers/smac_optimizer.py index 38e0b276bf..910b75d717 100644 --- a/mlos_core/mlos_core/optimizers/bayesian_optimizers/smac_optimizer.py +++ b/mlos_core/mlos_core/optimizers/bayesian_optimizers/smac_optimizer.py @@ -193,8 +193,8 @@ def __init__( if n_random_init > 0.25 * max_trials and max_ratio is None: warning( "Number of random initial configs (%d) is " - + "greater than 25%% of max_trials (%d). " - + "Consider setting max_ratio to avoid SMAC overriding n_random_init.", + "greater than 25%% of max_trials (%d). " + "Consider setting max_ratio to avoid SMAC overriding n_random_init.", n_random_init, max_trials, )