Skip to content

Commit

Permalink
Reformatting optimizer_info yaml with fewer restrictions on Metahyper
Browse files Browse the repository at this point in the history
  • Loading branch information
TarekAbouChakra committed Oct 25, 2023
1 parent 61103db commit a0de4e8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
9 changes: 0 additions & 9 deletions src/metahyper/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,15 +367,6 @@ def run(
if not Path(sampler_info_file).exists():
# Write the sampler_info to a YAML file
serializer.dump(sampler_info, sampler_info_file, sort_keys=False)
else:
# Load the sampler_info from a YAML file
sampler_info_from_file = serializer.load(sampler_info_file)
# Check if the sampler_info is valid
if sampler_info != sampler_info_from_file:
raise ValueError(
f"The sampler_info in the file {sampler_info_file} is not valid. "
f"Expected: {sampler_info}, Found: {sampler_info_from_file}"
)

evaluations_in_this_run = 0
while True:
Expand Down
6 changes: 3 additions & 3 deletions src/neps/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def run(
"searcher_name": searcher,
"searcher_alg": searcher_alg,
"user_defined_searcher": user_defined_searcher,
"args_accepted_changes": None,
"searcher_args_user_modified": False,
}

# Updating searcher arguments from searcher_kwargs
Expand All @@ -281,7 +281,7 @@ def run(
f"The searcher argument '{key}' has the same"
f" value '{value}' as default."
)
searcher_info["args_accepted_changes"] = True
searcher_info["searcher_args_user_modified"] = True
else:
# No searcher argument updates when NePS decides the searcher.
logger.info(35 * "=" + "WARNING" + 35 * "=")
Expand All @@ -290,7 +290,7 @@ def run(
f"The searcher argument '{key}' will not change to '{value}'"
f" because NePS chose the searcher"
)
searcher_info["args_accepted_changes"] = False
searcher_info["searcher_args_user_modified"] = False

searcher_config.update(
{
Expand Down
10 changes: 5 additions & 5 deletions tests/test_neps_api/test_yaml_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,31 @@ def no_logs_gte_error(caplog):
"searcher_name": "priorband_bo",
"searcher_alg": "priorband",
"user_defined_searcher": True,
"args_accepted_changes": True,
"searcher_args_user_modified": True,
},
"priorband_neps_decided": {
"searcher_name": "priorband",
"searcher_alg": "priorband",
"user_defined_searcher": False,
"args_accepted_changes": False,
"searcher_args_user_modified": False,
},
"bo_neps_decided": {
"searcher_name": "bayesian_optimization",
"searcher_alg": "bayesian_optimization",
"user_defined_searcher": False,
"args_accepted_changes": None,
"searcher_args_user_modified": False,
},
"pibo_neps_decided": {
"searcher_name": "pibo",
"searcher_alg": "bayesian_optimization",
"user_defined_searcher": False,
"args_accepted_changes": False,
"searcher_args_user_modified": False,
},
"hyperband_neps_decided": {
"searcher_name": "hyperband",
"searcher_alg": "hyperband",
"user_defined_searcher": False,
"args_accepted_changes": False,
"searcher_args_user_modified": False,
},
}

Expand Down

0 comments on commit a0de4e8

Please sign in to comment.