all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Luciana Lima Brito <lubrito@posteo.net>
To: Christopher Baines <mail@cbaines.net>
Cc: guix-devel@gnu.org
Subject: Re: Outreachy - Guix Data Service: implementing basic json output for derivation comparison page
Date: Sun, 18 Apr 2021 13:19:21 +0000	[thread overview]
Message-ID: <20210418101921.473873a2@lubrito> (raw)
In-Reply-To: <20210418101207.3ad239ae@lubrito>

[-- Attachment #1: Type: text/plain, Size: 1438 bytes --]

On Sun, 18 Apr 2021 13:12:07 +0000
Luciana Lima Brito <lubrito@posteo.net> wrote:

> Hi,
> 
> On Sat, 17 Apr 2021 18:45:14 +0100
> Christopher Baines <mail@cbaines.net> 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?
> 

The last patch had a few misaligned parens, please disregard. This one
is fixed.

-- 
Best Regards,

Luciana Lima Brito
MSc. in Computer Science

[-- Attachment #2: 0001-Implement-basic-json-output-for-the-derivation-compa.patch --]
[-- Type: text/x-patch, Size: 4741 bytes --]

From ff348cb5ce7db9ce9f08a6f0827356faa6465877 Mon Sep 17 00:00:00 2001
From: Luciana Brito <lubrito@posteo.net>
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 | 83 +++++++++++++++++++-
 1 file changed, 80 insertions(+), 3 deletions(-)

diff --git a/guix-data-service/web/compare/controller.scm b/guix-data-service/web/compare/controller.scm
index a6aa198..2ff7a40 100644
--- a/guix-data-service/web/compare/controller.scm
+++ b/guix-data-service/web/compare/controller.scm
@@ -588,9 +588,86 @@
                  '(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


  reply	other threads:[~2021-04-18 13:19 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-14 19:48 Outreachy - Guix Data Service: implementing basic json output for derivation comparison page Luciana Lima Brito
2021-04-15  8:46 ` Christopher Baines
2021-04-15 16:09   ` Luciana Lima Brito
2021-04-15 23:19     ` Christopher Baines
2021-04-16 15:07       ` Luciana Lima Brito
2021-04-16 15:47         ` Christopher Baines
2021-04-16 18:46           ` Luciana Lima Brito
2021-04-16 19:17             ` Christopher Baines
2021-04-16 22:47               ` Luciana Lima Brito
2021-04-17  8:40                 ` Christopher Baines
2021-04-17 12:48                   ` Luciana Lima Brito
2021-04-17 13:11                     ` Christopher Baines
2021-04-17 14:08                       ` Luciana Lima Brito
2021-04-17 17:45                         ` Christopher Baines
2021-04-18 13:12                           ` Luciana Lima Brito
2021-04-18 13:19                             ` Luciana Lima Brito [this message]
2021-04-18 16:34                             ` Christopher Baines
2021-04-18 19:12                               ` Luciana Lima Brito
2021-04-19  8:26                                 ` Christopher Baines
2021-04-19 14:04                                   ` Luciana Lima Brito
2021-04-19 20:20                                     ` Christopher Baines
2021-04-19 20:56                                       ` Luciana Lima Brito

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=20210418101921.473873a2@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.