[{"id":23896,"web_url":"https://patchwork.libcamera.org/comment/23896/","msgid":"<YtCszE9W8yWMkKQG@pendragon.ideasonboard.com>","date":"2022-07-14T23:54:52","subject":"Re: [libcamera-devel] [PATCH v5 7/8] utils: raspberrypi: ctt:\n\tOutput version 2.0 format tuning files","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Naush,\n\nThank you for the patch.\n\nOn Thu, Jul 14, 2022 at 04:24:08PM +0100, Naushir Patuck via libcamera-devel wrote:\n> Use the tuning file conversion script to output the new tuning file format from\n> the CTT.\n> \n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> ---\n>  utils/raspberrypi/ctt/ctt.py | 13 ++++++-------\n>  1 file changed, 6 insertions(+), 7 deletions(-)\n> \n> diff --git a/utils/raspberrypi/ctt/ctt.py b/utils/raspberrypi/ctt/ctt.py\n> index 15064634c67f..0d91ada15afa 100755\n> --- a/utils/raspberrypi/ctt/ctt.py\n> +++ b/utils/raspberrypi/ctt/ctt.py\n> @@ -15,7 +15,7 @@ from ctt_alsc import *\n>  from ctt_lux import *\n>  from ctt_noise import *\n>  from ctt_geq import *\n> -from ctt_pretty_print_json import *\n\nctt_pretty_print_json.py isn't used anymore, should it be dropped ?\n\n> +from convert_tuning import convert_v2\n>  import random\n>  import json\n>  import re\n> @@ -511,13 +511,12 @@ class Camera:\n>      \"\"\"\n>      def write_json(self):\n>          \"\"\"\n> -        Write json dictionary to file\n> +        Write json dictionary to file using our version 2 format\n>          \"\"\"\n> -        jstring = json.dumps(self.json, sort_keys=False)\n> -        \"\"\"\n> -        make it pretty :)\n> -        \"\"\"\n> -        pretty_print_json(jstring, self.jf)\n> +        out_json = convert_v2(self.json)\n\nThat's cheating :-) I'm OK with it for now, Would it be difficult to\noutput the v2 format natively though ? It seems that something along the\nlines of the following code should do:\n\n        out_json = {\n\t    \"version\": \"2.0\",\n\t    \"algorithms\": [{name: data} for name, data in self.json.items()],\n\t}\n\nand then you could import the Encoder class from convert_tuning instead\nof the convert_v2 function, and do\n\n        with open(self.jf, 'w') as f:\n            f.write(json.dumps(out_json, cls=Encoder, indent=4, sort_keys=False))\n\nPossibly even better, the Encoder class could be moved from\nconvert_tuning.py to ctt_pretty_print_json and replace the existing\nhand-written JSONPrettyPrinter.\n\n> +\n> +        with open(self.jf, 'w') as f:\n> +            f.write(out_json)\n>  \n>      \"\"\"\n>      add a new section to the log file","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id D4400BD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 14 Jul 2022 23:55:26 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 21D9763312;\n\tFri, 15 Jul 2022 01:55:26 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7E4A560489\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 15 Jul 2022 01:55:24 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E17B89DA;\n\tFri, 15 Jul 2022 01:55:23 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1657842926;\n\tbh=bdVC5iNxkuS0IOFiimt3t0i66xXm8J/gkqWLCTvwKc8=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=H2o5spO9fSnM7L7wLpqiEzoXh19+WIkHL5mZ5J95ZI306295P3DUXT0bjm1pMyKBy\n\to5wPAYCaWM65wJOv02S6U0Buo/qd1hyxZYZWgNljl/5w8N8ctqet8PgXTFTeOOhMtD\n\tdnECtLFLgzDvy1Fnw0enK6Wsb70Z+M6IuXtQbpyzIMZFJhmb0XnELz5jdCVX035izV\n\t1HPywOresBBGM7oUPl7pfYZ3Fq/Mne6oD+uHNJpmcDZvWN1JevXo03d+ecCD/DkIDr\n\tVinFfq6z4B1jh/cg6kKJJAQV3HqhO6e4eMpCV6LUAowQGV9UfFKkb3OdSfFulmkSml\n\t+qjy0VdQvLBcg==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1657842924;\n\tbh=bdVC5iNxkuS0IOFiimt3t0i66xXm8J/gkqWLCTvwKc8=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=E/OenhJqbQDxqL6ebMlrXLQkBnm0zU77YSyhfQV+TZphjM7sjwIS4rICkPOO6inIQ\n\tdxdttDbZo/y2FYwfUvWl3ako6mf3Y0x4KykFBQtDUTaqyGsAe57k9KuW5am2vkN40M\n\tHKucxlPbQfiPJFtVYiRCJ1xUucVSrJo4DKuyvt2M="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"E/OenhJq\"; dkim-atps=neutral","Date":"Fri, 15 Jul 2022 02:54:52 +0300","To":"Naushir Patuck <naush@raspberrypi.com>","Message-ID":"<YtCszE9W8yWMkKQG@pendragon.ideasonboard.com>","References":"<20220714152409.9780-1-naush@raspberrypi.com>\n\t<20220714152409.9780-8-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220714152409.9780-8-naush@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH v5 7/8] utils: raspberrypi: ctt:\n\tOutput version 2.0 format tuning files","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":23918,"web_url":"https://patchwork.libcamera.org/comment/23918/","msgid":"<CAEmqJPqa9E_u3bqojyoj0P+YsHm+Oxq2M66=6UM_TDZvDa3fRQ@mail.gmail.com>","date":"2022-07-15T08:39:29","subject":"Re: [libcamera-devel] [PATCH v5 7/8] utils: raspberrypi: ctt:\n\tOutput version 2.0 format tuning files","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"content":"Hi Laurent,\n\nThank you for your feedback.\n\nOn Fri, 15 Jul 2022 at 00:55, Laurent Pinchart <\nlaurent.pinchart@ideasonboard.com> wrote:\n\n> Hi Naush,\n>\n> Thank you for the patch.\n>\n> On Thu, Jul 14, 2022 at 04:24:08PM +0100, Naushir Patuck via\n> libcamera-devel wrote:\n> > Use the tuning file conversion script to output the new tuning file\n> format from\n> > the CTT.\n> >\n> > Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> > ---\n> >  utils/raspberrypi/ctt/ctt.py | 13 ++++++-------\n> >  1 file changed, 6 insertions(+), 7 deletions(-)\n> >\n> > diff --git a/utils/raspberrypi/ctt/ctt.py b/utils/raspberrypi/ctt/ctt.py\n> > index 15064634c67f..0d91ada15afa 100755\n> > --- a/utils/raspberrypi/ctt/ctt.py\n> > +++ b/utils/raspberrypi/ctt/ctt.py\n> > @@ -15,7 +15,7 @@ from ctt_alsc import *\n> >  from ctt_lux import *\n> >  from ctt_noise import *\n> >  from ctt_geq import *\n> > -from ctt_pretty_print_json import *\n>\n> ctt_pretty_print_json.py isn't used anymore, should it be dropped ?\n>\n> > +from convert_tuning import convert_v2\n> >  import random\n> >  import json\n> >  import re\n> > @@ -511,13 +511,12 @@ class Camera:\n> >      \"\"\"\n> >      def write_json(self):\n> >          \"\"\"\n> > -        Write json dictionary to file\n> > +        Write json dictionary to file using our version 2 format\n> >          \"\"\"\n> > -        jstring = json.dumps(self.json, sort_keys=False)\n> > -        \"\"\"\n> > -        make it pretty :)\n> > -        \"\"\"\n> > -        pretty_print_json(jstring, self.jf)\n> > +        out_json = convert_v2(self.json)\n>\n> That's cheating :-) I'm OK with it for now, Would it be difficult to\n> output the v2 format natively though ? It seems that something along the\n> lines of the following code should do:\n>\n>         out_json = {\n>             \"version\": \"2.0\",\n>             \"algorithms\": [{name: data} for name, data in\n> self.json.items()],\n>         }\n>\n> and then you could import the Encoder class from convert_tuning instead\n> of the convert_v2 function, and do\n>\n>         with open(self.jf, 'w') as f:\n>             f.write(json.dumps(out_json, cls=Encoder, indent=4,\n> sort_keys=False))\n>\n> Possibly even better, the Encoder class could be moved from\n> convert_tuning.py to ctt_pretty_print_json and replace the existing\n> hand-written JSONPrettyPrinter.\n>\n\nI think I would prefer the first suggestion and delete\nctt_pretty_print_json.py.\nIt pretty much does what convert_tuning.py does, so seems redundant.\n\nNaush\n\n\n\n>\n> > +\n> > +        with open(self.jf, 'w') as f:\n> > +            f.write(out_json)\n> >\n> >      \"\"\"\n> >      add a new section to the log file\n>\n> --\n> Regards,\n>\n> Laurent Pinchart\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id D6F20BD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 15 Jul 2022 08:39:47 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A4DE663312;\n\tFri, 15 Jul 2022 10:39:47 +0200 (CEST)","from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com\n\t[IPv6:2a00:1450:4864:20::22e])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id EC36E6330B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 15 Jul 2022 10:39:45 +0200 (CEST)","by mail-lj1-x22e.google.com with SMTP id x10so4495365ljj.11\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 15 Jul 2022 01:39:45 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1657874387;\n\tbh=Ki3HZeffs7sjQdd4visoZkvxxLCioaZ+qc67MeWEimY=;\n\th=References:In-Reply-To:Date:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=qPurbpHTOVPM2UHsl8532epTOrnyycGqzjw2KQdPy3z9bWVHPca1VbG6StZVVkENE\n\tr7rij1K/e3mvWUSgxlC+o342Cmfe5Fo6oz0jSwCWc/LNYsd4Li9kDHwxC8rdzbXNA7\n\tzoHQjwIvtkSDTmvuMZZTHKHhNhkp+h726JAXm3rLNqufJSh4Z1ssfjx4NSaqAvKcur\n\tJy9dW1UAoH6vn1i6wU/IL/LnyrciZmQOhrzFUmInUk7f2VDukmvHzVN9KhQ+9kfO1p\n\tkj7wig8qGSQ23y5N2JWD+FCReJdPNpxqG63gWKk/e/Z22Ujrd7uN5Ti3VKrJ/31uTt\n\tYiXkyw70T4Mwg==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=DTaN3Z2e0AtL8sGIshDMHTz9VKKERYpPnWjM/Nz+UNM=;\n\tb=h3Em7qB1n5qQDWwiqFqc6HDuO8eB6r0agpA6z4K9t+RMPEKD6DcchtBxLGlawnSJSw\n\ttY2Foz9f0CdskIA6pZSSgixInqEdxXxvfu/agIL54R13E0K6Bff61lVdMGVn8s7DGAPi\n\t+tmFEB6fVORuBY0o5VHQPovKSDw7KkzyZfleYmRSisY2jJAiTlF+aXhYO1WTAxRMDfSS\n\tuhIjhrt4lspP2LC0d+VGB19t3o+yWjcT4MlN552Gw7tyXolK4jiIbZO604c4HCHh3sTM\n\tYTfGSGsj+Q/rCI6EeIdsI/tEe5kIb9iqemQIT7CL2Srs/2zwhK5msd3czf9/i9p003T3\n\tC2GQ=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"h3Em7qB1\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=DTaN3Z2e0AtL8sGIshDMHTz9VKKERYpPnWjM/Nz+UNM=;\n\tb=72aOwb6Xesd2ihwwqzzz0WIoE0K6Gu+nqfnqKqd3rB1MnlvleXKlxestOeUBQ383MS\n\teBLkhUmS1gU9hARfvF75Pgnq2cUsDttIYZL2xwoERmQJiZQLrNZ++6JxiTz1eZTu+hOP\n\tkNewKolIOGn14Ie8XX08pWZm6Eex/ILQffkZNDQQEn0rSbYI5EEHuv8UDogPwMCETibz\n\tjdc1hzTLLJolXI5WtjScWhA05ErEWGkWdmI9qxgCCpjb4A0ZRioV/JqDYO7Fu7JwKOlu\n\tyZGuK1g6q8xPAvW+LEjL5ip3oGlFULVfqYadDWrLZ1N2QfxY2bfM/J82jtO5KGCcFpkr\n\tFh/w==","X-Gm-Message-State":"AJIora9DtC48q09NLF09wgeib1IzJeNE5eldj4mpMoqeyy6TvGisUuTv\n\tzRvIvY4mjVo6sL9Uqpi3aDlaauNHpDhSb1/9z74FDw==","X-Google-Smtp-Source":"AGRyM1vDm0F8f8rQjcbzmo+DjG47eP3AElnUgdeUsuSQT+mbkCT/Zk/5qlWzwslrFSvSqLqMPqYOKkTGeBrx0bJFCo8=","X-Received":"by 2002:a2e:b70b:0:b0:25d:52f3:3043 with SMTP id\n\tj11-20020a2eb70b000000b0025d52f33043mr6344411ljo.380.1657874385398;\n\tFri, 15 Jul 2022 01:39:45 -0700 (PDT)","MIME-Version":"1.0","References":"<20220714152409.9780-1-naush@raspberrypi.com>\n\t<20220714152409.9780-8-naush@raspberrypi.com>\n\t<YtCszE9W8yWMkKQG@pendragon.ideasonboard.com>","In-Reply-To":"<YtCszE9W8yWMkKQG@pendragon.ideasonboard.com>","Date":"Fri, 15 Jul 2022 09:39:29 +0100","Message-ID":"<CAEmqJPqa9E_u3bqojyoj0P+YsHm+Oxq2M66=6UM_TDZvDa3fRQ@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Content-Type":"multipart/alternative; boundary=\"000000000000d3025605e3d3f5ca\"","Subject":"Re: [libcamera-devel] [PATCH v5 7/8] utils: raspberrypi: ctt:\n\tOutput version 2.0 format tuning files","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Naushir Patuck <naush@raspberrypi.com>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":23919,"web_url":"https://patchwork.libcamera.org/comment/23919/","msgid":"<CAEmqJPqrNe540pDncYK+4NrwmhR0hJ93ZY1VUBUFqGT2CKH+qA@mail.gmail.com>","date":"2022-07-15T08:51:53","subject":"Re: [libcamera-devel] [PATCH v5 7/8] utils: raspberrypi: ctt:\n\tOutput version 2.0 format tuning files","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"content":"Hi Laurent,\n\nOn Fri, 15 Jul 2022 at 09:39, Naushir Patuck <naush@raspberrypi.com> wrote:\n\n> Hi Laurent,\n>\n> Thank you for your feedback.\n>\n> On Fri, 15 Jul 2022 at 00:55, Laurent Pinchart <\n> laurent.pinchart@ideasonboard.com> wrote:\n>\n>> Hi Naush,\n>>\n>> Thank you for the patch.\n>>\n>> On Thu, Jul 14, 2022 at 04:24:08PM +0100, Naushir Patuck via\n>> libcamera-devel wrote:\n>> > Use the tuning file conversion script to output the new tuning file\n>> format from\n>> > the CTT.\n>> >\n>> > Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n>> > ---\n>> >  utils/raspberrypi/ctt/ctt.py | 13 ++++++-------\n>> >  1 file changed, 6 insertions(+), 7 deletions(-)\n>> >\n>> > diff --git a/utils/raspberrypi/ctt/ctt.py b/utils/raspberrypi/ctt/ctt.py\n>> > index 15064634c67f..0d91ada15afa 100755\n>> > --- a/utils/raspberrypi/ctt/ctt.py\n>> > +++ b/utils/raspberrypi/ctt/ctt.py\n>> > @@ -15,7 +15,7 @@ from ctt_alsc import *\n>> >  from ctt_lux import *\n>> >  from ctt_noise import *\n>> >  from ctt_geq import *\n>> > -from ctt_pretty_print_json import *\n>>\n>> ctt_pretty_print_json.py isn't used anymore, should it be dropped ?\n>>\n>> > +from convert_tuning import convert_v2\n>> >  import random\n>> >  import json\n>> >  import re\n>> > @@ -511,13 +511,12 @@ class Camera:\n>> >      \"\"\"\n>> >      def write_json(self):\n>> >          \"\"\"\n>> > -        Write json dictionary to file\n>> > +        Write json dictionary to file using our version 2 format\n>> >          \"\"\"\n>> > -        jstring = json.dumps(self.json, sort_keys=False)\n>> > -        \"\"\"\n>> > -        make it pretty :)\n>> > -        \"\"\"\n>> > -        pretty_print_json(jstring, self.jf)\n>> > +        out_json = convert_v2(self.json)\n>>\n>> That's cheating :-) I'm OK with it for now, Would it be difficult to\n>> output the v2 format natively though ? It seems that something along the\n>> lines of the following code should do:\n>>\n>>         out_json = {\n>>             \"version\": \"2.0\",\n>>             \"algorithms\": [{name: data} for name, data in\n>> self.json.items()],\n>>         }\n>>\n>> and then you could import the Encoder class from convert_tuning instead\n>> of the convert_v2 function, and do\n>>\n>>         with open(self.jf, 'w') as f:\n>>             f.write(json.dumps(out_json, cls=Encoder, indent=4,\n>> sort_keys=False))\n>>\n>> Possibly even better, the Encoder class could be moved from\n>> convert_tuning.py to ctt_pretty_print_json and replace the existing\n>> hand-written JSONPrettyPrinter.\n>>\n>\n> I think I would prefer the first suggestion and delete\n> ctt_pretty_print_json.py.\n> It pretty much does what convert_tuning.py does, so seems redundant.\n>\n\nActually, looking at it further, perhaps I should move the entire\ncontents of convert_tuning.py\ninto ctt_pretty_print_json.py as the former does not only convert but also\nprettifies any\nflat json. What do you think?\n\n\n\n> Naush\n>\n>\n>\n>>\n>> > +\n>> > +        with open(self.jf, 'w') as f:\n>> > +            f.write(out_json)\n>> >\n>> >      \"\"\"\n>> >      add a new section to the log file\n>>\n>> --\n>> Regards,\n>>\n>> Laurent Pinchart\n>>\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id BAE70BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 15 Jul 2022 08:52:11 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3511C6330E;\n\tFri, 15 Jul 2022 10:52:11 +0200 (CEST)","from mail-lj1-x236.google.com (mail-lj1-x236.google.com\n\t[IPv6:2a00:1450:4864:20::236])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D28946330B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 15 Jul 2022 10:52:09 +0200 (CEST)","by mail-lj1-x236.google.com with SMTP id u14so5007327ljh.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 15 Jul 2022 01:52:09 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1657875131;\n\tbh=ab2AdL9mrRvKY6NGAOD+i2zPudvYlL4XPUHm/kP5zXI=;\n\th=References:In-Reply-To:Date:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=yNXcj2HwtgleYo//xx75RVwE+SBjVw9eA+NdS76Dbv9dX4KCdb7vVVPwpPmQdG9Sc\n\tA21i+9f988mLFIP7YLrnLBWOZVpyueX0aNH4IgXZpFcqnQ/6LDmD3niBckGv6j9Nq6\n\t+pmX6xX3CheUMZVwNVGFbkJ8Gc5k+eK8hr4EmO7r92oNS3QbSmt0FZkSicvII052Kr\n\to6pAC3QfGdUGoGlKzJcuqlniwx+Peoz0J57BVjga4diq76gJtGEt1XuCRguB0zh/3/\n\t/tFyICF5yYYLkHuWjZSMgdQ0YRSAxirkQCpu1475P56M5ei4MtCSGL9hqJDRUiimg8\n\tBFVCnJMntmoPg==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=sTG+py3a2CObquOhFGMvP66q5LjWiYXaPVH8+WZK2kk=;\n\tb=Vf1o6r7sEwXSrM7O2HxNwbTEDSfRoKsA/Ult+eFPJHBRHS5gUkurKFxgzsNDzmxzci\n\tiX0x1MjfGs3+bE1SN/KRS4gr77Q90V+AIbT1aq3GFURrmx4JiD4yTFXlKyBrFw7aieW8\n\t7f9M6+ZBpERXrWz8QEaoI5j/QFN0EifTXgrMn09ZDgHRT1n/y1J6LdebaeVZ5LmW/PMn\n\tVu9LMjPZf/r2k5q8iRjchaKbjUWNnSof3FdTWWQMiZ0oTkORJ+fs6FogSXvFfY0bu3Pd\n\tkdTNKwX5hRbNJ/+XW0Ru2N4Ut4h1qjv4FKBEkkWkfgQZl/lQk9bImlcK1s1YLoj2BGuj\n\tQySA=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"Vf1o6r7s\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=sTG+py3a2CObquOhFGMvP66q5LjWiYXaPVH8+WZK2kk=;\n\tb=xknsT7rFIunDTIH+QmZ5VdpkuUCDubLEtSiBATksW6KWQFowzW9CtMUFHF2XDgGXuM\n\tSHRg3Jc8B+NfyCo5n3bf6n3PiMhYtU6GjGmufsvnU1gcleGeD796Ecdqzr0HYW7DoxiP\n\throh1Ligz/33qdCMCKVfhNyJX5VLxCRbDV4AYySpOFhnW5XBSJjxt2qmz6MBv6n+DXCG\n\tOIo7fO8Lj8XN6YHc4Q/1zEreybBSQkqBcfjtxyKxu4ks0UisjSli0S2SebZkE220qkw5\n\t34pdx1JlI1e4vABw2/Mahhs+MPbndBxnZWBFCmNwJznrct7RYiWsh5ac7QqsY87Thl74\n\tPfPw==","X-Gm-Message-State":"AJIora/TDYAvFBH+e5fdslRjpx2vhoaJhR42/3JiAxLyMNrw9QZa8asU\n\tY9m8yY8oX8iChx6M28GhnejRcPtFOKccuX0ownnUJhSpTfHpxQ==","X-Google-Smtp-Source":"AGRyM1sGVxKBawEvdbNJWFTf0AdJqyq7vnI8vkGvYcYe8KcLDG68FDBAB8r8KOGP09fIcWnW0VReI19V/CGBJ7KCIP4=","X-Received":"by 2002:a05:651c:1a0a:b0:25d:a17d:9c23 with SMTP id\n\tby10-20020a05651c1a0a00b0025da17d9c23mr1540208ljb.480.1657875129220;\n\tFri, 15 Jul 2022 01:52:09 -0700 (PDT)","MIME-Version":"1.0","References":"<20220714152409.9780-1-naush@raspberrypi.com>\n\t<20220714152409.9780-8-naush@raspberrypi.com>\n\t<YtCszE9W8yWMkKQG@pendragon.ideasonboard.com>\n\t<CAEmqJPqa9E_u3bqojyoj0P+YsHm+Oxq2M66=6UM_TDZvDa3fRQ@mail.gmail.com>","In-Reply-To":"<CAEmqJPqa9E_u3bqojyoj0P+YsHm+Oxq2M66=6UM_TDZvDa3fRQ@mail.gmail.com>","Date":"Fri, 15 Jul 2022 09:51:53 +0100","Message-ID":"<CAEmqJPqrNe540pDncYK+4NrwmhR0hJ93ZY1VUBUFqGT2CKH+qA@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Content-Type":"multipart/alternative; boundary=\"00000000000028d6d105e3d4229c\"","Subject":"Re: [libcamera-devel] [PATCH v5 7/8] utils: raspberrypi: ctt:\n\tOutput version 2.0 format tuning files","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Naushir Patuck <naush@raspberrypi.com>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":23922,"web_url":"https://patchwork.libcamera.org/comment/23922/","msgid":"<YtEzz1kYt3lMaqUE@pendragon.ideasonboard.com>","date":"2022-07-15T09:30:55","subject":"Re: [libcamera-devel] [PATCH v5 7/8] utils: raspberrypi: ctt:\n\tOutput version 2.0 format tuning files","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Naush,\n\nOn Fri, Jul 15, 2022 at 09:51:53AM +0100, Naushir Patuck wrote:\n> On Fri, 15 Jul 2022 at 09:39, Naushir Patuck wrote:\n> > On Fri, 15 Jul 2022 at 00:55, Laurent Pinchart wrote:\n> >> On Thu, Jul 14, 2022 at 04:24:08PM +0100, Naushir Patuck via libcamera-devel wrote:\n> >> > Use the tuning file conversion script to output the new tuning file format from\n> >> > the CTT.\n> >> >\n> >> > Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> >> > ---\n> >> >  utils/raspberrypi/ctt/ctt.py | 13 ++++++-------\n> >> >  1 file changed, 6 insertions(+), 7 deletions(-)\n> >> >\n> >> > diff --git a/utils/raspberrypi/ctt/ctt.py b/utils/raspberrypi/ctt/ctt.py\n> >> > index 15064634c67f..0d91ada15afa 100755\n> >> > --- a/utils/raspberrypi/ctt/ctt.py\n> >> > +++ b/utils/raspberrypi/ctt/ctt.py\n> >> > @@ -15,7 +15,7 @@ from ctt_alsc import *\n> >> >  from ctt_lux import *\n> >> >  from ctt_noise import *\n> >> >  from ctt_geq import *\n> >> > -from ctt_pretty_print_json import *\n> >>\n> >> ctt_pretty_print_json.py isn't used anymore, should it be dropped ?\n> >>\n> >> > +from convert_tuning import convert_v2\n> >> >  import random\n> >> >  import json\n> >> >  import re\n> >> > @@ -511,13 +511,12 @@ class Camera:\n> >> >      \"\"\"\n> >> >      def write_json(self):\n> >> >          \"\"\"\n> >> > -        Write json dictionary to file\n> >> > +        Write json dictionary to file using our version 2 format\n> >> >          \"\"\"\n> >> > -        jstring = json.dumps(self.json, sort_keys=False)\n> >> > -        \"\"\"\n> >> > -        make it pretty :)\n> >> > -        \"\"\"\n> >> > -        pretty_print_json(jstring, self.jf)\n> >> > +        out_json = convert_v2(self.json)\n> >>\n> >> That's cheating :-) I'm OK with it for now, Would it be difficult to\n> >> output the v2 format natively though ? It seems that something along the\n> >> lines of the following code should do:\n> >>\n> >>         out_json = {\n> >>             \"version\": \"2.0\",\n> >>             \"algorithms\": [{name: data} for name, data in\n> >> self.json.items()],\n> >>         }\n> >>\n> >> and then you could import the Encoder class from convert_tuning instead\n> >> of the convert_v2 function, and do\n> >>\n> >>         with open(self.jf, 'w') as f:\n> >>             f.write(json.dumps(out_json, cls=Encoder, indent=4,\n> >> sort_keys=False))\n> >>\n> >> Possibly even better, the Encoder class could be moved from\n> >> convert_tuning.py to ctt_pretty_print_json and replace the existing\n> >> hand-written JSONPrettyPrinter.\n> >\n> > I think I would prefer the first suggestion and delete ctt_pretty_print_json.py.\n> > It pretty much does what convert_tuning.py does, so seems redundant.\n> \n> Actually, looking at it further, perhaps I should move the entire contents of convert_tuning.py\n> into ctt_pretty_print_json.py as the former does not only convert but also prettifies any\n> flat json. What do you think?\n\nHmmmm... I think it would be nice to keep v1-related code centralized in\na single place (or in as few places as possible). I would thus prefer\nmoving only the Encoder class to ctt_pretty_print_json.py, and have\nconvert_tuning.py be a small wrapper around it that converts to the\nlatest version of tuning files. ctt_pretty_print_json.py can also be\ninvoked directly, I would use that as a pretty printer/reformatter\ninstead of advertising convert_tuning.py as a formatting tool.\n\n> >> > +\n> >> > +        with open(self.jf, 'w') as f:\n> >> > +            f.write(out_json)\n> >> >\n> >> >      \"\"\"\n> >> >      add a new section to the log file","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 35444BD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 15 Jul 2022 09:31:29 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 620D763312;\n\tFri, 15 Jul 2022 11:31:28 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DE8506330B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 15 Jul 2022 11:31:26 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 6A595993;\n\tFri, 15 Jul 2022 11:31:26 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1657877488;\n\tbh=0/Lded5UKsBY0l/yl4cHBsrdNoGSvA64MCjxDlT4xdU=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=TRPd8B2SD+SfOQTSh74j3TqnbeVuklvZ8KdXFyFtAC49797YHgMzf/6asWmhBixIN\n\tpN0wcGt85TI9wLWVsdUJTxJ23ZfxJNPJv6WFU/ZeRZpe4HcJPjl7aL26gIcm5E2hIL\n\tgfE7AyU9zehPscUadDHSl61DQdgoBRmUIodGR83GjKPttf4go0ym1+vfwF+lu0KBqn\n\thlmkg+t68l6MuKlaibXZp0ZKSDqX8SKb814o0Y+7up+ulRU6GofdgE1je3JtK61uLK\n\t7Qzs0tw4p8xwsT/QY3ta7nSutx1x25Cys2MKAPQ3uhi6P7+G4Ui/VCKhp8ePHgggBf\n\tvOWG48lWlHKIg==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1657877486;\n\tbh=0/Lded5UKsBY0l/yl4cHBsrdNoGSvA64MCjxDlT4xdU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=cVCNZ095BRUopXoMMMD07agHBjvZ5f/989ArtMR2QHIv6s5ehv+qDC4hrgGH37BZR\n\tuCbxzWbx4T3g2ieTCfrSE2gYdq6PHrXXXCisWDVcySQps1i0kA5aIwqwNMKRvWA3dC\n\tIFx0eQ6FPHiGXvBonbzsNWpUdolfIuNie8vrhcEw="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"cVCNZ095\"; dkim-atps=neutral","Date":"Fri, 15 Jul 2022 12:30:55 +0300","To":"Naushir Patuck <naush@raspberrypi.com>","Message-ID":"<YtEzz1kYt3lMaqUE@pendragon.ideasonboard.com>","References":"<20220714152409.9780-1-naush@raspberrypi.com>\n\t<20220714152409.9780-8-naush@raspberrypi.com>\n\t<YtCszE9W8yWMkKQG@pendragon.ideasonboard.com>\n\t<CAEmqJPqa9E_u3bqojyoj0P+YsHm+Oxq2M66=6UM_TDZvDa3fRQ@mail.gmail.com>\n\t<CAEmqJPqrNe540pDncYK+4NrwmhR0hJ93ZY1VUBUFqGT2CKH+qA@mail.gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<CAEmqJPqrNe540pDncYK+4NrwmhR0hJ93ZY1VUBUFqGT2CKH+qA@mail.gmail.com>","Subject":"Re: [libcamera-devel] [PATCH v5 7/8] utils: raspberrypi: ctt:\n\tOutput version 2.0 format tuning files","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]