-
-
Notifications
You must be signed in to change notification settings - Fork 208
Open
Description
Just a minor thing: Errors for authentication and authorization is currently both handled by OpenMLNotAuthorizedError. Here is the difference:
| Concept | Question | Example |
|---|---|---|
| Authentication | "Who are you?" | No API key, invalid key, expired key |
| Authorization | "Are you allowed?" | Valid key, but you didn't upload this resource |
So we could handle this case with a new error-class: https://github.com/openml/openml-python/blob/main/openml/_api_calls.py#L520
I would suggest a new class called OpenMLAuthenticationError that gives the user more information when the API key is invalid. It could look somewhat like this:
class OpenMLAuthenticationError(...):
"""Exception raised when API authentication fails.
This typically occurs when:
- No API key is configured
- The API key is invalid or expired
- The API key lacks permissions for the requested operation
- ...
"""
def __init__(self, message: str):
help_text = (
"\n\nTo fix this:\n"
"Get your API key at ...\n"
"Run ... to configure apikey\n"
)
super().__init__(message + help_text)Metadata
Metadata
Assignees
Labels
No labels