From: Luciana Lima Brito <lubrito@posteo.net>
To: Christopher Baines <mail@cbaines.net>
Cc: guix-devel@gnu.org
Subject: Re: Outreachy - Guix Data Service: questions about improving the data for derivation comparisons.
Date: Fri, 23 Apr 2021 21:15:51 +0000 [thread overview]
Message-ID: <20210423181551.01c42455@lubrito> (raw)
In-Reply-To: <87zgxqggw9.fsf@cbaines.net>
Hi,
On Thu, 22 Apr 2021 22:15:34 +0100
Christopher Baines <mail@cbaines.net> wrote:
I'm stuck.
> I'd suggest avoiding '() as the value for hash and hash-algorithm when
> they're NULL in the database. One option here that I've used in some
> places is to return a alist rather than a list. This can simplify JSON
> output since it's often a alist that's desired, and can avoid breaking
> matches when they're matching on the list.
>
> Does that make sense?
It is not so clear to me. I tried three ways, always testing on
"outputs":
First, I tried using an alist within
the map function on derivation-outputs-differences-data
(comparison.scm), and I applied a list->vector on the result. It
worked, but I do believe that this is not the way we want it to be.
This way the label comes as another field, and I got the result like
this:
code:
`((label . ,(cond
((and (memq base-derivation-id
parsed-derivation-ids)
(memq target-derivation-id
parsed-derivation-ids))
'common)
((memq base-derivation-id parsed-derivation-ids)
'base)
(else 'target)))
(name . ,output-name)
(path . ,path)
,@(if (string? hash-algorithm)
`((hash-algorithm . ,hash-algorithm))
'())
,@(if (string? hash)
`((hash . ,hash))
'())
(recursive . ,(string=? recursive "t")))
json outputs:
0:
label: "base"
name: "foo"
path: "bar"
recursive: #f
This way I only used the function derivation-outputs-differences-data,
not using group-to-alist or group-by-last-element.
The second way I tried was to pass an alist as first element of the list
and append the labels (base or/and target):
(list
`((name . ,output-name)
(path . ,path)
,(if (string? hash-algorithm)
`(hash-algorithm . ,hash-algorithm)
'())
,(if (string? hash)
`(hash . ,hash)
'())
(recursive . ,(string=? recursive "t")))
(append (if (memq base-derivation-id
parsed-derivation-ids)
'(base)
'())
(if (memq target-derivation-id
parsed-derivation-ids)
'(target)
'())))
But this seemed to result in an extra parenthesis in the result, which
didn't work.
So I tried a third way, using the pairs
individually in the list and the append.
(list
`(name . ,output-name)
`(path . ,path)
(if (string? hash-algorithm)
`(hash-algorithm . ,hash-algorithm)
'())
(if (string? hash)
`(hash . ,hash)
'())
`(recursive . ,(string=? recursive "t"))
(append (if (memq base-derivation-id
parsed-derivation-ids)
'(base)
'())
(if (memq target-derivation-id
parsed-derivation-ids)
'(target)
'())))
Furthermore, all these methods would require tweaking the html
processing.
Here is an idea I just had. The first way I tried returned a
vector. This worked but kind of ugly. As I am already
getting the alist, I just thought about writing another function to
group by the first elements (the labels), something like this:
(group-by-first-element l)
where l is the alist I get from the first method I mentioned.
And then, I would have the following alist:
((base (...))
(target (...))
(common ((...)(...)(...))))
which is the current alist we are using in controller.scm.
Problem is, I still don't know how to do this, and this seems somewhat
too long winded to get the proper alist.
--
Best Regards,
Luciana Lima Brito
MSc. in Computer Science
next prev parent reply other threads:[~2021-04-23 21:16 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-21 18:29 Outreachy - Guix Data Service: questions about improving the data for derivation comparisons Luciana Lima Brito
2021-04-22 7:53 ` Christopher Baines
2021-04-22 20:00 ` Luciana Lima Brito
2021-04-22 20:08 ` Christopher Baines
2021-04-22 21:02 ` Luciana Lima Brito
2021-04-22 21:15 ` Christopher Baines
2021-04-23 21:15 ` Luciana Lima Brito [this message]
2021-04-23 21:48 ` Christopher Baines
2021-04-25 20:15 ` Luciana Lima Brito
2021-04-26 8:15 ` Christopher Baines
2021-04-26 19:11 ` Luciana Lima Brito
2021-04-26 21:21 ` Christopher Baines
2021-04-27 13:10 ` Luciana Lima Brito
2021-04-27 18:23 ` Christopher Baines
2021-04-27 18:33 ` Luciana Lima Brito
2021-04-27 18:42 ` Christopher Baines
2021-04-27 19:53 ` Luciana Lima Brito
2021-04-27 20:29 ` Christopher Baines
2021-04-27 22:35 ` Luciana Lima Brito
2021-04-28 7:56 ` Christopher Baines
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210423181551.01c42455@lubrito \
--to=lubrito@posteo.net \
--cc=guix-devel@gnu.org \
--cc=mail@cbaines.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.