Skip to content

Commit

Permalink
refactor: Utilization idle checker calculates resource name to avoid …
Browse files Browse the repository at this point in the history
…hard code (#2702) (#2929)

Co-authored-by: Sanghun Lee <sanghun@lablup.com>
  • Loading branch information
lablup-octodog and fregataa authored Oct 21, 2024
1 parent ffa6393 commit 9f599cd
Show file tree
Hide file tree
Showing 2 changed files with 189 additions and 80 deletions.
11 changes: 11 additions & 0 deletions src/ai/backend/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from pathlib import Path
from typing import Any, Dict, Mapping, MutableMapping, Optional, Tuple, Union, cast

import humps
import tomli
import trafaret as t
from pydantic import (
Expand Down Expand Up @@ -254,3 +255,13 @@ def set_if_not_set(table: MutableMapping[str, Any], key_path: Tuple[str, ...], v
table = table[k]
if table.get(key_path[-1]) is None:
table[key_path[-1]] = value


def config_key_to_snake_case(o: Any) -> Any:
match o:
case dict():
return {humps.dekebabize(k): config_key_to_snake_case(v) for k, v in o.items()}
case list() | tuple() | set():
return [config_key_to_snake_case(i) for i in o]
case _:
return o
Loading

0 comments on commit 9f599cd

Please sign in to comment.