
    QЦi                         S r SSKJr  SSKJrJr  \ " S S5      5       rS\\   S\\\	\4      4S jr
S	\\\	\4      S\\   4S
 jrg)zEvaluation results utilities for the `.eval_results/*.yaml` format.

See https://huggingface.co/docs/hub/eval-results for more details.
Specifications are available at https://github.com/huggingface/hub-docs/blob/main/eval_results.yaml.
    )	dataclass)AnyOptionalc                       \ rS rSr% Sr\\S'   \\S'   \\S'   Sr\	\   \S'   Sr
\	\   \S'   Sr\	\   \S	'   Sr\	\   \S
'   Sr\	\   \S'   Sr\	\   \S'   Sr\	\   \S'   Sr\	\   \S'   SS jrSrg)EvalResultEntry   aL	  
Evaluation result entry for the `.eval_results/*.yaml` format.

Represents evaluation scores stored in model repos that automatically appear on
the model page and the benchmark dataset's leaderboard.

For the legacy `model-index` format in `README.md`, use [`EvalResult`] instead.

See https://huggingface.co/docs/hub/eval-results for more details.

Args:
    dataset_id (`str`):
        Benchmark dataset ID from the Hub. Example: "cais/hle", "Idavidrein/gpqa".
    task_id (`str`):
        Task identifier within the benchmark. Example: "gpqa_diamond".
    value (`Any`):
        The metric value. Example: 20.90.
    dataset_revision (`str`, *optional*):
        Git SHA of the benchmark dataset.
    verify_token (`str`, *optional*):
        A signature that can be used to prove that evaluation is provably auditable and reproducible.
    date (`str`, *optional*):
        When the evaluation was run (ISO-8601 datetime). Defaults to git commit time.
    source_url (`str`, *optional*):
        Link to the evaluation source (e.g., https://huggingface.co/spaces/SaylorTwift/smollm3-mmlu-pro). Required if `source_name`, `source_user`, or `source_org` is provided.
    source_name (`str`, *optional*):
        Display name for the source. Example: "Eval Logs".
    source_user (`str`, *optional*):
        HF user name for attribution. Example: "celinah".
    source_org (`str`, *optional*):
        HF org name for attribution. Example: "cais".
    notes (`str`, *optional*):
        Details about the evaluation setup. Example: "tools", "no-tools", "chain-of-thought".

Example:
    ```python
    >>> from huggingface_hub import EvalResultEntry
    >>> # Minimal example with required fields only
    >>> result = EvalResultEntry(
    ...     dataset_id="Idavidrein/gpqa",
    ...     task_id="gpqa_diamond",
    ...     value=0.412,
    ... )
    >>> # Full example with all fields
    >>> result = EvalResultEntry(
    ...     dataset_id="cais/hle",
    ...     task_id="default",
    ...     value=20.90,
    ...     dataset_revision="5503434ddd753f426f4b38109466949a1217c2bb",
    ...     verify_token="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    ...     date="2025-01-15T10:30:00Z",
    ...     source_url="https://huggingface.co/datasets/cais/hle",
    ...     source_name="CAIS HLE",
    ...     source_org="cais",
    ...     notes="no-tools",
    ... )

    ```

dataset_idtask_idvalueNdataset_revisionverify_tokendate
source_urlsource_namesource_user
source_orgnotesc                     U R                   c  U R                  c  U R                  b  U R                  c  [	        S5      eg g )NzaIf `source_name`, `source_user`, or `source_org` is provided, `source_url` must also be provided.)r   r   r   r   
ValueError)selfs    \/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/huggingface_hub/_eval_results.py__post_init__EvalResultEntry.__post_init__U   sH    (D,<,<,HDOOLgoo%s  & Mh     )returnN)__name__
__module____qualname____firstlineno____doc__str__annotations__r   r   r   r   r   r   r   r   r   r   r   __static_attributes__r   r   r   r   r      s    :x OLJ&*hsm*"&L(3-&D(3- $J$!%K#%!%K#% $J$E8C=r   r   entriesr   c                 V   / nU  GH  nUR                   UR                  S.nUR                  b  UR                  US'   X2R                  S.nUR                  b  UR                  US'   UR
                  b  UR
                  US'   UR                  bf  SUR                  0nUR                  b  UR                  US'   UR                  b  UR                  US'   UR                  b  UR                  US	'   XTS
'   UR                  b  UR                  US'   UR                  U5        GM"     U$ )aQ  Convert a list of [`EvalResultEntry`] objects to a YAML-serializable list of dicts.

This produces the format expected in `.eval_results/*.yaml` files.

Args:
    entries (`list[EvalResultEntry]`):
        List of evaluation result entries to serialize.

Returns:
    `list[dict[str, Any]]`: A list of dictionaries ready to be dumped to YAML.

Example:
    ```python
    >>> from huggingface_hub import EvalResultEntry, eval_result_entries_to_yaml
    >>> entries = [
    ...     EvalResultEntry(dataset_id="cais/hle", task_id="default", value=20.90),
    ...     EvalResultEntry(dataset_id="Idavidrein/gpqa", task_id="gpqa_diamond", value=0.412),
    ... ]
    >>> yaml_data = eval_result_entries_to_yaml(entries)
    >>> yaml_data[0]
    {'dataset': {'id': 'cais/hle', 'task_id': 'default'}, 'value': 20.9}

    ```

    To upload eval results to the Hub:
    ```python
    >>> import yaml
    >>> from huggingface_hub import upload_file, EvalResultEntry, eval_result_entries_to_yaml
    >>> entries = [
    ...     EvalResultEntry(dataset_id="cais/hle", task_id="default", value=20.90),
    ... ]
    >>> yaml_content = yaml.dump(eval_result_entries_to_yaml(entries))
    >>> upload_file(
    ...     path_or_fileobj=yaml_content.encode(),
    ...     path_in_repo=".eval_results/hle.yaml",
    ...     repo_id="your-username/your-model",
    ... )

    ```
)idr
   revision)datasetr   verifyTokenr   urlnameuserorgsourcer   )r	   r
   r   r   r   r   r   r   r   r   r   append)r%   resultentryr)   datar/   s         r   eval_result_entries_to_yamlr4   ^   s!   R F).)9)9emm"T!!-"'"8"8GJ+2[[I)"'"4"4D::! ::DL'&+U-=-=%>F  ,!&!2!2v  ,!&!2!2v+ % 0 0u#N;;"!KKDMd1 2 Mr   r3   c                    / nU  GH  nUR                  SU5      nUR                  S0 5      nUR                  S0 5      n[        US   US   US   UR                  S5      UR                  S5      UR                  S	5      U(       a  UR                  S
5      OSU(       a  UR                  S5      OSU(       a  UR                  S5      OSU(       a  UR                  S5      OSUR                  S5      S9nUR                  U5        GM     U$ )a,  Parse a list of dicts into [`EvalResultEntry`] objects.

This parses the `.eval_results/*.yaml` format. For the legacy `model-index` format,
use [`model_index_to_eval_results`] instead.

Args:
    data (`list[dict[str, Any]]`):
        A list of dictionaries (e.g., parsed from YAML or API response).

Returns:
    `list[EvalResultEntry]`: A list of evaluation result entry objects.

Example:
    ```python
    >>> from huggingface_hub import parse_eval_result_entries
    >>> data = [
    ...     {"dataset": {"id": "cais/hle", "task_id": "default"}, "value": 20.90},
    ...     {"dataset": {"id": "Idavidrein/gpqa", "task_id": "gpqa_diamond"}, "value": 0.412},
    ... ]
    >>> entries = parse_eval_result_entries(data)
    >>> entries[0].dataset_id
    'cais/hle'
    >>> entries[0].value
    20.9

    ```
r3   r)   r/   r'   r   r
   r(   r*   r   r+   Nr,   r-   r.   r   )r	   r   r
   r   r   r   r   r   r   r   r   )getr   r0   )r3   r%   item
entry_datar)   r/   r2   s          r   parse_eval_result_entriesr9      s    8 GXXfd+
..B/"-t}W%I&$[[4#6',2vzz%(.4

6*$.4

6*$,2vzz%(..)
 	u# $ Nr   N)r!   dataclassesr   typingr   r   r   listdictr"   r4   r9   r   r   r   <module>r>      s~    "   O O OdCo)> C4SRUXCW CL/Dc3h$8 /T/=R /r   