Subject: Re: bug#52117: [core-updates-frozen] [PATCH 0/6] Fix Julia packages.

From: Maxim Cournoyer <[email-masked]>
Date: Fri, 26 Nov 2021 22:17:02 -0500

Hello Simon!

zimoun <[email-masked]> writes:

> Even providing '--procs=1' launches 2 workers which breaks some testsuite of
                                                             ^ the 
> packages; therefore set '#:parallel-tests?' to '#false' was ineffective.
 ^ some               ^ setting

It's good to put the rationale here, as you did.

> * guix/build/julia-build-system.scm (check): Fix unexpected behaviour from
> 'julia' command line option.

But in the changelog message I'd expect to see foremost *what* it does
rather than a reformulation of *why* it does it :-).  E.g., something
like: do not pass the '--procs' argument when not running the tests in
parallel.

> ---
>  guix/build/julia-build-system.scm | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/guix/build/julia-build-system.scm b/guix/build/julia-build-system.scm
> index f0dc419c17..af478fd4a3 100644
> --- a/guix/build/julia-build-system.scm
> +++ b/guix/build/julia-build-system.scm
> @@ -112,7 +112,10 @@ (define* (check #:key tests? source inputs outputs julia-package-name
>             (builddir (string-append out "/share/julia/"))
>             (jobs (if parallel-tests?
>                       (number->string (parallel-job-count))
> -                     "1")))
> +                     "1"))
> +           (nprocs (if parallel-tests?
> +                       (string-append "--procs=" jobs)
> +                       "")))
>        ;; With a patch, SOURCE_DATE_EPOCH is honored
>        (setenv "SOURCE_DATE_EPOCH" "1")
>        (setenv "JULIA_DEPOT_PATH" builddir)
> @@ -122,8 +125,7 @@ (define* (check #:key tests? source inputs outputs julia-package-name
>                                   "")))
>        (setenv "JULIA_CPU_THREADS" jobs)
>        (setenv "HOME" "/tmp")
> -      (invoke "julia" "--depwarn=yes"
> -              (string-append "--procs=" jobs)
> +      (invoke "julia" "--depwarn=yes" nprocs

Here nprocs can be ""; is it really OK to pass an empty string argument
to julia?

>                (string-append builddir "loadpath/"
>                               package "/test/runtests.jl"))))
>    #t)

Trailing '#t' are no longer required.  Actually, looking at the output
of julia --help:

 -p, --procs {N|auto}      Integer value N launches N *additional* local worker processes

The key is 'additional' :-).  So to disable parallel processing it needs
to be 0.

I've modified it like so:

--8<---------------cut here---------------start------------->8---
(define* (check #:key tests? source inputs outputs julia-package-name
                parallel-tests? #:allow-other-keys)
  (when tests?
    (let* ((out (assoc-ref outputs "out"))
           (package (or julia-package-name (project.toml->name "Project.toml")))
           (builddir (string-append out "/share/julia/"))
           (job-count (if parallel-tests?
                          (parallel-job-count)
                          1))
           ;; The --proc argument of Julia *adds* extra processors rather than
           ;; specify the exact count to use, so zero must be specified to
           ;; disable parallel processing.
           (additional-procs (max 0 (1- job-count))))
      ;; With a patch, SOURCE_DATE_EPOCH is honored
      (setenv "SOURCE_DATE_EPOCH" "1")
      (setenv "JULIA_DEPOT_PATH" builddir)
      (setenv "JULIA_LOAD_PATH"
              (string-append builddir "loadpath/" ":"
                             (or (getenv "JULIA_LOAD_PATH")
                                 "")))
      (setenv "JULIA_CPU_THREADS" (number->string job-count))
      (setenv "HOME" "/tmp")
      (invoke "julia" "--depwarn=yes"
              "--procs" (number->string additional-procs)
              (string-append builddir "loadpath/"
                             package "/test/runtests.jl")))))
--8<---------------cut here---------------start------------->8---

And took the liberty to remove trailing #f in other phases.

Thank you!

Maxim