Skip to content

Commit

Permalink
Mod: Update warning about duplicated metrics to display only once in …
Browse files Browse the repository at this point in the history
…evaluate func.
  • Loading branch information
Labbeti committed Feb 28, 2024
1 parent b632b85 commit 82df0e5
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/aac_metrics/functional/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@

import logging
import time

from functools import partial
from functools import cache, partial
from pathlib import Path
from typing import Any, Callable, Iterable, Optional, Union

import torch

from torch import Tensor

from aac_metrics.functional.bert_score_mrefs import bert_score_mrefs
Expand All @@ -28,7 +26,6 @@
from aac_metrics.utils.checks import check_metric_inputs
from aac_metrics.utils.tokenization import preprocess_mono_sents, preprocess_mult_sents


pylog = logging.getLogger(__name__)


Expand Down Expand Up @@ -155,8 +152,8 @@ def evaluate(
set(outs_sents_i.keys()).intersection(outs_sents.keys())
)
if len(corpus_overlap) > 0 or len(sents_overlap) > 0:
pylog.warning(
f"Found overlapping metric outputs names. (found {corpus_overlap=} and {sents_overlap=})"
warn_once(
f"Found overlapping metric outputs names. (found {corpus_overlap=} and {sents_overlap=} at least twice)"
)

outs_corpus |= outs_corpus_i
Expand Down Expand Up @@ -352,3 +349,8 @@ def _get_metric_factory_functions(
),
}
return factory


@cache
def warn_once(msg: str) -> None:
pylog.warning(msg)

0 comments on commit 82df0e5

Please sign in to comment.