guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Guix Data Service client module


From: Christopher Baines
Subject: Re: Guix Data Service client module
Date: Fri, 04 Feb 2022 10:14:05 +0000
User-agent: mu4e 1.6.10; emacs 27.2

Ludovic Courtès <ludo@gnu.org> writes:

> Hello Guix!
>
> Here’s a client module for the Guix Data Service, allowing you to access
> a subset of the Guix Data Service interfaces from the comfort of your
> REPL.
>
> I had it sitting in my source tree for a while and Chris sent me an
> impressive shell one-liner that made me want to try from Scheme:
>
>   wget
> "https://data.guix-patches.cbaines.net/revision/47f85c53d954f857b45cebefee27ec512d917484/lint-warnings.json?locale=en_US.UTF-8&linter=input-labels&field=linter&field=message&field=location";
> -O - | jq -r '.lint_warnings | .[] | .package.name' | sort | uniq | wc
> -l
>
> Turns out we can do the same in two long lines of Scheme!
>
> scheme@(guix data-service)> (define s (open-data-service 
> "https://data.guix-patches.cbaines.net";))
> scheme@(guix data-service)> (length (delete-duplicates (map 
> lint-warning-package (revision-lint-warnings s 
> "47f85c53d954f857b45cebefee27ec512d917484" "input-labels"))))
> $6 = 3560
>
>
> (That counts the number of packages at that revision that have one or
> more warnings from the new ‘input-labels’ lint checker.)
>
> We can do other things, such as browsing package versions:
>
> scheme@(guix data-service)> (define s (open-data-service 
> "https://data.guix.gnu.org";))
> scheme@(guix data-service)> (package-version-branches (car (package-versions 
> (lookup-package s "emacs"))))
> $9 = (#<<branch> name: "master" repository-id: 1>)
> scheme@(guix data-service)> (package-version-history s (car $9) "emacs")
> $10 = (#<<package-version-range> version: "27.2" first-revision: #<<revision> 
> commit: "cc33f50d0e2a7835e99913226cb4c4b0e9e961ae" date: #<date nanosecond: 0 
> second: 54 minute: 30 hour: 20 day: 25 month: 3 year: 2021 zone-offset: 0>> 
> last-revision: #<<revision> commit: 
> "364b56124b88398c199aacbfd4fdfc9a1583e634" date: #<date nanosecond: 0 second: 
> 31 minute: 16 hour: 13 day: 27 month: 6 year: 2021 zone-offset: 0>>> 
> #<<package-version-range> version: "27.1" first-revision: #<<revision> 
> commit: "36a09d185343375a5cba370431870f9c4435d623" date: #<date nanosecond: 0 
> second: 52 minute: 16 hour: 4 day: 28 month: 8 year: 2020 zone-offset: 0>> 
> last-revision: #<<revision> commit: 
> "ac29d37e2ffd7a85adfcac9be4d5bce018289bec" date: #<date nanosecond: 0 second: 
> 2 minute: 36 hour: 17 day: 25 month: 3 year: 2021 zone-offset: 0>>> 
> #<<package-version-range> version: "26.3" first-revision: #<<revision> 
> commit: "43412ab967ee00789fe933f916d804aed9961c57" date: #<date nanosecond: 0 
> second: 29 minute: 36 hour: 3 day: 30 month: 8 year: 2019 zone-offset: 0>> 
> last-revision: #<<revision> commit: 
> "bf19d5e4b26a2e38fe93a45f9341e14476ea5f82" date: #<date nanosecond: 0 second: 
> 19 minute: 50 hour: 21 day: 27 month: 8 year: 2020 zone-offset: 0>>> 
> #<<package-version-range> version: "26.2" first-revision: #<<revision> 
> commit: "5069baedb8a902c3b1ea9656c11471658a1de56b" date: #<date nanosecond: 0 
> second: 8 minute: 46 hour: 22 day: 12 month: 4 year: 2019 zone-offset: 0>> 
> last-revision: #<<revision> commit: 
> "02c61278f1327d403f072f42e6b92a1dc62fc93a" date: #<date nanosecond: 0 second: 
> 35 minute: 44 hour: 0 day: 30 month: 8 year: 2019 zone-offset: 0>>> 
> #<<package-version-range> version: "26.1" first-revision: #<<revision> 
> commit: "897f303d2fa61497a931cf5fcb43349eb5f44c14" date: #<date nanosecond: 0 
> second: 47 minute: 31 hour: 7 day: 1 month: 1 year: 2019 zone-offset: 0>> 
> last-revision: #<<revision> commit: 
> "ee6c4b62b88640f3828cf73a30377124e16cb95f" date: #<date nanosecond: 0 second: 
> 51 minute: 8 hour: 20 day: 12 month: 4 year: 2019 zone-offset: 0>>>)
>
> Now all we need to do is plug it into the right tools and enjoy!

Thanks for writing this Ludo, sorry it's taken so long for me to have a
look.

I've had a little play around with it locally, and it seems to work
well.

I added some exports (included below) so that I could more easily use
the module.

Maybe open-data-service could have the url default to
"https://data.guix.gnu.org";.

The only thing I can see that's required before merging though is the
exports. I'm now thinking about this kind of thing (getting data out of
the data service) in the context of patch/branch review.

Thanks,

Chris



  #:export (repository?
            repository-id
            repository-label
            repository-url
            repository-branches

            branch?
            branch-name
            branch-repository-id

            package-version?
            package-version-string
            package-version-branches

            package?
            package-name
            package-versions

            revision?
            revision-commit
            revision-date

            build?
            build-server-id
            build-id
            build-time

            channel-instance?
            channel-instance-system
            channel-instance-derivation
            channel-instance-builds

            lint-warning?
            lint-warning-package
            lint-warning-package-version
            lint-warning-message
            lint-warning-location

            open-data-service

            lookup-package
            lookup-repository
            package-version-history
            revision-channel-instances
            revision-lint-warnings))

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]