diff --git a/lib/catalog/README.md b/lib/catalog/README.md index 780c3171334..840a4a3d32f 100644 --- a/lib/catalog/README.md +++ b/lib/catalog/README.md @@ -45,17 +45,6 @@ Notice that the last part of the URL is the chart's slug, its identifier, in thi df = charts.get_data('life-expectancy') ``` -To see what charts are available, you can list them all. - -```python ->>> slugs = charts.list_charts() ->>> slugs[:5] -['above-ground-biomass-in-forest-per-hectare', - 'above-or-below-extreme-poverty-line-world-bank', - 'abs-change-energy-consumption', - 'absolute-change-co2', - 'absolute-gains-in-mean-female-height'] -``` ### Data science API diff --git a/lib/catalog/owid/catalog/charts.py b/lib/catalog/owid/catalog/charts.py index d6265d9c1ca..c3f8e07e096 100644 --- a/lib/catalog/owid/catalog/charts.py +++ b/lib/catalog/owid/catalog/charts.py @@ -6,7 +6,7 @@ # from dataclasses import dataclass -from typing import List, Optional +from typing import Optional import pandas as pd @@ -15,7 +15,6 @@ LicenseError, # noqa _fetch_bundle, _GrapherBundle, - _list_charts, ) @@ -53,14 +52,6 @@ def __eq__(self, value: object) -> bool: return isinstance(value, Chart) and value.slug == self.slug -def list_charts() -> List[str]: - """ - List all available charts published on Our World in Data, representing each via - a short slug that you can use with `get_data()`. - """ - return sorted(_list_charts()) - - def get_data(slug_or_url: str) -> pd.DataFrame: """ Fetch the data for a chart by its slug or by the URL of the chart. diff --git a/lib/catalog/owid/catalog/internal.py b/lib/catalog/owid/catalog/internal.py index 244999904f2..432e73395df 100644 --- a/lib/catalog/owid/catalog/internal.py +++ b/lib/catalog/owid/catalog/internal.py @@ -6,7 +6,6 @@ import datetime as dt import json -import re from dataclasses import dataclass from typing import Dict, List, Literal @@ -162,10 +161,3 @@ def _fetch_bundle(slug: str) -> _GrapherBundle: if d.metadata.get("origins"): origins.append(d.metadata.pop("origins")) return _GrapherBundle(config, dimensions, origins) - - -def _list_charts() -> List[str]: - content = requests.get("https://ourworldindata.org/charts").content.decode("utf-8") - links = re.findall('"(/grapher/[^"]+)"', content) - slugs = [link.strip('"').split("/")[-1] for link in links] - return sorted(set(slugs)) diff --git a/lib/catalog/tests/test_charts.py b/lib/catalog/tests/test_charts.py index e0a61392308..f0bfb9fba34 100644 --- a/lib/catalog/tests/test_charts.py +++ b/lib/catalog/tests/test_charts.py @@ -37,15 +37,6 @@ def test_fetch_non_redistributable_chart(): chart.get_data() -def test_list_charts(): - slugs = charts.list_charts() - assert len(slugs) > 0 - assert "life-expectancy" in slugs - - # all unique - assert len(slugs) == len(set(slugs)) - - def test_fetch_missing_chart(): with pytest.raises(charts.ChartNotFoundError): charts.Chart("this-chart-does-not-exist").bundle