File size: 2,009 Bytes
			
			| 9d5b4c0 fe70438 9d5b4c0 88c61d3 fe70438 d346c89 9d5b4c0 24df49f 9d5b4c0 24df49f 9d5b4c0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | from typing import Optional
from .logging_utils import get_logger
logger = get_logger()
class Documentation:
    URL = "https://www.unitxt.ai/en/latest/"
    HUGGINGFACE_METRICS = "docs/adding_metric.html#adding-a-hugginface-metric"
    ADDING_TASK = "docs/adding_task.html"
    ADDING_TEMPLATE = "docs/adding_template.html"
    POST_PROCESSORS = "docs/adding_template.html#post-processors"
    MULTIPLE_METRICS_OUTPUTS = (
        "docs/adding_metric.html#metric-outputs-with-multiple-metrics"
    )
    EVALUATION = "docs/evaluating_datasets.html"
    BENCHMARKS = "docs/benchmark.html"
    DATA_CLASSIFICATION_POLICY = "docs/data_classification_policy.html"
    CATALOG = "docs/saving_and_loading_from_catalog.html"
    SETTINGS = "docs/settings.html"
def additional_info(path: str) -> str:
    return f"\nFor more information: see {Documentation.URL}/{path} \n"
class UnitxtError(Exception):
    """Exception raised for Unitxt errors.
    Args:
        message (str):
            explanation of the error
        additional_info_id (Optional[str]):
            relative path to additional documentation on web
            If set, should be one of the DOCUMENATION_* constants in the error_utils.py file.
    """
    def __init__(self, message: str, additional_info_id: Optional[str] = None):
        if additional_info_id is not None:
            message += additional_info(additional_info_id)
        super().__init__(message)
class UnitxtWarning:
    """Object to format warning message to log.
    Args:
        message (str):
            explanation of the warning
        additional_info_id (Optional[str]):
            relative path to additional documentation on web
            If set, should be one of the DOCUMENATION_* constants in the error_utils.py file.
    """
    def __init__(self, message: str, additional_info_id: Optional[str] = None):
        if additional_info_id is not None:
            message += additional_info(additional_info_id)
        logger.warning(message)
 | 
