Skip to content

Commit

Permalink
rm list_metrics (#2702)
Browse files Browse the repository at this point in the history
* rm list_metrics

* tweak readme
  • Loading branch information
julien-c authored Dec 9, 2024
1 parent 6925b1c commit 92463fb
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 54 deletions.
2 changes: 1 addition & 1 deletion src/huggingface_hub/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()`
Expand Down
2 changes: 0 additions & 2 deletions src/huggingface_hub/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@
"list_datasets",
"list_inference_endpoints",
"list_liked_repos",
"list_metrics",
"list_models",
"list_organization_members",
"list_papers",
Expand Down Expand Up @@ -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
Expand Down
41 changes: 0 additions & 41 deletions src/huggingface_hub/hf_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
10 changes: 0 additions & 10 deletions tests/test_hf_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
ExpandDatasetProperty_T,
ExpandModelProperty_T,
ExpandSpaceProperty_T,
MetricInfo,
ModelInfo,
RepoSibling,
RepoUrl,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 92463fb

Please sign in to comment.