Skip to content

Listing functions when not enough results are available #580

@janvanrijn

Description

@janvanrijn

It occured to me that the listing function goes bananas when there are less results available that we wanted to obtain.

I extended the unit test of test_utils.py:

class OpenMLTaskTest(TestBase):

    def mocked_perform_api_call(call):
        # TODO: JvR: Why is this not a staticmethod?
        url = openml.config.server + '/' + call
        return openml._api_calls._read_url(url)

    @mock.patch('openml._api_calls._perform_api_call', side_effect=mocked_perform_api_call)
    def test_list_all_few_results_available(self, _perform_api_call):
        # we want to make sure that the number of api calls is only 1.
        # Although we have multiple versions of the iris dataset, there is only
        # one with this name/version combination

        datasets = openml.datasets.list_datasets(size=1000,
                                                 data_name='iris',
                                                 data_version=1)
        self.assertEqual(len(datasets), 1)
        self.assertEqual(_perform_api_call.call_count, 1)

It actually makes more calls. I will push a fix

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions