Skip to content

Commit

Permalink
MNT use api.openml.org URLs for fetch_openml (scikit-learn#26171)
Browse files Browse the repository at this point in the history
  • Loading branch information
lesteve committed Apr 14, 2023
1 parent fb02c17 commit d8b05e0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion sklearn/datasets/_openml.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

__all__ = ["fetch_openml"]

_OPENML_PREFIX = "https://openml.org/"
_OPENML_PREFIX = "https://api.openml.org/"
_SEARCH_NAME = "api/v1/json/data/list/data_name/{}/limit/2"
_DATA_INFO = "api/v1/json/data/{}"
_DATA_FEATURES = "api/v1/json/data/features/{}"
Expand Down
12 changes: 7 additions & 5 deletions sklearn/datasets/tests/test_openml.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ def _monkey_patch_webbased_functions(context, data_id, gzip_response):
# monkey patches the urlopen function. Important note: Do NOT use this
# in combination with a regular cache directory, as the files that are
# stored as cache should not be mixed up with real openml datasets
url_prefix_data_description = "https://openml.org/api/v1/json/data/"
url_prefix_data_features = "https://openml.org/api/v1/json/data/features/"
url_prefix_download_data = "https://openml.org/data/v1/"
url_prefix_data_list = "https://openml.org/api/v1/json/data/list/"
url_prefix_data_description = "https://api.openml.org/api/v1/json/data/"
url_prefix_data_features = "https://api.openml.org/api/v1/json/data/features/"
url_prefix_download_data = "https://api.openml.org/data/v1/"
url_prefix_data_list = "https://api.openml.org/api/v1/json/data/list/"

path_suffix = ".gz"
read_fn = gzip.open
Expand All @@ -85,7 +85,9 @@ def _monkey_patch_webbased_functions(context, data_id, gzip_response):

def _file_name(url, suffix):
output = (
re.sub(r"\W", "-", url[len("https://openml.org/") :]) + suffix + path_suffix
re.sub(r"\W", "-", url[len("https://api.openml.org/") :])
+ suffix
+ path_suffix
)
# Shorten the filenames to have better compatibility with windows 10
# and filenames > 260 characters
Expand Down

0 comments on commit d8b05e0

Please sign in to comment.