From e153a8727c3bf1cb9fcfd15eb990beec0d83c12c Mon Sep 17 00:00:00 2001 From: Eman Abdelhaleem Date: Wed, 24 Dec 2025 17:44:38 +0200 Subject: [PATCH 1/3] safely imported openml-sklearn --- openml/runs/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/openml/runs/__init__.py b/openml/runs/__init__.py index 6d3dca504..d378bc19e 100644 --- a/openml/runs/__init__.py +++ b/openml/runs/__init__.py @@ -1,5 +1,7 @@ # License: BSD 3-Clause +import importlib.util + from .functions import ( delete_run, get_run, @@ -15,6 +17,9 @@ from .run import OpenMLRun from .trace import OpenMLRunTrace, OpenMLTraceIteration +if importlib.util.find_spec("openml_sklearn"): + import openml_sklearn # noqa: F401 + __all__ = [ "OpenMLRun", "OpenMLRunTrace", From ea748d054de2b5f7be627b0de16bd71e10ef016a Mon Sep 17 00:00:00 2001 From: Eman Abdelhaleem Date: Fri, 26 Dec 2025 00:34:53 +0200 Subject: [PATCH 2/3] safely imported openml-sklearn in both flows and models --- openml/extensions/functions.py | 12 ++++++++++-- openml/runs/__init__.py | 5 ----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/openml/extensions/functions.py b/openml/extensions/functions.py index 7a944c997..7009ae331 100644 --- a/openml/extensions/functions.py +++ b/openml/extensions/functions.py @@ -1,6 +1,7 @@ # License: BSD 3-Clause from __future__ import annotations +import importlib.util from typing import TYPE_CHECKING, Any # Need to implement the following by its full path because otherwise it won't be possible to @@ -16,8 +17,7 @@ SKLEARN_HINT = ( "But it looks related to scikit-learn. " "Please install the OpenML scikit-learn extension (openml-sklearn) and try again. " - "For more information, see " - "https://github.com/openml/openml-sklearn?tab=readme-ov-file#installation" + "You can use `pip install openml-sklearn` for installation." ) @@ -58,6 +58,10 @@ def get_extension_by_flow( ------- Extension or None """ + # import openml_sklearn to register SklearnExtension + if importlib.util.find_spec("openml_sklearn"): + import openml_sklearn # noqa: F401 + candidates = [] for extension_class in openml.extensions.extensions: if extension_class.can_handle_flow(flow): @@ -103,6 +107,10 @@ def get_extension_by_model( ------- Extension or None """ + # import openml_sklearn to register SklearnExtension + if importlib.util.find_spec("openml_sklearn"): + import openml_sklearn # noqa: F401 + candidates = [] for extension_class in openml.extensions.extensions: if extension_class.can_handle_model(model): diff --git a/openml/runs/__init__.py b/openml/runs/__init__.py index d378bc19e..6d3dca504 100644 --- a/openml/runs/__init__.py +++ b/openml/runs/__init__.py @@ -1,7 +1,5 @@ # License: BSD 3-Clause -import importlib.util - from .functions import ( delete_run, get_run, @@ -17,9 +15,6 @@ from .run import OpenMLRun from .trace import OpenMLRunTrace, OpenMLTraceIteration -if importlib.util.find_spec("openml_sklearn"): - import openml_sklearn # noqa: F401 - __all__ = [ "OpenMLRun", "OpenMLRunTrace", From 2b388dd6c0fdc0679ff2a6c7a0acc682db423933 Mon Sep 17 00:00:00 2001 From: Eman Abdelhaleem Date: Sun, 28 Dec 2025 11:05:50 +0200 Subject: [PATCH 3/3] update SKLEARN_HINT --- openml/extensions/functions.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openml/extensions/functions.py b/openml/extensions/functions.py index 7009ae331..06902325e 100644 --- a/openml/extensions/functions.py +++ b/openml/extensions/functions.py @@ -18,6 +18,8 @@ "But it looks related to scikit-learn. " "Please install the OpenML scikit-learn extension (openml-sklearn) and try again. " "You can use `pip install openml-sklearn` for installation." + "For more information, see " + "https://docs.openml.org/python/extensions/" )