From 92463fb559deb32926a216be9f62dd0a55862306 Mon Sep 17 00:00:00 2001 From: Julien Chaumond Date: Mon, 9 Dec 2024 15:58:31 +0100 Subject: [PATCH] rm list_metrics (#2702) * rm list_metrics * tweak readme --- src/huggingface_hub/README.md | 2 +- src/huggingface_hub/__init__.py | 2 -- src/huggingface_hub/hf_api.py | 41 --------------------------------- tests/test_hf_api.py | 10 -------- 4 files changed, 1 insertion(+), 54 deletions(-) diff --git a/src/huggingface_hub/README.md b/src/huggingface_hub/README.md index 2349c4444e..a6cac7cb2a 100644 --- a/src/huggingface_hub/README.md +++ b/src/huggingface_hub/README.md @@ -98,7 +98,7 @@ huggingface-cli whoami huggingface-cli repo create ``` -With the `HfApi` class there are methods to query models, datasets, and metrics by specific tags (e.g. if you want to list models compatible with your library): +With the `HfApi` class there are methods to query models, datasets, and Spaces by specific tags (e.g. if you want to list models compatible with your library): - **Models**: - `list_models()` - `model_info()` diff --git a/src/huggingface_hub/__init__.py b/src/huggingface_hub/__init__.py index 3b013cd02d..4bc6c38e29 100644 --- a/src/huggingface_hub/__init__.py +++ b/src/huggingface_hub/__init__.py @@ -208,7 +208,6 @@ "list_datasets", "list_inference_endpoints", "list_liked_repos", - "list_metrics", "list_models", "list_organization_members", "list_papers", @@ -741,7 +740,6 @@ def __dir__(): list_datasets, # noqa: F401 list_inference_endpoints, # noqa: F401 list_liked_repos, # noqa: F401 - list_metrics, # noqa: F401 list_models, # noqa: F401 list_organization_members, # noqa: F401 list_papers, # noqa: F401 diff --git a/src/huggingface_hub/hf_api.py b/src/huggingface_hub/hf_api.py index 3c1bd6a5d5..cf0256655c 100644 --- a/src/huggingface_hub/hf_api.py +++ b/src/huggingface_hub/hf_api.py @@ -1112,33 +1112,6 @@ def __init__(self, **kwargs): self.__dict__.update(**kwargs) -@dataclass -class MetricInfo: - """ - Contains information about a metric on the Hub. - - Attributes: - id (`str`): - ID of the metric. E.g. `"accuracy"`. - space_id (`str`): - ID of the space associated with the metric. E.g. `"Accuracy"`. - description (`str`): - Description of the metric. - """ - - id: str - space_id: str - description: Optional[str] - - def __init__(self, **kwargs): - self.id = kwargs.pop("id") - self.space_id = kwargs.pop("spaceId") - self.description = kwargs.pop("description", None) - # backwards compatibility - self.spaceId = self.space_id - self.__dict__.update(**kwargs) - - @dataclass class CollectionItem: """ @@ -2157,19 +2130,6 @@ def list_datasets( item["siblings"] = None yield DatasetInfo(**item) - def list_metrics(self) -> List[MetricInfo]: - """ - Get the public list of all the metrics on huggingface.co - - Returns: - `List[MetricInfo]`: a list of [`MetricInfo`] objects which. - """ - path = f"{self.endpoint}/api/metrics" - r = get_session().get(path) - hf_raise_for_status(r) - d = r.json() - return [MetricInfo(**x) for x in d] - @validate_hf_hub_args def list_spaces( self, @@ -9564,7 +9524,6 @@ def _parse_revision_from_pr_url(pr_url: str) -> str: list_repo_commits = api.list_repo_commits list_repo_tree = api.list_repo_tree get_paths_info = api.get_paths_info -list_metrics = api.list_metrics get_model_tags = api.get_model_tags get_dataset_tags = api.get_dataset_tags diff --git a/tests/test_hf_api.py b/tests/test_hf_api.py index f3f299655f..d7a583437b 100644 --- a/tests/test_hf_api.py +++ b/tests/test_hf_api.py @@ -59,7 +59,6 @@ ExpandDatasetProperty_T, ExpandModelProperty_T, ExpandSpaceProperty_T, - MetricInfo, ModelInfo, RepoSibling, RepoUrl, @@ -1739,9 +1738,6 @@ def test_staging_list_datasets(self): def test_staging_list_models(self): self._api.list_models() - def test_staging_list_metrics(self): - self._api.list_metrics() - class HfApiPublicProductionTest(unittest.TestCase): @with_production_testing @@ -2192,12 +2188,6 @@ def test_space_info_expand_cannot_be_used_with_files_metadata(self): with self.assertRaises(ValueError): self._api.space_info("HuggingFaceH4/zephyr-chat", expand=["author"], files_metadata=True) - def test_list_metrics(self): - metrics = self._api.list_metrics() - self.assertGreater(len(metrics), 10) - self.assertIsInstance(metrics[0], MetricInfo) - assert any(metric.description for metric in metrics) - def test_filter_models_by_author(self): models = list(self._api.list_models(author="muellerzr")) assert len(models) > 0