Skip to content

Commit

Permalink
Merge branch 'releases/2.2.0' into eugene/CVS-151847-add-missing-tile…
Browse files Browse the repository at this point in the history
…-recipes-2
  • Loading branch information
sovrasov authored Sep 9, 2024
2 parents 75cc598 + 1d319cd commit eee6c61
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/otx/engine/hpo/hpo_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from __future__ import annotations

import dataclasses
import json
import logging
import time
from functools import partial
Expand Down Expand Up @@ -128,6 +129,10 @@ def execute_hpo(
hpo_algo.print_result()
_remove_unused_model_weights(hpo_workdir, best_hpo_weight)

if best_config is not None:
with (hpo_workdir / "best_hp.json").open("w") as f:
json.dump(best_config, f)

return best_config, best_hpo_weight


Expand Down
2 changes: 2 additions & 0 deletions src/otx/tools/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ def convert(config_path: str, task: OTXTaskType | None = None) -> dict:
task_info["task"] = task
default_config = ConfigConverter._get_default_config(task_info)
ConfigConverter._update_params(default_config, param_dict)
if (hpo_time_ratio := template_config.get("hpo_parameters", {}).get("hpo_time_ratio")) is not None:
default_config["hpo_config.expected_time_ratio"] = hpo_time_ratio
ConfigConverter._remove_unused_key(default_config)
return default_config

Expand Down
1 change: 1 addition & 0 deletions tests/unit/engine/hpo/test_hpo_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ def test_execute_hpo(

# check hpo workdir exists
assert (engine_work_dir / "hpo").exists()
assert (engine_work_dir / "hpo" / "best_hp.json").exists()
# check a case where progress_update_callback exists
mock_thread.assert_called_once()
assert mock_thread.call_args.kwargs["target"] == _update_hpo_progress
Expand Down

0 comments on commit eee6c61

Please sign in to comment.