From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id aKxTC00wfGC5FQAAgWs5BA (envelope-from ) for ; Sun, 18 Apr 2021 15:12:45 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id UA4JB00wfGBiFgAA1q6Kng (envelope-from ) for ; Sun, 18 Apr 2021 13:12:45 +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 C419D222F4 for ; Sun, 18 Apr 2021 15:12:44 +0200 (CEST) Received: from localhost ([::1]:50684 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lY7EB-0001kA-Ux for larch@yhetil.org; Sun, 18 Apr 2021 09:12:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44354) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lY7Dx-0001if-E3 for guix-devel@gnu.org; Sun, 18 Apr 2021 09:12:29 -0400 Received: from mout02.posteo.de ([185.67.36.66]:40835) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lY7Dv-0002pM-AF for guix-devel@gnu.org; Sun, 18 Apr 2021 09:12:29 -0400 Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id B290D2400E5 for ; Sun, 18 Apr 2021 15:12:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1618751542; bh=xaz42bm4MEUOULUsAKAuoFXYWLEt1LXQTXGJl0BmDbs=; h=Date:From:To:Cc:Subject:From; b=XxXomUc8Im3LDSRO2c8L1cmrWM1rOCX+Arw6FDgGyHbwczLk+vtRq8LuPczm5WDiW q2d93OfYAd/q8JaZgnXeo1/Svy3wFQym7Ha2nNZu5mrGB8Wk1rpiWC4TkF6USvo5RK QW8uFggkm8YeWoe3SVVBRSxCjcbRf/e1GuiU3QjBen7pJX/MTHH4/xVdsDG4VlrFRF 5ozipbWZEWnJxyvGFc1PWtq0Slv3WxWnU/Wl6zE/uu5q/MTdyturdLre6+F9P5Jr7Y 4U1ICnOEpdOqf4Vc6mstPkPHWP7JWHubsA9eiIPgBgStPguFemjjDh55b6ZzQLydaJ xuaA7gNpc0ENg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4FNVjJ3cBJz9rxR; Sun, 18 Apr 2021 15:12:20 +0200 (CEST) Date: Sun, 18 Apr 2021 13:12:07 +0000 From: Luciana Lima Brito To: Christopher Baines Subject: Re: Outreachy - Guix Data Service: implementing basic json output for derivation comparison page Message-ID: <20210418101207.3ad239ae@lubrito> In-Reply-To: <875z0kkdp1.fsf@cbaines.net> References: <20210414164859.7acc631f@lubrito> <87wnt4x7e3.fsf@cbaines.net> <20210415130947.7387a546@lubrito> <87o8efxhil.fsf@cbaines.net> <20210416120740.05a819ca@lubrito> <87czuuxmdd.fsf@cbaines.net> <20210416154600.62c4a97d@lubrito> <87a6pyxcme.fsf@cbaines.net> <20210416194735.0f4ccaed@lubrito> <877dl1xq15.fsf@cbaines.net> <20210417094857.14599c72@lubrito> <87bladjbsm.fsf@cbaines.net> <20210417110829.03ed516d@lubrito> <875z0kkdp1.fsf@cbaines.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/gKWY11DjLA5d0aynwHOO=Dz" Received-SPF: pass client-ip=185.67.36.66; envelope-from=lubrito@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, FROM_FMBLA_NEWDOM=1.499, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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=1618751564; 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:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=fgdKr79hqA0zcLef4PRPNS4tF7khoiKYq6nAyzOyKCs=; b=aeNPJQifM8SHJxqz/XzZ9Z1Ia8x+7eyv7/C3z50osT/SrrryWifmD/tPNSs+J/ZvkMXnVF IBcM9v0tp9fLQMLvJDnouI7EBe0D7o1jpjF4XBiwv4dhV3G23zQoMcQZ4vYij6mtDj9CKL IBEuLVL1/DRR+40Fs8uWvOHZ97ioon9J4uhwBTmoLBAtGpzvWjObLyKw1AupUu+ND3imOU Kby5Sy4suhNZn9OEInzsJGOAvez4DBmuZf96Xg9ezGuMEjovxz4EfE5Weu8KIFYGbzBL4x E6dB0v5AVF2c6hHN2i9CWCWoP0ArkH4ITwB+fxocR4x3ydA56kJrWHWk9+zqqA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1618751564; a=rsa-sha256; cv=none; b=mBXpsdmJytlDoM5r72c2XsUGxnRTZZqoo9eQh34BEoLYW8pbuG9MP9lSxZkFswJXS1MYue MocJP7saogC7AW25jyVCVSY+xQAZyff65aN/d3I8d1Gup4jzPOYJP8mVa/Y5CVuY5Z4fv3 2Wvh1V+mH7dWKvoKjSjshr7kZsHbKyqbsxgRke8nFTm/PelY/Q2+z5+PmjuRC0aRR4ly8P eFkoDmt+fpSOXvERKgtOOg/KJIohEC8uwW70RyH/KNSMwDeTQ6Z7nAnW2nlNFSykCEeqcm SbWAU9WoSiFaLZdlXcS4tBeHE0CuJzxyczW2NynYTIKGZqPnqauC+SO0etx9SA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=XxXomUc8; 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=XxXomUc8; 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: C419D222F4 X-Spam-Score: -2.64 X-Migadu-Scanner: scn0.migadu.com X-TUID: vqJ+2MZNFpz9 --MP_/gKWY11DjLA5d0aynwHOO=Dz Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, On Sat, 17 Apr 2021 18:45:14 +0100 Christopher Baines wrote: > Some more things to think about: > > - Variable naming, what does the "matched" in matched outputs mean? > (same goes for the other "matched" things) The name matched would refer to the match function, but I changed to *-values. The names I wanted were "outputs", "inputs" and "sources", but I already used them. If you have anything in mind, please let me know. > - (if (null? ...), I'm unsure if all of those checks are necessary, I > believe some fields at least will never be "null?". I revised it, I think now it's better. About the "recursive" field, apparently it assumes a string value "t" or "f", and I convert this to a boolean. Are there other values possible? > - Builder and arguments grouping, I think this makes sense on the > HTML page, as they're connected, but does it make sense in the JSON? indeed, I separated them. > I think you're getting close to something that's ready to merge > though. One last thing, I see that on the html the commom inputs are ommited. Does this make sense for the json too? -- Best Regards, Luciana Lima Brito MSc. in Computer Science --MP_/gKWY11DjLA5d0aynwHOO=Dz Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0001-Implement-basic-json-output-for-the-derivation-compa.patch >From 614ea09fc6a2d96a9dc2955ae08736740d08f8f8 Mon Sep 17 00:00:00 2001 From: Luciana Brito Date: Sun, 11 Apr 2021 11:06:06 -0300 Subject: [PATCH] Implement basic json output for the derivation comparison page --- guix-data-service/web/compare/controller.scm | 89 +++++++++++++++++++- 1 file changed, 86 insertions(+), 3 deletions(-) diff --git a/guix-data-service/web/compare/controller.scm b/guix-data-service/web/compare/controller.scm index a6aa198..09caa82 100644 --- a/guix-data-service/web/compare/controller.scm +++ b/guix-data-service/web/compare/controller.scm @@ -588,9 +588,92 @@ '(application/json text/html) mime-types) ((application/json) - (render-json - '((error . "unimplemented")) ; TODO - #:extra-headers http-headers-for-unchanging-content)) + (let* ((outputs (assq-ref data 'outputs)) + (output-values + (map + (lambda (label items) + (cons label + (list->vector + (map + (match-lambda + ((name path hash-alg hash recursive) + `((name . ,name) + (path . ,path) + ,@(if (not (string? hash-alg)) + '() + `((hash-algorithm . ,hash-alg)) + ) + ,@(if (not (string? hash)) + '() + `((hash . ,hash)) + ) + (recursive . ,(string=? recursive "t")) + ) + )) + (or items '()))))) + '(base target common) + (list (assq-ref outputs 'base) + (assq-ref outputs 'target) + (assq-ref outputs 'common)))) + + (inputs (assq-ref data 'inputs)) + (input-values + (map + (lambda (label items) + (cons label + (list->vector + (map + (match-lambda + ((derivation output) + `((derivation . ,derivation) + (output . ,output) + ))) + (or items '()))))) + '(base target common) + (list (assq-ref inputs 'base) + (assq-ref inputs 'target)))) + + (sources (assq-ref data 'sources)) + (source-values + (map + (lambda (label items) + (cons label + (list->vector + (map + (match-lambda + ((derivation) + `((derivation . ,derivation) + ))) + (or items '()))))) + '(base target common) + (list (assq-ref sources 'base) + (assq-ref sources 'target) + (assq-ref sources 'common)))) + + (args (assq-ref data 'arguments)) + (base-args (list->vector (assq-ref args 'base))) + (target-args (list->vector (assq-ref args 'target)))) + + (render-json + `((base + . ((derivation . ,base-derivation))) + (target + . ((derivation . ,target-derivation))) + (outputs + . ,output-values) + (inputs + . ,input-values) + (sources + . ,source-values) + (system + . ,(assq-ref data 'system)) + (builder + . ,(assq-ref data 'builder)) + (arguments + . ((base . ,base-args) + (target . ,target-args))) + (environment-variables . ,(assq-ref data 'environment-variables))) + #:extra-headers http-headers-for-unchanging-content))) (else (render-html #:sxml (compare/derivation -- 2.30.2 --MP_/gKWY11DjLA5d0aynwHOO=Dz--