Skip to content

Handling filters with None #371

@joaquinvanschoren

Description

@joaquinvanschoren

Passing a None object as a filter argument on listing calls seems to ignore the filter rather than returning no results.
E.g. list_evaluations(setup=setuplist) where setuplist happens to be None will happily download ALL OpenML evaluations (when placed in a paging loop).

Indeed, the code says:

def list_evaluations(function, offset=None, size=None, id=None, task=None,
                     setup=None, flow=None, uploader=None, tag=None):
    if setup is not None:
        api_call += "/setup/%s" % ','.join([str(int(i)) for i in setup])

It would be safer to actually check whether the argument was passed? This can be done with kwargs: https://stackoverflow.com/questions/14749328/python-how-to-check-whether-optional-function-parameter-is-set

What do you think? This actually happened to me by mistake (I assumed all studies have a list of setups - not) and I only noticed after downloading 1.3 million evaluations.
Normally you wouldn't worry too much about stupid user mistakes, but in this case it stresses the server. Maybe adding it just for the listing calls isn't the worst idea.

Metadata

Metadata

Assignees

Labels

Good First IssueIssues suitable for people new to contributing to openml-python!

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions