GNU bug report logs - #58136
[PATCH] ui: Improve sort order when searching package names.

Previous Next

Package: guix-patches;

Reported by: Lars-Dominik Braun <lars <at> 6xq.net>

Date: Wed, 28 Sep 2022 09:28:02 UTC

Severity: normal

Tags: moreinfo, patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 58136 in the body.
You can then email your comments to 58136 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to ludo <at> gnu.org, guix-patches <at> gnu.org:
bug#58136; Package guix-patches. (Wed, 28 Sep 2022 09:28:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Lars-Dominik Braun <lars <at> 6xq.net>:
New bug report received and forwarded. Copy sent to ludo <at> gnu.org, guix-patches <at> gnu.org. (Wed, 28 Sep 2022 09:28:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Lars-Dominik Braun <lars <at> 6xq.net>
To: guix-patches <at> gnu.org
Subject: [PATCH] ui: Improve sort order when searching package names.
Date: Wed, 28 Sep 2022 11:27:37 +0200
Hi,

we provide a `guix serach`-based package search to our users and noticed
that searching for “ggplot2” yields the package r-ggplot2 on position
11 only – when it should be the first. Looking at other potential
search terms (haven, shiny, ape, renv, here, ini, setuptools) reveals
similar issues.

I propose we also score the unprefixed package name, so SCORE can award
bonus points for a full string match. I don’t like that we have to
maintain a list of common prefixes for this and that package names are
scored twice now, but I can’t think of a better solution right now.

Cheers,
Lars


* guix/ui.scm (%package-metrics): Increase score for PACKAGE-NAME and
add score for unprefixed package name.
---
 guix/ui.scm | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/guix/ui.scm b/guix/ui.scm
index dad2b853ac..55b596ed35 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -1655,7 +1655,38 @@ (define (regexp->score regexp)
 (define %package-metrics
   ;; Metrics used to compute the "relevance score" of a package against a set
   ;; of regexps.
-  `((,package-name . 4)
+  `((,package-name . 8)
+
+    ;; For packages with a language prefix (namespaces), also compare the
+    ;; unprefixed name, so searching for “ggplot2” yields
+    ;; r-ggplot2 as first result instead of other, higher-ranked packages,
+    ;; which contain “ggplot2” in their description alot.
+    (,(lambda (package)
+        (let ((namespaces (list "cl-"
+                                "ecl-"
+                                "emacs-"
+                                "ghc-"
+                                "go-"
+                                "guile-"
+                                "java-"
+                                "julia-"
+                                "node-"
+                                "ocaml-"
+                                "perl-"
+                                "python-"
+                                "r-"
+                                "ruby-"
+                                "rust-"
+                                "sbcl-"
+                                "texlive-"))
+              (name (package-name package)))
+          (fold (lambda (prefix accum)
+                  (if (string-prefix? prefix name)
+                      (cons (substring name (string-length prefix)) accum)
+                      accum))
+                '()
+                namespaces)))
+       . 4)
 
     ;; Match against uncommon outputs.
     (,(lambda (package)
-- 
2.35.1





Information forwarded to guix-patches <at> gnu.org:
bug#58136; Package guix-patches. (Wed, 28 Sep 2022 14:43:02 GMT) Full text and rfc822 format available.

Message #8 received at 58136 <at> debbugs.gnu.org (full text, mbox):

From: zimoun <zimon.toutoune <at> gmail.com>
To: Lars-Dominik Braun <lars <at> 6xq.net>, 58136 <at> debbugs.gnu.org
Cc: ludo <at> gnu.org
Subject: Re: [bug#58136] [PATCH] ui: Improve sort order when searching
 package names.
Date: Wed, 28 Sep 2022 16:26:38 +0200
Hi Lars,

On Wed, 28 Sep 2022 at 11:27, Lars-Dominik Braun <lars <at> 6xq.net> wrote:

> I propose we also score the unprefixed package name, so SCORE can award
> bonus points for a full string match. I don’t like that we have to
> maintain a list of common prefixes for this and that package names are
> scored twice now, but I can’t think of a better solution right now.

In addition to your proposal which LGTM, maybe we could also use the
’upstream-name’ properties.  Most of the time, the Guix name matches the
upstream name, but sometimes not.  Although, it would not fix the issue
for ggplot2 since there is no upstream-name for this package. :-)

Well, I propose something like see below (based on your patch):

 1. keep the weight as 4
 2. set the “namespace” weight to 1 (or 2 if you prefer)

    Otherwise, for example, generic name as CSV could artificially bump
    the relevance and hide relevant packages.  For instance, compare

       guix search csv

 3. use upstream-name if provided

WDYT?


--8<---------------cut here---------------start------------->8---
diff --git a/guix/ui.scm b/guix/ui.scm
index 55b596ed35..14f296a546 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -1655,7 +1655,7 @@ (define (regexp->score regexp)
 (define %package-metrics
   ;; Metrics used to compute the "relevance score" of a package against a set
   ;; of regexps.
-  `((,package-name . 8)
+  `((,package-name . 4)
 
     ;; For packages with a language prefix (namespaces), also compare the
     ;; unprefixed name, so searching for “ggplot2” yields
@@ -1684,9 +1684,9 @@ (define %package-metrics
                   (if (string-prefix? prefix name)
                       (cons (substring name (string-length prefix)) accum)
                       accum))
-                '()
+                (list (package-upstream-name package))
                 namespaces)))
-       . 4)
+     . 1)
 
     ;; Match against uncommon outputs.
     (,(lambda (package)
--8<---------------cut here---------------end--------------->8---


Cheers,
simon




Information forwarded to guix-patches <at> gnu.org:
bug#58136; Package guix-patches. (Wed, 28 Sep 2022 20:24:02 GMT) Full text and rfc822 format available.

Message #11 received at 58136 <at> debbugs.gnu.org (full text, mbox):

From: Maxime Devos <maximedevos <at> telenet.be>
To: zimoun <zimon.toutoune <at> gmail.com>, Lars-Dominik Braun <lars <at> 6xq.net>,
 58136 <at> debbugs.gnu.org
Cc: ludo <at> gnu.org
Subject: Re: [bug#58136] [PATCH] ui: Improve sort order when searching package
 names.
Date: Wed, 28 Sep 2022 22:23:04 +0200
[Message part 1 (text/plain, inline)]
> +    ;; For packages with a language prefix (namespaces), also compare the

You missed "minetest-"

On 28-09-2022 16:26, zimoun wrote:
>   3. use upstream-name if provided
> 
> WDYT?

For the Minetest mods (which have upstream-names like "Jeija/mesecons"), 
I don't think think the upstream-name is useful as-is

Greetings,
Maxime.
[OpenPGP_0x49E3EE22191725EE.asc (application/pgp-keys, attachment)]
[OpenPGP_signature (application/pgp-signature, attachment)]

Information forwarded to guix-patches <at> gnu.org:
bug#58136; Package guix-patches. (Wed, 28 Sep 2022 20:46:02 GMT) Full text and rfc822 format available.

Message #14 received at 58136 <at> debbugs.gnu.org (full text, mbox):

From: Maxime Devos <maximedevos <at> telenet.be>
To: zimoun <zimon.toutoune <at> gmail.com>, Lars-Dominik Braun <lars <at> 6xq.net>,
 58136 <at> debbugs.gnu.org
Cc: ludo <at> gnu.org
Subject: Re: [bug#58136] [PATCH] ui: Improve sort order when searching package
 names.
Date: Wed, 28 Sep 2022 22:45:38 +0200
[Message part 1 (text/plain, inline)]

On 28-09-2022 22:23, Maxime Devos wrote:
> You missed "minetest-"

Also, "lua-".
[OpenPGP_0x49E3EE22191725EE.asc (application/pgp-keys, attachment)]
[OpenPGP_signature (application/pgp-signature, attachment)]

Information forwarded to guix-patches <at> gnu.org:
bug#58136; Package guix-patches. (Wed, 28 Sep 2022 21:41:01 GMT) Full text and rfc822 format available.

Message #17 received at 58136 <at> debbugs.gnu.org (full text, mbox):

From: zimoun <zimon.toutoune <at> gmail.com>
To: Maxime Devos <maximedevos <at> telenet.be>, Lars-Dominik Braun
 <lars <at> 6xq.net>, 58136 <at> debbugs.gnu.org
Cc: ludo <at> gnu.org
Subject: Re: [bug#58136] [PATCH] ui: Improve sort order when searching
 package names.
Date: Wed, 28 Sep 2022 23:40:02 +0200
Hi,

On mer., 28 sept. 2022 at 22:23, Maxime Devos <maximedevos <at> telenet.be> wrote:

> On 28-09-2022 16:26, zimoun wrote:
>>   3. use upstream-name if provided
>
> For the Minetest mods (which have upstream-names like "Jeija/mesecons"), 
> I don't think think the upstream-name is useful as-is

Using the change I am proposing, just knowing ’jeija’ returns a match:

--8<---------------cut here---------------start------------->8---
$ ./pre-inst-env guix search jeija
name: minetest-mesecons
version: 1.2.1-63.27c3c51
outputs:
+ out: everything else
systems: x86_64-linux
dependencies: 
location: gnu/packages/minetest.scm:367:4
homepage: https://mesecons.net
license: LGPL 3, CC-BY-SA 3.0
synopsis: Digital circuitry for Minetest, including wires, buttons and lights  
description: Mesecons is a mod for Minetest implementing various items
+ related to digital circuitry, such as wires, buttons, lights and programmable
+ controllers.  Among other things, there are also pistons, solar panels,
+ pressure plates and note blocks.
+ 
+ Mesecons has a similar goal to Redstone in Minecraft, but works in its own
+ way, with different rules and mechanics.
relevance: 4
--8<---------------cut here---------------end--------------->8---

which is better than nothing.

Well, upstream-name is not so much useful as-is but it can help for some
cases.


Cheers,
simon




Information forwarded to guix-patches <at> gnu.org:
bug#58136; Package guix-patches. (Wed, 28 Sep 2022 21:44:01 GMT) Full text and rfc822 format available.

Message #20 received at 58136 <at> debbugs.gnu.org (full text, mbox):

From: Maxime Devos <maximedevos <at> telenet.be>
To: zimoun <zimon.toutoune <at> gmail.com>, Lars-Dominik Braun <lars <at> 6xq.net>,
 58136 <at> debbugs.gnu.org
Cc: ludo <at> gnu.org
Subject: Re: [bug#58136] [PATCH] ui: Improve sort order when searching package
 names.
Date: Wed, 28 Sep 2022 23:43:44 +0200
[Message part 1 (text/plain, inline)]

On 28-09-2022 23:40, zimoun wrote:
> Using the change I am proposing, just knowing ’jeija’ returns a match:
> 
> --8<---------------cut here---------------start------------->8---
> $ ./pre-inst-env guix search jeija
> name: minetest-mesecons
> [...]

Right, didn't think of that.

Greetings,
Maxime.
[OpenPGP_0x49E3EE22191725EE.asc (application/pgp-keys, attachment)]
[OpenPGP_signature (application/pgp-signature, attachment)]

Information forwarded to guix-patches <at> gnu.org:
bug#58136; Package guix-patches. (Sat, 01 Oct 2022 21:44:02 GMT) Full text and rfc822 format available.

Message #23 received at 58136 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: zimoun <zimon.toutoune <at> gmail.com>
Cc: 58136 <at> debbugs.gnu.org, Lars-Dominik Braun <lars <at> 6xq.net>
Subject: Re: [bug#58136] [PATCH] ui: Improve sort order when searching
 package names.
Date: Sat, 01 Oct 2022 23:42:54 +0200
Hi,

zimoun <zimon.toutoune <at> gmail.com> skribis:

> Well, I propose something like see below (based on your patch):
>
>  1. keep the weight as 4
>  2. set the “namespace” weight to 1 (or 2 if you prefer)
>
>     Otherwise, for example, generic name as CSV could artificially bump
>     the relevance and hide relevant packages.  For instance, compare
>
>        guix search csv
>
>  3. use upstream-name if provided

Maybe something like:

  (define %package-metrics
    `((,package-name . 4)
      (,package-upstream-name* . 4)  ;or a lower weight, dunno
      …))

where:

  (define (package-upstream-name* package)
    (or (assoc-ref (package-properties package) 'upstream-name)
        (package-name-sans-namespace package)))  ;strip "r-", "emacs-", etc.

WDYT?

(Perhaps ‘package-upstream-name’ could be taught about these implicit
name conversions done for R, Python, Emacs, etc.?)

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#58136; Package guix-patches. (Sun, 02 Oct 2022 09:05:02 GMT) Full text and rfc822 format available.

Message #26 received at 58136 <at> debbugs.gnu.org (full text, mbox):

From: zimoun <zimon.toutoune <at> gmail.com>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: Lars-Dominik Braun <lars <at> 6xq.net>, 58136 <at> debbugs.gnu.org
Subject: Re: [bug#58136] [PATCH] ui: Improve sort order when searching
 package names.
Date: Sun, 02 Oct 2022 10:26:26 +0200
Hi,

On Sat, 01 Oct 2022 at 23:42, Ludovic Courtès <ludo <at> gnu.org> wrote:

>   (define (package-upstream-name* package)
>     (or (assoc-ref (package-properties package) 'upstream-name)
>         (package-name-sans-namespace package)))  ;strip "r-", "emacs-", etc.

I think it is better to rely on ’package-upstream-name’ and hides the
plumbing.  It helps when something needs to be “refactored“, IMHO.


> (Perhaps ‘package-upstream-name’ could be taught about these implicit
> name conversions done for R, Python, Emacs, etc.?)

Maybe, but it requires to scrutinize importer per importer since
upstream name is mainly used by these, IIUC.


Cheers,
simon




Information forwarded to guix-patches <at> gnu.org:
bug#58136; Package guix-patches. (Wed, 12 Oct 2022 11:25:01 GMT) Full text and rfc822 format available.

Message #29 received at 58136 <at> debbugs.gnu.org (full text, mbox):

From: Lars-Dominik Braun <ldb <at> leibniz-psychology.org>
To: zimoun <zimon.toutoune <at> gmail.com>
Cc: ludo <at> gnu.org, 58136 <at> debbugs.gnu.org
Subject: Re: [bug#58136] [PATCH] ui: Improve sort order when searching
 package names.
Date: Wed, 12 Oct 2022 13:24:08 +0200
[Message part 1 (text/plain, inline)]
Hi simon,

> In addition to your proposal which LGTM, maybe we could also use the
> ’upstream-name’ properties.  Most of the time, the Guix name matches the
> upstream name, but sometimes not.  Although, it would not fix the issue
> for ggplot2 since there is no upstream-name for this package. :-)
I agree that using the upstream-name would be a good idea.

>  2. set the “namespace” weight to 1 (or 2 if you prefer)
> 
>     Otherwise, for example, generic name as CSV could artificially bump
>     the relevance and hide relevant packages.  For instance, compare
> 
>        guix search csv
The issue here is we don’t know what the user is searching for. If we
add more weight to the package name then usually libraries (rust-csv,
ghc-csv, …) win. Imo a search for “csv” should return tools to
manipulate CSV files like csvkit, csvdiff, xlsx2csv, … Just like
“json” should yield tools like jq, json.sh and possibly others which
I cannot find right now. But maybe I’m searching for a C library that
parses CSV instead. And then what…?

As for ggplot2, the particular issue seems to be that scores are added
for each match and the description for some of our packages contains
“ggplot2” alot. So I tried using MAX instead of +, which works,
but results in little variation of scores and thus weird sort order
(descending by name). It does not feel like an improvement either.

Cheers,
Lars

-- 
Lars-Dominik Braun
Wissenschaftlicher Mitarbeiter/Research Associate

www.leibniz-psychology.org
ZPID - Leibniz-Institut für Psychologie /
ZPID - Leibniz Institute for Psychology
Universitätsring 15
D-54296 Trier - Germany
Tel.: +49–651–201-4964
[v2.patch (text/plain, attachment)]
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#58136; Package guix-patches. (Mon, 17 Oct 2022 07:47:02 GMT) Full text and rfc822 format available.

Message #32 received at 58136 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Lars-Dominik Braun <ldb <at> leibniz-psychology.org>
Cc: 58136 <at> debbugs.gnu.org, zimoun <zimon.toutoune <at> gmail.com>
Subject: Re: bug#58136: [PATCH] ui: Improve sort order when searching
 package names.
Date: Mon, 17 Oct 2022 09:46:28 +0200
Hi!

Lars-Dominik Braun <ldb <at> leibniz-psychology.org> skribis:

> diff --git a/guix/packages.scm b/guix/packages.scm
> index 94e464cd01..9934501cdb 100644
> --- a/guix/packages.scm
> +++ b/guix/packages.scm
> @@ -86,6 +86,7 @@ (define-module (guix packages)
>              this-package
>              package-name
>              package-upstream-name
> +            package-upstream-name*
>              package-version
>              package-full-name
>              package-source
> @@ -657,6 +658,38 @@ (define (package-upstream-name package)
>    (or (assq-ref (package-properties package) 'upstream-name)
>        (package-name package)))
>  
> +(define (package-upstream-name* package)
> +  "Return the upstream name of PACKAGE, which could be different from the name
> +it has in Guix."

s/which could.*Guix/accounting for commonly-used package name prefixes
in addition to the @code{upstream-name} property/

Preferably make this addition in a separate commit.

> +++ b/guix/ui.scm
> @@ -1623,10 +1623,23 @@ (define (relevance obj regexps metrics)
>    (define (score regexp str)
>      (fold-matches regexp str 0
>                    (lambda (m score)
> -                    (+ score
> -                       (if (string=? (match:substring m) str)
> -                           5             ;exact match
> -                           1)))))
> +                    (let* ((start (- (match:start m) 1))
> +                           (end (match:end m))
> +                           (left (if (>= start 0) (string-ref str start) #f))
> +                           (right (if (< end (string-length str)) (string-ref str end) #f))
> +                           (delimiter-classes '(Cc Cf Pd Pe Pf Pi Po Ps Sk Zs Zl Zp))
> +                           (delim-left (or (member (and=> left char-general-category) delimiter-classes) (eq? left #f)))
> +                           (delim-right (or (member (and=> right char-general-category) delimiter-classes) (eq? right #f))))
> +                      (max score
> +                        (cond
> +                          ;; regexp is a full match for str.
> +                          ((and (eq? left #f) (eq? right #f)) 4)
> +                          ;; regexp matches a single word in str.
> +                          ((and delim-left delim-right) 3)
> +                          ;; regexp matches the beginning or end of a word in str.
> +                          ((or delim-left delim-right) 2)
> +                          ;; Everything else.
> +                          (#t 1)))))))

The intent is to have all regexps behave as if the user passed \<STR\>,
is that right?  Would be nice to have a comment clarifying that above
and perhaps making it a separate change?

Stylistic notes:

  (if cond consequent #f)  =>  (and cond consequent)
  (eq? x #f)               =>  (not x)
  (cond … (#t x))          =>  (cond … (else x))

> @@ -1635,10 +1648,11 @@ (define (regexp->score regexp)
>                  ((field . weight)
>                   (match (field obj)
>                     (#f  relevance)
> +                   ('() relevance)
>                     ((? string? str)
> -                    (+ relevance (* (score-regexp str) weight)))
> +                    (max relevance (* (score-regexp str) weight)))
>                     ((lst ...)
> -                    (+ relevance (* weight (apply + (map score-regexp lst)))))))))
> +                    (max relevance (* weight (apply max (map score-regexp lst)))))))))

Intuitively I would expect scores to add up, otherwise we’re kinda
losing information; so I would not make this change.  WDYT?

There’s a test for ‘package-relevance’ in tests/ui.scm.  Please make
sure it still passes and ideally add relevant tests such as the CSV
example you gave.

Thanks!

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#58136; Package guix-patches. (Mon, 17 Oct 2022 09:31:03 GMT) Full text and rfc822 format available.

Message #35 received at 58136 <at> debbugs.gnu.org (full text, mbox):

From: zimoun <zimon.toutoune <at> gmail.com>
To: Ludovic Courtès <ludo <at> gnu.org>, Lars-Dominik Braun
 <ldb <at> leibniz-psychology.org>
Cc: 58136 <at> debbugs.gnu.org
Subject: Re: [bug#58136] [PATCH] ui: Improve sort order when searching
 package names.
Date: Mon, 17 Oct 2022 10:19:48 +0200
Hi Lars, Ludo,

In short, I miss why the initial patch with a minor tweak is not enough
for covering the corner cases. :-)


On lun., 17 oct. 2022 at 09:46, Ludovic Courtès <ludo <at> gnu.org> wrote:
>> +++ b/guix/ui.scm
>> @@ -1623,10 +1623,23 @@ (define (relevance obj regexps metrics)
>>    (define (score regexp str)
>>      (fold-matches regexp str 0
>>                    (lambda (m score)
>> -                    (+ score
>> -                       (if (string=? (match:substring m) str)
>> -                           5             ;exact match
>> -                           1)))))
>> +                    (let* ((start (- (match:start m) 1))
>> +                           (end (match:end m))
>> +                           (left (if (>= start 0) (string-ref str start) #f))
>> +                           (right (if (< end (string-length str)) (string-ref str end) #f))
>> +                           (delimiter-classes '(Cc Cf Pd Pe Pf Pi Po Ps Sk Zs Zl Zp))
>> +                           (delim-left (or (member (and=> left char-general-category) delimiter-classes) (eq? left #f)))
>> +                           (delim-right (or (member (and=> right char-general-category) delimiter-classes) (eq? right #f))))
>> +                      (max score
>> +                        (cond
>> +                          ;; regexp is a full match for str.
>> +                          ((and (eq? left #f) (eq? right #f)) 4)
>> +                          ;; regexp matches a single word in str.
>> +                          ((and delim-left delim-right) 3)
>> +                          ;; regexp matches the beginning or end of a word in str.
>> +                          ((or delim-left delim-right) 2)
>> +                          ;; Everything else.
>> +                          (#t 1)))))))
>
> The intent is to have all regexps behave as if the user passed \<STR\>,
> is that right?  Would be nice to have a comment clarifying that above
> and perhaps making it a separate change?

All this appears to me overcomplicated.  Personally, I have to read it
many times to get the logic; while the initial patch was much clearer,
IMHO.

Other said, I am not convinced the complexity is worth the corner case.


The initial patch with the minor tweak I am proposing (maybe using
package-upstream-name*) appears to me enough for covering the corner
cases initially reported (as ggplot2).


>> @@ -1635,10 +1648,11 @@ (define (regexp->score regexp)
>>                  ((field . weight)
>>                   (match (field obj)
>>                     (#f  relevance)
>> +                   ('() relevance)
>>                     ((? string? str)
>> -                    (+ relevance (* (score-regexp str) weight)))
>> +                    (max relevance (* (score-regexp str) weight)))
>>                     ((lst ...)
>> -                    (+ relevance (* weight (apply + (map score-regexp lst)))))))))
>> +                    (max relevance (* weight (apply max (map score-regexp lst)))))))))
>
> Intuitively I would expect scores to add up, otherwise we’re kinda
> losing information; so I would not make this change.  WDYT?

I agree with Ludo that ’max’ is counterintuitive.


Well, could we list some examples (keyword and expectation)?  Because
the initial patch with a minor tweak LGTM and covers ggplot2, csv, and
some others.


Cheers,
simon




Added tag(s) moreinfo. Request was from Christopher Baines <mail <at> cbaines.net> to control <at> debbugs.gnu.org. (Thu, 03 Nov 2022 15:46:02 GMT) Full text and rfc822 format available.

Information forwarded to guix-patches <at> gnu.org:
bug#58136; Package guix-patches. (Fri, 09 Dec 2022 11:50:01 GMT) Full text and rfc822 format available.

Message #40 received at 58136 <at> debbugs.gnu.org (full text, mbox):

From: Lars-Dominik Braun <lars <at> 6xq.net>
To: 58136 <at> debbugs.gnu.org
Cc: Ludovic Courtès <ludo <at> gnu.org>,
 zimoun <zimon.toutoune <at> gmail.com>
Subject: Re: [PATCH] ui: Improve sort order when searching package names.
Date: Fri, 9 Dec 2022 12:49:32 +0100
[Message part 1 (text/plain, inline)]
Hi,

attached is version 2 of my initial patch, which simply moves prefix
detection into PACKAGE-UPSTREAM-NAME* (as suggested by Ludo) and reduces
the score to 2 (as suggested by Simon). It’s therefore quite tailored
to the “ggplot2 problem”, but does the job.

Thanks,
Lars

[0001-packages-Add-package-upstream-name.patch (text/plain, attachment)]
[0002-ui-Take-package-upstream-name-into-account-when-sear.patch (text/plain, attachment)]

Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Tue, 13 Dec 2022 13:30:02 GMT) Full text and rfc822 format available.

Notification sent to Lars-Dominik Braun <lars <at> 6xq.net>:
bug acknowledged by developer. (Tue, 13 Dec 2022 13:30:02 GMT) Full text and rfc822 format available.

Message #45 received at 58136-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Lars-Dominik Braun <lars <at> 6xq.net>
Cc: 58136-done <at> debbugs.gnu.org, zimoun <zimon.toutoune <at> gmail.com>
Subject: Re: [PATCH] ui: Improve sort order when searching package names.
Date: Tue, 13 Dec 2022 14:28:58 +0100
[Message part 1 (text/plain, inline)]
Hi,

Lars-Dominik Braun <lars <at> 6xq.net> skribis:

> From e0092d786b29f4f1cdc35217212a86804f36cdb4 Mon Sep 17 00:00:00 2001
> From: Lars-Dominik Braun <lars <at> 6xq.net>
> Date: Fri, 9 Dec 2022 11:46:37 +0100
> Subject: [PATCH v2 1/2] packages: Add 'package-upstream-name*'.
>
> * guix/packages.scm (package-upstream-name*): New procedure.
> * tests/packages.scm ("package-upstream-name*"): New test.

[...]

> From 5e0e8c0145a728d0ed49116596f06cc15e1e865d Mon Sep 17 00:00:00 2001
> From: Lars-Dominik Braun <lars <at> 6xq.net>
> Date: Fri, 9 Dec 2022 12:01:31 +0100
> Subject: [PATCH v2 2/2] ui: Take package upstream name into account when
>  searching.
>
> * guix/ui.scm (%package-metrics): Add PACKAGE-UPSTREAM-NAME*.

Applied with the minor changes below, thank you!

Ludo’.

[Message part 2 (text/x-patch, inline)]
diff --git a/guix/packages.scm b/guix/packages.scm
index 5e8e3a4ff4..6e61e16aa4 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -718,11 +718,11 @@ (define (package-upstream-name* package)
     (or (assq-ref (package-properties package) 'upstream-name)
         (let loop ((prefixes namespaces))
           (match prefixes
-            ('() name)
+            (() name)
             ((prefix rest ...)
               (if (string-prefix? prefix name)
                 (substring name (string-length prefix))
-                (loop (cdr prefixes)))))))))
+                (loop rest))))))))
 
 (define (hidden-package p)
   "Return a \"hidden\" version of P--i.e., one that 'fold-packages' and thus,
[Message part 3 (text/plain, inline)]
and:

[Message part 4 (text/x-patch, inline)]
diff --git a/tests/ui.scm b/tests/ui.scm
index 6a25a204ca..438acae525 100644
--- a/tests/ui.scm
+++ b/tests/ui.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2019, 2020 Ludovic Courtès <ludo <at> gnu.org>
+;;; Copyright © 2013-2017, 2019-2020, 2022 Ludovic Courtès <ludo <at> gnu.org>
 ;;; Copyright © 2022 Taiju HIGASHI <higashi <at> taiju.info>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -294,6 +294,15 @@ (define guile-2.0.9
          (>0 (package-relevance libb2
                                 (map rx '("crypto" "library")))))))
 
+(test-assert "package-relevance and upstream name"
+  ;; https://issues.guix.gnu.org/58136
+  (let ((ggplot2  (specification->package "r-ggplot2"))
+        (ggstance (specification->package "r-ggstance"))
+        (rx       (make-regexp "ggplot2" regexp/icase)))
+    (> (package-relevance ggplot2 (list rx))
+       (package-relevance ggstance (list rx))
+       0)))
+
 (define (make-empty-file directory file)
   ;; Create FILE in DIRECTORY.
   (close-port (open-output-file (in-vicinity directory file))))

Information forwarded to guix-patches <at> gnu.org:
bug#58136; Package guix-patches. (Tue, 13 Dec 2022 14:55:01 GMT) Full text and rfc822 format available.

Message #48 received at 58136 <at> debbugs.gnu.org (full text, mbox):

From: Lars-Dominik Braun <lars <at> 6xq.net>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 58136 <at> debbugs.gnu.org
Subject: Re: [PATCH] ui: Improve sort order when searching package names.
Date: Tue, 13 Dec 2022 15:53:41 +0100
Hi Ludo,

> Applied with the minor changes below, thank you!
thank you!

> +(test-assert "package-relevance and upstream name"
> +  ;; https://issues.guix.gnu.org/58136
> +  (let ((ggplot2  (specification->package "r-ggplot2"))
> +        (ggstance (specification->package "r-ggstance"))
> +        (rx       (make-regexp "ggplot2" regexp/icase)))
> +    (> (package-relevance ggplot2 (list rx))
> +       (package-relevance ggstance (list rx))
> +       0)))
I was hesitant to add a system test, which depends on real package
descriptions (not synthetic ones), because at some point it *will* break.

Cheers,
Lars





Information forwarded to guix-patches <at> gnu.org:
bug#58136; Package guix-patches. (Tue, 13 Dec 2022 16:41:01 GMT) Full text and rfc822 format available.

Message #51 received at 58136 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Lars-Dominik Braun <lars <at> 6xq.net>
Cc: 58136 <at> debbugs.gnu.org
Subject: Re: [PATCH] ui: Improve sort order when searching package names.
Date: Tue, 13 Dec 2022 17:40:36 +0100
Hi,

Lars-Dominik Braun <lars <at> 6xq.net> skribis:

>> Applied with the minor changes below, thank you!
> thank you!
>
>> +(test-assert "package-relevance and upstream name"
>> +  ;; https://issues.guix.gnu.org/58136
>> +  (let ((ggplot2  (specification->package "r-ggplot2"))
>> +        (ggstance (specification->package "r-ggstance"))
>> +        (rx       (make-regexp "ggplot2" regexp/icase)))
>> +    (> (package-relevance ggplot2 (list rx))
>> +       (package-relevance ggstance (list rx))
>> +       0)))
> I was hesitant to add a system test, which depends on real package
> descriptions (not synthetic ones), because at some point it *will* break.

Yes, that’s a tradeoff.  For now, I would think the test is a plus as it
will allow us to see if future tweaks break this use case but yeah, on
the day it breaks, we’ll have to rewrite it or to drop it.

Ludo’.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 11 Jan 2023 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 104 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.