summary refs log tree commit diff
diff options
context:
space:
mode:
authorMaxim Cournoyer <maxim.cournoyer@gmail.com>2022-04-18 17:23:40 -0400
committerMaxim Cournoyer <maxim.cournoyer@gmail.com>2022-05-12 12:45:55 -0400
commit1d1f44b7099a745028a4d99d623c709ab004524b (patch)
tree1f63cf6a70431836e98835c7b4999a7ed08131b7
parentc359a4fabba7c6fab2498d602f5a63d4cebcc5e4 (diff)
downloadguix-1d1f44b7099a745028a4d99d623c709ab004524b.tar.gz
gnu: python-scikit-learn: Parallelize build and test suite.
* gnu/packages/machine-learning.scm (python-scikit-learn)
[phases]{configure}: New phase.
{build-ext}: Add '-j' option.
{check}: Add '-n' option.
[native-inputs]: Add python-pytest-xdist.
-rw-r--r--gnu/packages/machine-learning.scm19
1 files changed, 13 insertions, 6 deletions
diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index 7f082ee677..b765257d98 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -16,7 +16,7 @@
 ;;; Copyright © 2020 Konrad Hinsen <konrad.hinsen@fastmail.net>
 ;;; Copyright © 2020 Edouard Klein <edk@beaver-labs.com>
 ;;; Copyright © 2020, 2021, 2022 Vinicius Monego <monego@posteo.net>
-;;; Copyright © 2020, 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2020, 2021, 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1095,8 +1095,13 @@ computing environments.")
     (arguments
      `(#:phases
        (modify-phases %standard-phases
+         (add-before 'build 'configure
+           (lambda _
+             (setenv "SKLEARN_BUILD_PARALLEL"
+                     (number->string (parallel-job-count)))))
          (add-after 'build 'build-ext
-           (lambda _ (invoke "python" "setup.py" "build_ext" "--inplace")))
+           (lambda _ (invoke "python" "setup.py" "build_ext" "--inplace"
+                             "-j" (number->string (parallel-job-count)))))
          (replace 'check
            (lambda* (#:key tests? #:allow-other-keys)
              (when tests?
@@ -1107,13 +1112,15 @@ computing environments.")
                (setenv "HOME" "/tmp")
 
                (invoke "pytest" "sklearn" "-m" "not network"
+                       "-n" (number->string (parallel-job-count))
                        ;; This test tries to access the internet.
                        "-k" "not test_load_boston_alternative")))))))
-    (inputs
-     (list openblas))
+    (inputs (list openblas))
     (native-inputs
-     (list python-pytest python-pandas ;for tests
-           python-cython))
+     (list python-cython
+           python-pandas
+           python-pytest
+           python-pytest-xdist))
     (propagated-inputs
      (list python-numpy python-threadpoolctl python-scipy python-joblib))
     (home-page "https://scikit-learn.org/")