Skip to content

Commit

Permalink
Merge branch 'remove_the_batch_suffix_from_examples' of https://githu…
Browse files Browse the repository at this point in the history
…b.com/razdoburdin/scikit-learn-intelex into remove_the_batch_suffix_from_examples
  • Loading branch information
Dmitry Razdoburdin committed Jul 27, 2023
2 parents f277e4f + 240ced7 commit 0c4704d
Show file tree
Hide file tree
Showing 220 changed files with 10,523 additions and 7,102 deletions.
1 change: 1 addition & 0 deletions .ci/pipeline/build-and-test-lnx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ steps:
bash .ci/scripts/setup_sklearn.sh $(SKLEARN_VERSION)
pip install --upgrade -r requirements-test.txt -r requirements-test-optional.txt
pip install $(python .ci/scripts/get_compatible_scipy_version.py)
if [ $(echo $(PYTHON_VERSION) | grep '3.8\|3.9\|3.10') ]; then conda install -q -y -c intel dpnp; fi
pip list
displayName: 'Install testing requirements'
- script: |
Expand Down
14 changes: 0 additions & 14 deletions .ci/pipeline/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,6 @@ variables:
ARGS: '1'

jobs:
- job: PEP8
pool:
vmImage: 'ubuntu-22.04'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.9'
addToPath: true
- script: |
python -m pip install --upgrade pip setuptools
pip install flake8
flake8 --ignore=E265,E722,E402,F401,F403,W503 --max-line-length=90 --count
displayName: 'PEP 8 check'
- job: Linux
timeoutInMinutes: 120
strategy:
Expand Down
13 changes: 0 additions & 13 deletions .ci/pipeline/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,6 @@ variables:
value: python

jobs:
- job: PEP8
pool:
vmImage: 'ubuntu-22.04'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.9'
addToPath: true
- script: |
python -m pip install --upgrade pip setuptools
pip install flake8
flake8 --ignore=E265,E722,E402,F401,F403,W503 --max-line-length=90 --count
displayName: 'PEP 8 check'
- job: Docs
pool:
vmImage: 'ubuntu-22.04'
Expand Down
2 changes: 1 addition & 1 deletion .circleci/run_xpu_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
if args.device == "gpu":
from sklearnex._config import config_context
with config_context(
target_offload=args.device, allow_fallback_to_host=True):
target_offload=args.device, allow_fallback_to_host=False):
pytest.main(
pytest_params + ["--pyargs", "sklearn"] + yml_deselected_tests
)
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Lint

on: [pull_request, push]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- id: changedfiles
name: Get list of changed .py files
run: |
set -x
echo "CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep .py$ | xargs)" >> "$GITHUB_OUTPUT"
if [[ $(git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep .py$ | wc -l) -eq 0 ]]; then
echo "HAS_CHANGES=false" >> "$GITHUB_OUTPUT"
else
echo "HAS_CHANGES=true" >> "$GITHUB_OUTPUT"
fi
- uses: actions/setup-python@v4
name: Setup python for isort
if: steps.changedfiles.outputs.HAS_CHANGES == 'true'
with:
python-version: "3.10"
- name: Run isort on changed files
if: steps.changedfiles.outputs.HAS_CHANGES == 'true'
run: |
set -x
python -m pip install isort
isort --check ${{ steps.changedfiles.outputs.CHANGED_FILES }}
- uses: psf/black@stable
name: Run black on changed files
if: steps.changedfiles.outputs.HAS_CHANGES == 'true'
with:
src: ${{ steps.changedfiles.outputs.CHANGED_FILES }}
27 changes: 27 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#===============================================================================
# Copyright 2023 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#===============================================================================

repos:
- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
- id: black
language_version: python3.10
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
language_version: python3.10
12 changes: 12 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,15 @@ To contribute your changes directly to the repository, do the following:
- [Submit](https://github.com/intel/scikit-learn-intelex/pulls) a pull request into the `master` branch. Provide a brief description of the changes you are contributing.

Public CI is enabled for the repository. Your PR should pass all of our checks. We will review your contribution and, if any additional fixes or modifications are necessary, we may give some feedback to guide you. When accepted, your pull request will be merged into our GitHub repository.

## Code Style

We use [black](https://black.readthedocs.io/en/stable/) and [isort](https://pycqa.github.io/isort/) formatters for Python* code. The line length is 90 characters; use default options otherwise. You can find the linter configuration in our [.pyproject.toml](https://github.com/intel/scikit-learn-intelex/blob/master/pyproject.toml).
A GitHub* Action verifies if your changes comply with the output of the auto-formatting tools.

Optionally, you can install pre-commit hooks that do the formatting for you. For this, run from the top level of the repository:

```bash
pip install pre-commit
pre-commit install
```
33 changes: 18 additions & 15 deletions daal4py/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
#===============================================================================
# ===============================================================================
# Copyright 2014 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -13,44 +13,47 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#===============================================================================
# ===============================================================================

import platform

if "Windows" in platform.system():
import os
import sys
import site
import sys

current_path = os.path.dirname(__file__)
path_to_env = site.getsitepackages()[0]
path_to_libs = os.path.join(path_to_env, "Library", "bin")
path_to_oneapi_backend = os.path.join(current_path, "oneapi")
if sys.version_info.minor >= 8:
if 'DALROOT' in os.environ:
dal_root_redist = os.path.join(os.environ['DALROOT'], "redist", "intel64")
if "DALROOT" in os.environ:
dal_root_redist = os.path.join(os.environ["DALROOT"], "redist", "intel64")
if os.path.exists(dal_root_redist):
os.add_dll_directory(dal_root_redist)
os.environ['PATH'] = dal_root_redist + os.pathsep + os.environ['PATH']
os.environ["PATH"] = dal_root_redist + os.pathsep + os.environ["PATH"]
os.add_dll_directory(path_to_libs)
os.add_dll_directory(path_to_oneapi_backend)
os.environ['PATH'] = path_to_libs + os.pathsep + os.environ['PATH']
os.environ["PATH"] = path_to_libs + os.pathsep + os.environ["PATH"]

try:
from daal4py._daal4py import *
from daal4py._daal4py import (
_get__version__,
__has_dist__,
_get__daal_link_version__,
_get__daal_run_version__,
__has_dist__)
_get__version__,
)
except ImportError as e:
s = str(e)
if 'libfabric' in s:
if "libfabric" in s:
raise ImportError(
s + '\n\nActivating your conda environment or sourcing mpivars.'
'[c]sh/psxevars.[c]sh may solve the issue.\n')
s + "\n\nActivating your conda environment or sourcing mpivars."
"[c]sh/psxevars.[c]sh may solve the issue.\n"
)

raise

from . import mb
from . import sklearn
from . import mb, sklearn

__all__ = ['mb', 'sklearn']
__all__ = ["mb", "sklearn"]
28 changes: 16 additions & 12 deletions daal4py/__main__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
#===============================================================================
# ===============================================================================
# Copyright 2014 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -13,9 +13,10 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#===============================================================================
# ===============================================================================

import sys

from .sklearn import patch_sklearn


Expand All @@ -29,27 +30,30 @@ def _main():
Python* patches of scikit-learn, optimizing solvers of
scikit-learn with Intel(R) oneAPI Data Analytics Library.
""",
formatter_class=argparse.ArgumentDefaultsHelpFormatter)

parser.add_argument('-m', action='store_true', dest='module',
help="Executes following as a module")
parser.add_argument('name', help="Script or module name")
parser.add_argument('args', nargs=argparse.REMAINDER,
help="Command line arguments")
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)

parser.add_argument(
"-m", action="store_true", dest="module", help="Executes following as a module"
)
parser.add_argument("name", help="Script or module name")
parser.add_argument("args", nargs=argparse.REMAINDER, help="Command line arguments")
args = parser.parse_args()

try:
import sklearn

patch_sklearn()
except ImportError:
print("Scikit-learn could not be imported. Nothing to patch")

sys.argv = [args.name] + args.args
if '_' + args.name in globals():
return globals()['_' + args.name](*args.args)
if "_" + args.name in globals():
return globals()["_" + args.name](*args.args)
import runpy

runf = runpy.run_module if args.module else runpy.run_path
runf(args.name, run_name='__main__')
runf(args.name, run_name="__main__")


sys.exit(_main())
6 changes: 3 additions & 3 deletions daal4py/mb/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
#===============================================================================
# ===============================================================================
# Copyright 2023 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -13,8 +13,8 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#===============================================================================
# ===============================================================================

from .model_builders import GBTDAALBaseModel, convert_model

__all__ = ['GBTDAALBaseModel', 'convert_model']
__all__ = ["GBTDAALBaseModel", "convert_model"]
Loading

0 comments on commit 0c4704d

Please sign in to comment.