Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions openml/_api/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from openml._api.runtime.core import APIContext


def set_api_version(version: str, *, strict: bool = False) -> None:
api_context.set_version(version=version, strict=strict)


api_context = APIContext()
Comment on lines +1 to +8
Copy link
Collaborator

@PGijsbers PGijsbers Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not clear what the function of the APIContext is here. Why do we need it and cannot just use backend directly? E.g.:

Suggested change
from openml._api.runtime.core import APIContext
def set_api_version(version: str, *, strict: bool = False) -> None:
api_context.set_version(version=version, strict=strict)
api_context = APIContext()
from openml._api.runtime.core import build_backend
_backend = build_backend("v1", strict=False)
def set_api_version(version: str, *, strict: bool = False) -> None:
global _backend
_backend = build_backend(version=version, strict=strict)
def backend() -> APIBackend:
return _backend

If it is just to avoid the pitfall where users assign the returned value to a local variable with a scope that is too long lived, then the same would apply if users would assign api_context.backend to a variable. We could instead extend the APIBackend class to allow updates to its attributes?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you, it's not really useful, I am going to iterate over the design and will keep this in mind

6 changes: 6 additions & 0 deletions openml/_api/clients/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from .http import HTTPCache, HTTPClient

__all__ = [
"HTTPCache",
"HTTPClient",
]
Loading