-
-
Notifications
You must be signed in to change notification settings - Fork 206
[ENH] Simplified Unified Get/List API #1552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| "run": runs.functions.list_runs, | ||
| } | ||
|
|
||
| try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should really stop abusing try/except for case distinctions.
This is not good style, since you cannot distinguish actual exceptions from the try-block with the intended exception.
Instead, use if/else with a precise condition. In this case, you can also:
- use
dict.get, and then check ifNonewas retrieved. - do an input check on
object_type
| return func(**kwargs) | ||
|
|
||
|
|
||
| def get(object_type_or_name: Any, identifier: Any | None = None, /, **kwargs: Any) -> Any: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the first arg can be two different things, I would avoid that - instead, I would do one of two things:
- use
*, the argument syntax - make the
identifierfirst, andobject_typesecond
| "run": runs.functions.get_run, | ||
| } | ||
|
|
||
| try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again a try/except that you should avoid.
| dataset_ids: list[int | str] | None = None, | ||
| flow_ids: list[int] | None = None, | ||
| run_ids: list[int] | None = None, | ||
| task_ids: builtins.list[int] | None = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are you changing this?
| GetDispatcher = Dict[str, Callable[..., Any]] | ||
|
|
||
|
|
||
| def list(object_type: str, /, **kwargs: Any) -> Any: # noqa: A001 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
list is not a good name, as it overloads python list - we should avoid that!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what other good names are there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe list_all
Redundant syntax for getters
In getters, syntax is repeated and redundant, mainly through
the submodule having to be imported or addressed.
API implementation
Implementation Details
Added
openml.list(object_type: str, **kwargs) -> Any, a dispatcher that forwards to:list_datasetslist_taskslist_flowslist_runsAdded
openml.get(object_type_or_name, identifier=None, **kwargs) -> Any, a unified getter with support for:Type-based lookup
Name-only shortcut for datasets
Exported both functions via
__all__and documented them with docstrings.Preserved full backward compatibility:
openml.datasets.get_dataset) remain unchanged.Added unit tests to validate dispatcher behavior without requiring network access.