From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 37C81459BD; Tue, 17 Sep 2024 13:59:33 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 08E77402CB; Tue, 17 Sep 2024 13:59:33 +0200 (CEST) Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) by mails.dpdk.org (Postfix) with ESMTP id AD6E5402CB for ; Tue, 17 Sep 2024 13:59:30 +0200 (CEST) Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2f75e5f3debso36676241fa.1 for ; Tue, 17 Sep 2024 04:59:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pantheon.tech; s=google; t=1726574370; x=1727179170; darn=dpdk.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=U/vEgRcGEaKmOnSC1EgdpIp8pRWBCl1Kzj3Vs5OMdzQ=; b=cKknL/L2wy3WML0gqmrmB5evlhi011thRh7YP1ZijRIBVQnbiGGgBf5P4mTX0vPhda EihlYOT5LvVG/fb6MrX79aoW/W/5aABxjjLF4z92Lm2hEDY8NWA9CHuAhawt3GruIeI+ WPZHPp3AOOGjE9UPXitH2VK/USNvDVc6e73sHUsinCbBiwVWO/nfSC+5F6VxAedUdxOr vIH6bUMvrdU9Avz69ifEoCQ7C8YmZuHGRv/3kaKZJS2P6NWHkf/0PfKuWppa3WGt2FrT FmYNhtZRNPNYJ0E0VOrZ2OgF4DeCpLRV4brvUui4VKCP3m1uGtwfDAD8JHwRk7MgVDcJ 1zBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726574370; x=1727179170; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=U/vEgRcGEaKmOnSC1EgdpIp8pRWBCl1Kzj3Vs5OMdzQ=; b=KHpsW+4EFDftyD8+WSn6Ej/SZAYod8aacxjIVGdrM7mfuXEq98P/BQ6CJ/oJ5HJwOa 7gvqmTA045xHhWY7EmDZqdyV44bNTi50BPFwMMp+undF2mBcewjDz7nLl9DE7SmdJe/B EObaigF7GzmgqA8/tGqJ68EVWwBkcu2Xltuj8TgKJSrDMtrrjIUnQg4aVT2eQsNVc12l gYQcfIL1EQwoNk0xAjyCFvp3SJxtFKSRmOugHfNMakzOCaqc7Qey8Alec41+/f1yNPcg 3xvYK2YB4LOS9UeRE9LSpJRigCSDWQEgXuQYJjT92tFkMCIJJlWpCLnnWq6+hE/FNHbW lYUA== X-Forwarded-Encrypted: i=1; AJvYcCUqwI0KzW/QM942xApKQKLTLrk7xRrSiJ6cPMmUnfUXi/4QUErNzc3UxqQQjAGsN/uUrxU=@dpdk.org X-Gm-Message-State: AOJu0YxD/n2+k3TgU51bSsJkx7WhqYm1LWapOOnlaHLn5AkyixDwFxTT IxJ7DbNIb27UOMN/pXCV7581sGHzxIXggFx5UFVLNf2m7h9naKcr0Mfnv5nzTyk= X-Google-Smtp-Source: AGHT+IEULs++k5RNpKj2B40IEglKtiBRQWBN2TzNkod6UNyWrN8kYDhyRZbSP0dIURIRVuE+XfpNYA== X-Received: by 2002:ac2:4bc4:0:b0:52e:a63d:e5c1 with SMTP id 2adb3069b0e04-5367fee52a2mr7083657e87.30.1726574369931; Tue, 17 Sep 2024 04:59:29 -0700 (PDT) Received: from [10.12.0.236] (81.89.53.154.host.vnet.sk. [81.89.53.154]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a90610f427dsm440743366b.54.2024.09.17.04.59.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 17 Sep 2024 04:59:29 -0700 (PDT) Message-ID: Date: Tue, 17 Sep 2024 13:59:29 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 5/5] dts: add JSON schema generation script To: Luca Vizzarro , dev@dpdk.org Cc: Honnappa Nagarahalli , Paul Szczepanek References: <20240822163941.1390326-1-luca.vizzarro@arm.com> <20240822163941.1390326-6-luca.vizzarro@arm.com> Content-Language: en-US From: =?UTF-8?Q?Juraj_Linke=C5=A1?= In-Reply-To: <20240822163941.1390326-6-luca.vizzarro@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org > create mode 100755 dts/generate-schema.py Could it be worth putting this into devtools? It is a devtool. > > diff --git a/doc/guides/tools/dts.rst b/doc/guides/tools/dts.rst > @@ -430,6 +430,16 @@ Refer to the script for usage: ``devtools/dts-check-format.sh -h``. > Configuration Schema > -------------------- > > +The configuration schema is automatically generated from Pydantic models and can be found > +at ``dts/framework/config/conf_yaml_schema.json``. Whenever the models are changed, the schema > +should be regenerated using the dedicated script at ``dts/generate-schema.py``, e.g.: Should we add this to devtools/dts-check-format.sh? Looks like a good candidate. > + > +.. code-block:: console > + > + $ poetry shell > + (dts-py3.10) $ ./generate-schema.py > + > + > Definitions > ~~~~~~~~~~~ The definition names have changed and maybe there are also some other changes or does that not matter? Can these Pydantic changes help us with generating this schema description as well? > diff --git a/dts/generate-schema.py b/dts/generate-schema.py > @@ -0,0 +1,38 @@ > +#!/usr/bin/env python3 > +# SPDX-License-Identifier: BSD-3-Clause > +# Copyright(c) 2024 Arm Limited > + > +"""JSON schema generation script.""" This should at least say how to run the script, but we probably want to add more, such as from what it's creating the schema and where it's going to put it. > +from framework.config import ConfigurationType > + Ah, so it is used elsewhere. Let's just rename it then. > +DTS_DIR = os.path.dirname(os.path.realpath(__file__)) > +RELATIVE_PATH_TO_SCHEMA = "framework/config/conf_yaml_schema.json" We're using pathlib everywhere in DTS, so let's use it here as well. Not sure if the portability is needed in this script, but why not. > +class GenerateSchemaWithDialect(GenerateJsonSchema): > + """Custom schema generator which adds the schema dialect.""" I'd add that we're adding a reference to the schema dialect. > + print("Schema generated successfully!") > +except Exception as e: > + raise Exception("failed to generate schema") from e Let's unify the message with the print above by capitalizing and adding a dot to the end.