Skip to content

Better error message for non-existing dataset #1111

@joaquinvanschoren

Description

@joaquinvanschoren

Description

When you call datasets.get_dataset(did) with an invalid ID, you get a rather obscure FileNotFound Error, even though the server returns an 'Unknown dataset' error.

Steps/Code to Reproduce

Expected Results

A 'Dataset does not exist' exception

Actual Results

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/openml/datasets/functions.py in _get_dataset_description(did_cache_dir, dataset_id)
    948     try:
--> 949         with io.open(description_file, encoding="utf8") as fh:
    950             dataset_xml = fh.read()

FileNotFoundError: [Errno 2] No such file or directory: '/root/.cache/openml/org/openml/www/datasets/987987987/description.xml'

During handling of the above exception, another exception occurred:

OpenMLServerException                     Traceback (most recent call last)
7 frames
/usr/local/lib/python3.7/dist-packages/openml/_api_calls.py in __check_response(response, url, file_elements)
    282 def __check_response(response, url, file_elements):
    283     if response.status_code != 200:
--> 284         raise __parse_server_exception(response, url, file_elements=file_elements)
    285     elif (
    286         "Content-Encoding" not in response.headers or response.headers["Content-Encoding"] != "gzip"

OpenMLServerException: https://www.openml.org/api/v1/xml/data/987987987 returned code 111: Unknown dataset - None

Versions

Linux-5.4.104+-x86_64-with-Ubuntu-18.04-bionic
Python 3.7.11 (default, Jul 3 2021, 18:01:19)
[GCC 7.5.0]
NumPy 1.19.5
SciPy 1.4.1
Scikit-Learn 0.22.2.post1
OpenML 0.12.2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions