From 2ee61851f4b9736a68428da97fd157659dd4059b Mon Sep 17 00:00:00 2001 From: ethanglaser Date: Tue, 3 Dec 2024 17:12:48 -0800 Subject: [PATCH 1/3] ci: run_examples warnings to errors --- examples/daal4py/readcsv.py | 11 +++++++++-- examples/mb/readcsv.py | 9 +++++++-- examples/sklearnex/knn_bf_regression_spmd.py | 4 ++-- tests/run_examples.py | 6 +++--- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/examples/daal4py/readcsv.py b/examples/daal4py/readcsv.py index 564b8cbd18..e19d4d6733 100644 --- a/examples/daal4py/readcsv.py +++ b/examples/daal4py/readcsv.py @@ -14,19 +14,26 @@ # limitations under the License. # ============================================================================== -from importlib.machinery import SourceFileLoader +from importlib.util import spec_from_file_location, module_from_spec from pathlib import Path utils_path = Path(__file__).parent.parent / "utils" +module_name = "readcsv" +module_path = str(utils_path / "readcsv.py") -readcsv = SourceFileLoader("readcsv", str(utils_path / "readcsv.py")).load_module() +spec = spec_from_file_location(module_name, module_path) +readcsv = module_from_spec(spec) +spec.loader.exec_module(readcsv) np_read_csv = readcsv.np_read_csv pd_read_csv = readcsv.pd_read_csv csr_read_csv = readcsv.csr_read_csv +read_next = readcsv.read_next __all__ = [ "np_read_csv", "pd_read_csv", "csr_read_csv", + "read_next", ] + diff --git a/examples/mb/readcsv.py b/examples/mb/readcsv.py index 5edf201907..3d59d97213 100644 --- a/examples/mb/readcsv.py +++ b/examples/mb/readcsv.py @@ -14,13 +14,18 @@ # limitations under the License. # ============================================================================== -from importlib.machinery import SourceFileLoader +from importlib.util import spec_from_file_location, module_from_spec from pathlib import Path utils_path = Path(__file__).parent.parent / "utils" +module_name = "readcsv" +module_path = str(utils_path / "readcsv.py") -readcsv = SourceFileLoader("readcsv", str(utils_path / "readcsv.py")).load_module() +spec = spec_from_file_location(module_name, module_path) +readcsv = module_from_spec(spec) +spec.loader.exec_module(readcsv) np_read_csv = readcsv.np_read_csv pd_read_csv = readcsv.pd_read_csv csr_read_csv = readcsv.csr_read_csv + diff --git a/examples/sklearnex/knn_bf_regression_spmd.py b/examples/sklearnex/knn_bf_regression_spmd.py index 28ce112290..863c79d8e2 100644 --- a/examples/sklearnex/knn_bf_regression_spmd.py +++ b/examples/sklearnex/knn_bf_regression_spmd.py @@ -21,7 +21,7 @@ import numpy as np from mpi4py import MPI from numpy.testing import assert_allclose -from sklearn.metrics import mean_squared_error +from sklearn.metrics import root_mean_squared_error from sklearnex.spmd.neighbors import KNeighborsRegressor @@ -80,6 +80,6 @@ def generate_X_y(par, coef_seed, data_seed): ) print( "RMSE for entire rank {}: {}\n".format( - rank, mean_squared_error(y_test, dpt.to_numpy(y_predict), squared=False) + rank, root_mean_squared_error(y_test, dpt.to_numpy(y_predict)) ) ) diff --git a/tests/run_examples.py b/tests/run_examples.py index ba84c26968..feb78e2383 100755 --- a/tests/run_examples.py +++ b/tests/run_examples.py @@ -223,10 +223,10 @@ def get_exe_cmd(ex, args): return None if not args.nodist and ex.endswith("spmd.py"): if IS_WIN: - return 'mpiexec -localonly -n 4 "' + sys.executable + '" "' + ex + '"' - return 'mpirun -n 4 "' + sys.executable + '" "' + ex + '"' + return 'mpiexec -localonly -n 4 "' + sys.executable + '" -W error "' + ex + '"' + return 'mpirun -n 4 "' + sys.executable + '" -W error "' + ex + '"' else: - return '"' + sys.executable + '" "' + ex + '"' + return '"' + sys.executable + '" -W error "' + ex + '"' def run(exdir, logdir, args): From 4ad5e7e2837f67bbc1b1b5a958f0ac88abc9361d Mon Sep 17 00:00:00 2001 From: ethanglaser Date: Wed, 4 Dec 2024 12:01:43 -0800 Subject: [PATCH 2/3] isorted --- examples/daal4py/readcsv.py | 2 +- examples/mb/readcsv.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/daal4py/readcsv.py b/examples/daal4py/readcsv.py index e19d4d6733..e2d7241b99 100644 --- a/examples/daal4py/readcsv.py +++ b/examples/daal4py/readcsv.py @@ -14,7 +14,7 @@ # limitations under the License. # ============================================================================== -from importlib.util import spec_from_file_location, module_from_spec +from importlib.util import module_from_spec, spec_from_file_location from pathlib import Path utils_path = Path(__file__).parent.parent / "utils" diff --git a/examples/mb/readcsv.py b/examples/mb/readcsv.py index 3d59d97213..8c7000d472 100644 --- a/examples/mb/readcsv.py +++ b/examples/mb/readcsv.py @@ -14,7 +14,7 @@ # limitations under the License. # ============================================================================== -from importlib.util import spec_from_file_location, module_from_spec +from importlib.util import module_from_spec, spec_from_file_location from pathlib import Path utils_path = Path(__file__).parent.parent / "utils" From 62f7d5c9a19c7653ab875dc66ee8769ceacc4d0a Mon Sep 17 00:00:00 2001 From: ethanglaser Date: Thu, 5 Dec 2024 05:21:42 -0800 Subject: [PATCH 3/3] blacked --- examples/daal4py/readcsv.py | 1 - examples/mb/readcsv.py | 1 - tests/run_examples.py | 4 +++- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/daal4py/readcsv.py b/examples/daal4py/readcsv.py index e2d7241b99..8651ee1d71 100644 --- a/examples/daal4py/readcsv.py +++ b/examples/daal4py/readcsv.py @@ -36,4 +36,3 @@ "csr_read_csv", "read_next", ] - diff --git a/examples/mb/readcsv.py b/examples/mb/readcsv.py index 8c7000d472..f66455ce65 100644 --- a/examples/mb/readcsv.py +++ b/examples/mb/readcsv.py @@ -28,4 +28,3 @@ np_read_csv = readcsv.np_read_csv pd_read_csv = readcsv.pd_read_csv csr_read_csv = readcsv.csr_read_csv - diff --git a/tests/run_examples.py b/tests/run_examples.py index feb78e2383..de1676469e 100755 --- a/tests/run_examples.py +++ b/tests/run_examples.py @@ -223,7 +223,9 @@ def get_exe_cmd(ex, args): return None if not args.nodist and ex.endswith("spmd.py"): if IS_WIN: - return 'mpiexec -localonly -n 4 "' + sys.executable + '" -W error "' + ex + '"' + return ( + 'mpiexec -localonly -n 4 "' + sys.executable + '" -W error "' + ex + '"' + ) return 'mpirun -n 4 "' + sys.executable + '" -W error "' + ex + '"' else: return '"' + sys.executable + '" -W error "' + ex + '"'