Download code/labeling/src/config_utils.py from lsh9034/ci-net: direct link, hf CLI and curl.
- Browser
- Download file 1.39 kB
-
https://huggingface.co/lsh9034/ci-net/resolve/main/code/labeling/src/config_utils.py
- Command line
-
hf download hf://lsh9034/ci-net/code/labeling/src/config_utils.py
-
curl -L -o config_utils.py https://huggingface.co/lsh9034/ci-net/resolve/main/code/labeling/src/config_utils.py
1.39 kB
| """ | |
| file: config.py | |
| date: 2026/02/15 | |
| brief: JSON κΈ°λ° μ€μ νμΌ λ‘λ μ νΈλ¦¬ν° | |
| λ³Έ λͺ¨λμ νλ‘μ νΈ μ λ°μμ μ¬μ©λλ μ€μ (JSON) νμΌμ | |
| νμ΄μ¬ λμ λ리 ννλ‘ λ‘λνκΈ° μν κ³΅ν΅ μ νΈ ν¨μλ€μ μ 곡νλ€. | |
| νΉμ§: | |
| - UTF-8 μΈμ½λ©μ λͺ μμ μΌλ‘ μ¬μ© | |
| - μ€μ νμΌμ ꡬ쑰λ ν€μ λν κ²μ¦μ μννμ§ μμ | |
| - κ° step(step1/2/3) μ€ν¬λ¦½νΈμμ λμΌν λ°©μμΌλ‘ μ¬μ¬μ©λ¨ | |
| ---------------------------------------------------------------------- | |
| Version Date Comment | |
| --------- ---------- ---------------------------------------------- | |
| """ | |
| import json | |
| from typing import Any, Dict | |
| def load_config(path: str) -> Dict[str, Any]: | |
| """ | |
| JSON νμμ μ€μ νμΌμ λ‘λνμ¬ λμ λλ¦¬λ‘ λ°ννλ€. | |
| Parameters | |
| ---------- | |
| path : str | |
| λ‘λν μ€μ νμΌ(JSON)μ κ²½λ‘ | |
| Returns | |
| ------- | |
| dict[str, Any] | |
| JSON νμΌ λ΄μ©μ κ·Έλλ‘ λ΄μ μ€μ λμ λ리 | |
| Raises | |
| ------ | |
| FileNotFoundError | |
| μ§μ ν κ²½λ‘μ νμΌμ΄ μ‘΄μ¬νμ§ μλ κ²½μ° | |
| json.JSONDecodeError | |
| JSON νμμ΄ μ¬λ°λ₯΄μ§ μμ κ²½μ° | |
| UnicodeDecodeError | |
| νμΌ μΈμ½λ©μ΄ UTF-8μ΄ μλ κ²½μ° | |
| """ | |
| with open(path, "r", encoding="utf-8") as f: | |
| cfg = json.load(f) | |
| return cfg | |