Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix/geti integration #3543

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/otx/algo/modules/base_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def _dump_init_info(self) -> None:
with_file_handler = False
# dump the information to the logger file if there is a `FileHandler`
for handler in logger.handlers:
if isinstance(handler, FileHandler):
if isinstance(handler, FileHandler) and handler.stream is not None:
handler.stream.write("Name of parameter - Initialization information\n")
for name, param in self.named_parameters():
handler.stream.write(
Expand Down
2 changes: 1 addition & 1 deletion src/otx/engine/hpo/hpo_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def execute_hpo(
engine.model.patch_optimizer_and_scheduler_for_hpo()

hpo_workdir = Path(engine.work_dir) / "hpo"
hpo_workdir.mkdir(exist_ok=True)
hpo_workdir.mkdir(parents=True, exist_ok=True)
hpo_configurator = HPOConfigurator(
engine=engine,
max_epochs=max_epochs,
Expand Down
21 changes: 17 additions & 4 deletions src/otx/hpo/search_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@

logger = logging.getLogger()

AVAILABLE_SEARCH_SPACE_TYPE = ["uniform", "quniform", "loguniform", "qloguniform", "choice"]
AVAILABLE_SEARCH_SPACE_TYPE = [
"uniform",
"quniform",
"loguniform",
"qloguniform",
"choice",
]


class SingleSearchSpace:
Expand Down Expand Up @@ -58,7 +64,9 @@ def __init__(
self._check_all_value_is_right()

@property
def type(self) -> Literal["uniform", "loguniform", "quniform", "qloguniform", "choice"]: # noqa: A003
def type( # noqa: A003
self,
) -> Literal["uniform", "loguniform", "quniform", "qloguniform", "choice"]:
"""Type of hyper parameter in search space."""
return self._type

Expand Down Expand Up @@ -309,8 +317,13 @@ def __init__(
) -> None:
self.search_space: dict[str, SingleSearchSpace] = {}

for key, val in search_space.items(): # pylint: disable=too-many-nested-blocks
self.search_space[key] = SingleSearchSpace(**val)
try:
for key, val in search_space.items(): # pylint: disable=too-many-nested-blocks
self.search_space[key] = SingleSearchSpace(**val)
except Exception:
msg = f"Failed to create SingleSearchSpace. key={key}, val={val}"
logging.exception(msg)
raise

def __getitem__(self, key: str) -> SingleSearchSpace:
"""Get search space by key."""
Expand Down
Loading