Skip to content

Commit

Permalink
Fix: Do not import onedal when OFF_ONEDAL_IFACE=1 (#1744)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
3 people authored Mar 19, 2024
1 parent f2926fd commit ef1fa89
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#! /usr/bin/env python
# ==============================================================================
# Copyright 2014 Intel Corporation
# Copyright 2024 Fujitsu Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -72,7 +73,7 @@
ONEDAL_2021_3 = 2021 * 10000 + 3 * 100
ONEDAL_2023_0_1 = 2023 * 10000 + 0 * 100 + 1
is_onedal_iface = (
os.environ.get("OFF_ONEDAL_IFACE") is None and ONEDAL_VERSION >= ONEDAL_2021_3
os.environ.get("OFF_ONEDAL_IFACE", "0") == "0" and ONEDAL_VERSION >= ONEDAL_2021_3
)

d4p_version = (
Expand Down
14 changes: 8 additions & 6 deletions sklearnex/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# ==============================================================================
# Copyright 2021 Intel Corporation
# Copyright 2024 Fujitsu Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -14,7 +15,7 @@
# limitations under the License.
# ==============================================================================

from onedal.common.hyperparameters import get_hyperparameters
import os

from . import utils
from ._config import config_context, get_config, set_config
Expand Down Expand Up @@ -50,12 +51,13 @@
"unpatch_sklearn",
"utils",
]
onedal_iface_flag = os.environ.get("OFF_ONEDAL_IFACE", "0")
if onedal_iface_flag == "0":
from onedal import _is_spmd_backend
from onedal.common.hyperparameters import get_hyperparameters


from onedal import _is_spmd_backend

if _is_spmd_backend:
__all__.append("spmd")
if _is_spmd_backend:
__all__.append("spmd")


from ._utils import set_sklearn_ex_verbose
Expand Down
3 changes: 2 additions & 1 deletion sklearnex/dispatcher.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# ==============================================================================
# Copyright 2021 Intel Corporation
# Copyright 2024 Fujitsu Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -22,7 +23,7 @@


def _is_new_patching_available():
return os.environ.get("OFF_ONEDAL_IFACE") is None and daal_check_version(
return os.environ.get("OFF_ONEDAL_IFACE", "0") == "0" and daal_check_version(
(2021, "P", 300)
)

Expand Down

0 comments on commit ef1fa89

Please sign in to comment.