DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Juraj Linkeš" <juraj.linkes@pantheon.tech>
To: Luca Vizzarro <luca.vizzarro@arm.com>, dev@dpdk.org
Cc: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>,
	Paul Szczepanek <paul.szczepanek@arm.com>
Subject: Re: [PATCH 5/5] dts: add JSON schema generation script
Date: Tue, 17 Sep 2024 13:59:29 +0200	[thread overview]
Message-ID: <fcd5862d-8183-4da5-90f5-a03323ac7b80@pantheon.tech> (raw)
In-Reply-To: <20240822163941.1390326-6-luca.vizzarro@arm.com>


>   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.


      reply	other threads:[~2024-09-17 11:59 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-22 16:39 [PATCH 0/5] dts: Pydantic configuration Luca Vizzarro
2024-08-22 16:39 ` [PATCH 1/5] dts: add TestSuiteSpec class and discovery Luca Vizzarro
2024-09-16 13:00   ` Juraj Linkeš
2024-08-22 16:39 ` [PATCH 2/5] dts: add Pydantic and remove Warlock Luca Vizzarro
2024-09-16 13:17   ` Juraj Linkeš
2024-08-22 16:39 ` [PATCH 3/5] dts: use Pydantic in the configuration Luca Vizzarro
2024-09-17 11:13   ` Juraj Linkeš
2024-08-22 16:39 ` [PATCH 4/5] dts: use TestSuiteSpec class imports Luca Vizzarro
2024-09-17 11:39   ` Juraj Linkeš
2024-08-22 16:39 ` [PATCH 5/5] dts: add JSON schema generation script Luca Vizzarro
2024-09-17 11:59   ` Juraj Linkeš [this message]

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=fcd5862d-8183-4da5-90f5-a03323ac7b80@pantheon.tech \
    --to=juraj.linkes@pantheon.tech \
    --cc=dev@dpdk.org \
    --cc=honnappa.nagarahalli@arm.com \
    --cc=luca.vizzarro@arm.com \
    --cc=paul.szczepanek@arm.com \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).