Skip to content

Commit 40642c2

Browse files
Update ai-model/train.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 4386cb9 commit 40642c2

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

ai-model/train.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,15 @@
1919

2020
def load_config(config_path: str = "config/training_config.yaml") -> dict:
2121
"""Load training configuration."""
22-
with open(config_path, "r") as f:
23-
return yaml.safe_load(f)
22+
try:
23+
with open(config_path, "r") as f:
24+
return yaml.safe_load(f)
25+
except OSError as e:
26+
# Handle file-related errors (missing file, permission issues, etc.)
27+
raise RuntimeError(f"Failed to read configuration file '{config_path}': {e}") from e
28+
except yaml.YAMLError as e:
29+
# Handle malformed or invalid YAML content
30+
raise RuntimeError(f"Failed to parse YAML configuration from '{config_path}': {e}") from e
2431

2532

2633
def setup_model_and_tokenizer(config: dict):

0 commit comments

Comments
 (0)