From 42af969f35114c48b844e9f4a4664fb093b789ce Mon Sep 17 00:00:00 2001 From: Meganton Date: Fri, 8 Nov 2024 17:12:05 +0100 Subject: [PATCH] renamed run_pipline args to evaluate pipeline --- neps/utils/cli.py | 6 +++--- neps/utils/run_args.py | 6 +++--- .../test_declarative_usage_docs/neps_run.py | 6 +++--- .../test_declarative_usage_docs.py | 2 +- tests/test_yaml_run_args/test_yaml_run_args.py | 8 ++++---- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/neps/utils/cli.py b/neps/utils/cli.py index 2b1c3afb..67d67a7b 100644 --- a/neps/utils/cli.py +++ b/neps/utils/cli.py @@ -286,14 +286,14 @@ def run_optimization(args: argparse.Namespace) -> None: run_args = Path("run_config.yaml") else: run_args = args.run_args - if not isinstance(args.run_pipeline, Default): - module_path, function_name = args.run_pipeline.split(":") + if not isinstance(args.evaluate_pipeline, Default): + module_path, function_name = args.evaluate_pipeline.split(":") evaluate_pipeline = load_and_return_object( module_path, function_name, EVALUATE_PIPELINE ) else: - evaluate_pipeline = args.run_pipeline + evaluate_pipeline = args.evaluate_pipeline kwargs = {} if args.searcher_kwargs: diff --git a/neps/utils/run_args.py b/neps/utils/run_args.py index 6f32c359..2fbd740c 100644 --- a/neps/utils/run_args.py +++ b/neps/utils/run_args.py @@ -49,7 +49,7 @@ def get_run_args_from_yaml(path: str | Path) -> dict: validates these arguments, and then returns them in a dictionary. It checks for the presence and validity of expected parameters, and distinctively handles more complex configurations, specifically those that are dictionaries(e.g. pipeline_space) or - objects(e.g. run_pipeline) requiring loading. + objects(e.g. evaluate_pipeline) requiring loading. Args: path (str): The file path to the YAML configuration file. @@ -67,7 +67,7 @@ def get_run_args_from_yaml(path: str | Path) -> dict: settings = {} # List allowed NePS run arguments with simple types (e.g., string, int). Parameters - # like 'run_pipeline', 'preload_hooks', 'pipeline_space', + # like 'evaluate_pipeline', 'preload_hooks', 'pipeline_space', # and 'searcher' are excluded due to needing specialized processing. expected_parameters = [ ROOT_DIRECTORY, @@ -146,7 +146,7 @@ def config_loader(path: str | Path) -> dict: def extract_leaf_keys(d: dict, special_keys: dict | None = None) -> tuple[dict, dict]: """Recursive function to extract leaf keys and their values from a nested dictionary. - Special keys (e.g.'run_pipeline') are also extracted if present + Special keys (e.g.'evaluate_pipeline') are also extracted if present and their corresponding values (dict) at any level in the nested structure. Args: diff --git a/tests/test_yaml_run_args/test_declarative_usage_docs/neps_run.py b/tests/test_yaml_run_args/test_declarative_usage_docs/neps_run.py index 6bf37202..b1d18fc3 100644 --- a/tests/test_yaml_run_args/test_declarative_usage_docs/neps_run.py +++ b/tests/test_yaml_run_args/test_declarative_usage_docs/neps_run.py @@ -23,10 +23,10 @@ def evaluate_pipeline_constant(learning_rate, optimizer, epochs, batch_size): description="Run NEPS optimization with run_args.yml." ) parser.add_argument("run_args", type=str, help="Path to the YAML configuration file.") - parser.add_argument("--run_pipeline", action="store_true") + parser.add_argument("--evaluate_pipeline", action="store_true") args = parser.parse_args() - if args.run_pipeline: - neps.run(run_args=args.run_args, evaluate_pipeline=run_pipeline_constant) + if args.evaluate_pipeline: + neps.run(run_args=args.run_args, evaluate_pipeline=evaluate_pipeline_constant) else: neps.run(run_args=args.run_args) diff --git a/tests/test_yaml_run_args/test_declarative_usage_docs/test_declarative_usage_docs.py b/tests/test_yaml_run_args/test_declarative_usage_docs/test_declarative_usage_docs.py index 3b49ae05..4a026689 100644 --- a/tests/test_yaml_run_args/test_declarative_usage_docs/test_declarative_usage_docs.py +++ b/tests/test_yaml_run_args/test_declarative_usage_docs/test_declarative_usage_docs.py @@ -48,7 +48,7 @@ def test_run_with_yaml_and_run_pipeline() -> None: try: subprocess.check_call( - [sys.executable, BASE_PATH / "neps_run.py", yaml_path, "--run_pipeline"] + [sys.executable, BASE_PATH / "neps_run.py", yaml_path, "--evaluate_pipeline"] ) except subprocess.CalledProcessError as e: pytest.fail( diff --git a/tests/test_yaml_run_args/test_yaml_run_args.py b/tests/test_yaml_run_args/test_yaml_run_args.py index d02e4f63..7995d953 100644 --- a/tests/test_yaml_run_args/test_yaml_run_args.py +++ b/tests/test_yaml_run_args/test_yaml_run_args.py @@ -80,7 +80,7 @@ def are_functions_equivalent( # Compare keys with a function/list of functions as their values # Special because they include a module loading procedure by a path and the name of # the function - for special_key in ["run_pipeline", "pre_load_hooks"]: + for special_key in ["evaluate_pipeline", "pre_load_hooks"]: if special_key in expected_output: func_expected = expected_output.pop(special_key) func_output = output.pop(special_key) @@ -105,7 +105,7 @@ def are_functions_equivalent( ( "run_args_full.yaml", { - "run_pipeline": evaluate_pipeline, + "evaluate_pipeline": evaluate_pipeline, "pipeline_space": pipeline_space, "root_directory": "test_yaml", "max_evaluations_total": 20, @@ -129,7 +129,7 @@ def are_functions_equivalent( ( "run_args_full_same_level.yaml", { - "run_pipeline": evaluate_pipeline, + "evaluate_pipeline": evaluate_pipeline, "pipeline_space": pipeline_space, "root_directory": "test_yaml", "max_evaluations_total": 20, @@ -181,7 +181,7 @@ def are_functions_equivalent( ( "run_args_optional_loading_format.yaml", { - "run_pipeline": evaluate_pipeline, + "evaluate_pipeline": evaluate_pipeline, "pipeline_space": pipeline_space, "root_directory": "test_yaml", "max_evaluations_total": 20,