wL i> XdZddlZddlZddlmZddlmZerddlmZddd e d e d e fd Z y) zz Helpful utility functions and classes in relation to exploring API endpoints with the aim for a user-friendly interface. N) TYPE_CHECKING) ModelCardData) ModelInfo model_informinimum_thresholdmaximum_thresholdreturnc| | td|d}|tj}t|dd}|t |t t fsy|jdd}t |t r|d}|sytjdt|}|yt|jd }||cxkxr|kScS) aChecks if a model's emission is within a given threshold. Args: model_info (`ModelInfo`): A model info object containing the model's emission information. minimum_threshold (`float`): A minimum carbon threshold to filter by, such as 1. maximum_threshold (`float`): A maximum carbon threshold to filter by, such as 10. Returns: `bool`: Whether the model's emission is within the given threshold. NzFBoth `minimum_threshold` and `maximum_threshold` cannot both be `None` card_dataFco2_eq_emissions emissionsz \d+\.\d+|\d+r) ValueErrormathinfgetattr isinstancedictrgetresearchstrfloatgroup)rrr r emissionmatchedemission_values l/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/huggingface_hub/utils/endpoint_helpers.py_is_emission_within_thresholdr s %6%>abb   HH K6I 9t]6K L}}/6H(D!K( iiX7G7==+,N  C2C CC CC) __doc__rrtypingr repocard_datarhf_apirrboolr r!rr(sH  )"&Dk&De&Dhm&Drv&Dr!