Skip to content

Better error message for non-existing dataset #1111

Closed

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

Activity

  1. added this to the 0.13.1 milestone on Nov 29, 2022
  2. modified the milestones: 0.13.1, 0.14.0 on Jun 12, 2023
  3. modified the milestones: 0.14.0, 0.16.0 on Oct 14, 2024
  4. eddiebergman commented on Oct 14, 2024

    @eddiebergman
    Contributor

    I looked into this and as seen in the error above, the return code is 111 which stands for "Revalidation failed", this seems a bit odd and strikes me as something that should be a 404. I assume this is a server side issue for which I can't do much about.

    In them meantime, I can implement a hack that looks for error code 111 and "Unknown dataset - None" and convert it to something more appropriate.

  5. eddiebergman commented on Oct 14, 2024

    @eddiebergman
    Contributor

    Turns out this return code is not actually a HTTP error code and a custom set of codes as found here: https://github.com/openml/OpenML/blob/9a652179fc95392559222bb99769e82bdf8e91b8/openml_OS/views/pages/api_new/v1/xml/pre.php#L13-L17

  6. PGijsbers commented on Oct 14, 2024

    @PGijsbers
    Collaborator

    Yes, that's correct. The error code itself isn't so much the problem it's just that getting a whole stacktrace for something that we reasonably can expect a user to do (even if on accident) is not great. We just want a clean error that says "This dataset does not exist (anymore)." or something similar, I think.

  7. eddiebergman commented on Oct 14, 2024

    @eddiebergman
    Contributor

    Closed with #1356

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions