From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:bcc0::]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id sKM2Lz45g2BRWgEAgWs5BA (envelope-from ) for ; Fri, 23 Apr 2021 23:16:46 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id 1H+qKj45g2A9ZwAAbx9fmQ (envelope-from ) for ; Fri, 23 Apr 2021 21:16:46 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 6F4B21698B for ; Fri, 23 Apr 2021 23:16:46 +0200 (CEST) Received: from localhost ([::1]:59858 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1la3AL-0004xZ-Hu for larch@yhetil.org; Fri, 23 Apr 2021 17:16:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60958) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1la39p-0004wb-2f for guix-devel@gnu.org; Fri, 23 Apr 2021 17:16:13 -0400 Received: from mout01.posteo.de ([185.67.36.65]:44975) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1la39k-0004HG-AZ for guix-devel@gnu.org; Fri, 23 Apr 2021 17:16:12 -0400 Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id 96778240026 for ; Fri, 23 Apr 2021 23:16:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1619212564; bh=Gkvl3geO3hE3PIMSEczeddYoBkL631lH9tvNmA/j16A=; h=Date:From:To:Cc:Subject:From; b=mSxaWRPzYaO8WuPDlY811K2ippQUB/otuzLJ/AxFAs7T4x2VsRF0xuDsnNDsLtogv bEBdpikw0Z0oqzlowrEnavYpUogtY1hPnxh07U6d8rRrSN9l6fulVRhZsxnRzzjWi2 GzsvaUV+TeT3g18vI+xClU5dZfPm6DkM2BPfZYcvf7vyTp3ybHuYNPiAISeuz3U56I j6g0R4ihPUZSXlUQBHR4aA8GMEOn6pnGoVGCZ5bFNQ+7g4Tjlizl/2fi7BAplOtnOS 3SgoYXUEWzMg6GgYKOI99S22vO//5RbDbMNTD8nAC6v0qtNqznxAE6TaGfLw4wohej zjW5teH71JN4w== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4FRnC61TXFz9rxK; Fri, 23 Apr 2021 23:16:01 +0200 (CEST) Date: Fri, 23 Apr 2021 21:15:51 +0000 From: Luciana Lima Brito To: Christopher Baines Subject: Re: Outreachy - Guix Data Service: questions about improving the data for derivation comparisons. Message-ID: <20210423181551.01c42455@lubrito> In-Reply-To: <87zgxqggw9.fsf@cbaines.net> References: <20210421152914.461bbdbb@lubrito> <87bla6iwli.fsf@cbaines.net> <20210422170040.37941083@lubrito> <875z0ehyl3.fsf@cbaines.net> <20210422180208.28473e41@lubrito> <87zgxqggw9.fsf@cbaines.net> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=185.67.36.65; envelope-from=lubrito@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: guix-devel@gnu.org Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: "Guix-devel" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1619212606; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=/bu8XpWvsonyIGDI/jxYaO6jZa/iU8SFbea47P/T088=; b=k5hGgU15G7+rH9pHI1se65zxqEuP60DzrokYsh8J2vT+k22ZFz+L5Jsf/SsUVTeipZGGFQ pCEyCWZnGLJ/RNbiERqmEzvwBrMpiSxYbnX7nyRt/eEuXK+IN5beDWWNgbdQy5qdCkYJTo o4AmONq44Xa6IjRpXNG8X+qhcHrEeS0gSrwFsqihjGO8WiJke5OliQ7Wm2Ff8xQIVOGQBl YEnFNBBGw6BWt3LJVnybLbjkk6bvW1onUi+k9Vn6rlO8xCRx/mSrnJKOOiFmx/pASvYKm3 3ARj1A+joMi9Xf253DPZkD5aAVAHdCDpMz4bvbnmouOTobc2Tmf3Lm1Q0ocb3g== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1619212606; a=rsa-sha256; cv=none; b=RMEKGHaPKuVP1XTDDLbjt6S7oxaG3IZ4xWYnzyFq9mij+ZuFRKKX1uA0xqDvBBj3jEwt3T QPqmtwrmWGla6ghWZhW5EHv7rueacjG23JwOVlUg6kf6BvXEsZcWtRf5cR/Lm0AkFfTVYt l7/89/7yknN9JeUjghdKGv/EMNKMWmflH1WeXVqZCLmqUuyiXszOqhIrXmd5SBBd34Dzem e9GtYBCR3kvdQWjjZwStwXNXMqnArjtoKpTZB1eFiJHhWd3HJ9hm0rXJSSCep/Rw0Wegcb BwykbDvwfSMLQ/aHQCxBz0AMlO31AQ1k1YSxKwmnn+/m0jqXXSkX7WKE6XjtAw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=mSxaWRPz; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of guix-devel-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-devel-bounces@gnu.org X-Migadu-Spam-Score: -2.64 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=mSxaWRPz; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of guix-devel-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-devel-bounces@gnu.org X-Migadu-Queue-Id: 6F4B21698B X-Spam-Score: -2.64 X-Migadu-Scanner: scn0.migadu.com X-TUID: MTbpmwSEERWt Hi, On Thu, 22 Apr 2021 22:15:34 +0100 Christopher Baines 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