Skip to content

Commit

Permalink
merge master + fix loading neps-searchers from yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
danrgll committed Jun 13, 2024
1 parent 54b2e63 commit 50d343e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 18 deletions.
18 changes: 5 additions & 13 deletions neps/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
from typing import Callable, Iterable, Literal

import ConfigSpace as CS
from neps.utils.run_args_from_yaml import check_essential_arguments, get_run_args_from_yaml,\
from neps.utils.run_args_from_yaml import check_essential_arguments, \
get_run_args_from_yaml, \
check_double_reference

from neps.utils.common import instance_from_map
Expand All @@ -25,17 +26,7 @@
from neps.status.status import post_run_csv
from neps.utils.common import get_searcher_data, get_value
from neps.utils.data_loading import _get_loss

VALID_SEARCHER = [
"default",
"bayesian_optimization",
"random_search",
"hyperband",
"priorband",
"mobster",
"asha",
"regularized_evolution",
]
from neps.optimizers.info import SearcherConfigs


def _post_evaluation_hook_function(
Expand Down Expand Up @@ -418,7 +409,8 @@ def _run_args(
message = f"The pipeline_space has invalid type: {type(pipeline_space)}"
raise TypeError(message) from e

if isinstance(searcher, (str, Path)) and searcher not in VALID_SEARCHER:
if isinstance(searcher, (str, Path)) and searcher not in \
SearcherConfigs.get_searchers() and searcher is not "default":
# The users has their own custom searcher.
logging.info("Preparing to run user created searcher")

Expand Down
2 changes: 1 addition & 1 deletion neps/search_spaces/yaml_search_space_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging
import re

logger = logging.getLogger(__name__)
logger = logging.getLogger("neps")


def convert_scientific_notation(value: str | int | float, show_usage_flag=False) \
Expand Down
2 changes: 1 addition & 1 deletion neps/utils/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def get_searcher_data(
data = yaml.safe_load(file)

file_name = user_yaml_path.stem
searcher = data.get("name", file_name)
searcher = data.pop("name", file_name)

else:
# TODO(eddiebergman): This is a bad idea as it relies on folder structure to be
Expand Down
5 changes: 2 additions & 3 deletions neps/utils/run_args_from_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,8 @@ def get_run_args_from_yaml(path: str) -> dict:
check_run_args(settings)

logger.debug(
f"'run_args' are extracted and type-tested from the referenced YAML file. "
f"These arguments will now be overwritten: {settings}."
)
f"The 'run_args' arguments: {settings} are now extracted and type-tested from "
f"referenced YAML.")

return settings

Expand Down

0 comments on commit 50d343e

Please sign in to comment.