Skip to content

Commit 3a9576b

Browse files
committed
replace warnings.warn by logger.warn in repocard.py
1 parent 14f3190 commit 3a9576b

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/huggingface_hub/repocard.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import os
22
import re
3-
import warnings
43
from pathlib import Path
54
from typing import Any, Dict, Literal, Optional, Type, Union
65

@@ -21,7 +20,10 @@
2120
from huggingface_hub.utils import get_session, is_jinja_available, yaml_dump
2221

2322
from .constants import REPOCARD_NAME
24-
from .utils import EntryNotFoundError, SoftTemporaryDirectory, validate_hf_hub_args
23+
from .utils import EntryNotFoundError, SoftTemporaryDirectory, logging, validate_hf_hub_args
24+
25+
26+
logger = logging.get_logger(__name__)
2527

2628

2729
TEMPLATE_MODELCARD_PATH = Path(__file__).parent / "templates" / "modelcard_template.md"
@@ -102,7 +104,7 @@ def content(self, content: str):
102104
raise ValueError("repo card metadata block should be a dict")
103105
else:
104106
# Model card without metadata... create empty metadata
105-
warnings.warn("Repo card metadata block was not found. Setting CardData to empty.")
107+
logger.warning("Repo card metadata block was not found. Setting CardData to empty.")
106108
data_dict = {}
107109
self.text = content
108110

src/huggingface_hub/repocard_data.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import copy
2-
import warnings
32
from collections import defaultdict
43
from dataclasses import dataclass
54
from typing import Any, Dict, List, Optional, Tuple, Union
65

7-
from huggingface_hub.utils import yaml_dump
6+
from huggingface_hub.utils import logging, yaml_dump
7+
8+
9+
logger = logging.get_logger(__name__)
810

911

1012
@dataclass
@@ -325,7 +327,7 @@ def __init__(
325327
self.eval_results = eval_results
326328
except (KeyError, TypeError) as error:
327329
if ignore_metadata_errors:
328-
warnings.warn("Invalid model-index. Not loading eval results into CardData.")
330+
logger.warning("Invalid model-index. Not loading eval results into CardData.")
329331
else:
330332
raise ValueError(
331333
f"Invalid `model_index` in metadata cannot be parsed: {error.__class__} {error}. Pass"

0 commit comments

Comments
 (0)