Skip to content

Commit ef1fa89

Browse files
ajay-fujiDarshan PatelAjay Kumar Patel
authored
Fix: Do not import onedal when OFF_ONEDAL_IFACE=1 (#1744)
* Fix: Do not import onedal when OFF_ONEDAL_IFACE=1 * Added copyright * Update condition code to unset OFF_ONEDAL_IFACE when set to 0 * Update and add Copyright * Update to os.environ.get(..) for uniformity --------- Co-authored-by: Darshan Patel <[email protected]> Co-authored-by: Ajay Kumar Patel <[email protected]>
1 parent f2926fd commit ef1fa89

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#! /usr/bin/env python
22
# ==============================================================================
33
# Copyright 2014 Intel Corporation
4+
# Copyright 2024 Fujitsu Limited
45
#
56
# Licensed under the Apache License, Version 2.0 (the "License");
67
# you may not use this file except in compliance with the License.
@@ -72,7 +73,7 @@
7273
ONEDAL_2021_3 = 2021 * 10000 + 3 * 100
7374
ONEDAL_2023_0_1 = 2023 * 10000 + 0 * 100 + 1
7475
is_onedal_iface = (
75-
os.environ.get("OFF_ONEDAL_IFACE") is None and ONEDAL_VERSION >= ONEDAL_2021_3
76+
os.environ.get("OFF_ONEDAL_IFACE", "0") == "0" and ONEDAL_VERSION >= ONEDAL_2021_3
7677
)
7778

7879
d4p_version = (

sklearnex/__init__.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# ==============================================================================
22
# Copyright 2021 Intel Corporation
3+
# Copyright 2024 Fujitsu Limited
34
#
45
# Licensed under the Apache License, Version 2.0 (the "License");
56
# you may not use this file except in compliance with the License.
@@ -14,7 +15,7 @@
1415
# limitations under the License.
1516
# ==============================================================================
1617

17-
from onedal.common.hyperparameters import get_hyperparameters
18+
import os
1819

1920
from . import utils
2021
from ._config import config_context, get_config, set_config
@@ -50,12 +51,13 @@
5051
"unpatch_sklearn",
5152
"utils",
5253
]
54+
onedal_iface_flag = os.environ.get("OFF_ONEDAL_IFACE", "0")
55+
if onedal_iface_flag == "0":
56+
from onedal import _is_spmd_backend
57+
from onedal.common.hyperparameters import get_hyperparameters
5358

54-
55-
from onedal import _is_spmd_backend
56-
57-
if _is_spmd_backend:
58-
__all__.append("spmd")
59+
if _is_spmd_backend:
60+
__all__.append("spmd")
5961

6062

6163
from ._utils import set_sklearn_ex_verbose

sklearnex/dispatcher.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# ==============================================================================
22
# Copyright 2021 Intel Corporation
3+
# Copyright 2024 Fujitsu Limited
34
#
45
# Licensed under the Apache License, Version 2.0 (the "License");
56
# you may not use this file except in compliance with the License.
@@ -22,7 +23,7 @@
2223

2324

2425
def _is_new_patching_available():
25-
return os.environ.get("OFF_ONEDAL_IFACE") is None and daal_check_version(
26+
return os.environ.get("OFF_ONEDAL_IFACE", "0") == "0" and daal_check_version(
2627
(2021, "P", 300)
2728
)
2829

0 commit comments

Comments
 (0)