DPDK patches and discussions
 help / color / mirror / Atom feed
From: Nicholas Pratte <npratte@iol.unh.edu>
To: luca.vizzarro@arm.com, juraj.linkes@pantheon.tech,
	probb@iol.unh.edu,  jspewock@iol.unh.edu,
	bruce.richardson@intel.com, yoan.picchi@foss.arm.com,
	 paul.szczepanek@arm.com, Honnappa.Nagarahalli@arm.com
Cc: dev@dpdk.org
Subject: Re: [PATCH v1] dts: Testbed And Node Configuration Split
Date: Mon, 10 Jun 2024 15:37:18 -0400	[thread overview]
Message-ID: <CAKXZ7eijgDbH8nvW1iv4m4wPKPiAOA_KY2HgsGJ5O=V8FKwT8w@mail.gmail.com> (raw)
In-Reply-To: <20240610193410.17968-2-npratte@iol.unh.edu>

<snip>

> -def load_config(config_file_path: Path) -> Configuration:
> +def load_config(node_config_file_path: Path, exec_config_file_path: Path) -> Configuration:
>      """Load DTS test run configuration from a file.
>
> -    Load the YAML test run configuration file
> +    Load both the YAML testbed and execution configuration files
>      and :download:`the configuration file schema <conf_yaml_schema.json>`,
> -    validate the test run configuration file, and create a test run configuration object.
> +    validate both configuration files to create a test run configuration object.
>
>      The YAML test run configuration file is specified in the :option:`--config-file` command line
>      argument or the :envvar:`DTS_CFG_FILE` environment variable.
>
>      Args:
> -        config_file_path: The path to the YAML test run configuration file.
> +        node_config_file_path: The path to the testbed configuration YAML file.
> +        exec_config_file_path: The path to the execution configuration YAML file.
>
>      Returns:
>          The parsed test run configuration.
>      """
> -    with open(config_file_path, "r") as f:
> -        config_data = yaml.safe_load(f)
> +    with open(node_config_file_path, "r") as f:
> +        node_config_data = yaml.safe_load(f)
> +    with open(exec_config_file_path, "r") as f:
> +        execution_config_data = yaml.safe_load(f)
>
>      schema_path = os.path.join(Path(__file__).parent.resolve(), "conf_yaml_schema.json")
>
>      with open(schema_path, "r") as f:
>          schema = json.load(f)
> -    config = warlock.model_factory(schema, name="_Config")(config_data)
> -    config_obj: Configuration = Configuration.from_dict(dict(config))  # type: ignore[arg-type]
> +    config = {
> +        **dict(warlock.model_factory(schema, name="_Config")(node_config_data)),
> +        **dict(warlock.model_factory(schema, name="_Config")(execution_config_data)),
> +    }
> +    if "nodes" not in config or "executions" not in config:
> +        raise ConfigurationError(
> +            f"{'node' if 'nodes' not in config else 'execution'} data not configured."
> +        )
> +    config_obj: Configuration = Configuration.from_dict(config)  # type: ignore[arg-type]
>      return config_obj

There is an alternative approach to this that I currently have
implemented on a separate local branch. Essentially, both configs are
merged together before being validated by the schema, effectively
removing the need to change the schema at all as well as the above
assertion that both nodes and executions are in the two config files.
However, using this alternative method might mean that there is no added
control that prevents users from making funky errors when creating
both config files. I could also just be overthinking or missing
something.

<snip>

  reply	other threads:[~2024-06-10 19:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-10 19:34 Nicholas Pratte
2024-06-10 19:37 ` Nicholas Pratte [this message]
2024-06-14 18:32   ` Jeremy Spewock
2024-06-14 18:27 ` Jeremy Spewock

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='CAKXZ7eijgDbH8nvW1iv4m4wPKPiAOA_KY2HgsGJ5O=V8FKwT8w@mail.gmail.com' \
    --to=npratte@iol.unh.edu \
    --cc=Honnappa.Nagarahalli@arm.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=jspewock@iol.unh.edu \
    --cc=juraj.linkes@pantheon.tech \
    --cc=luca.vizzarro@arm.com \
    --cc=paul.szczepanek@arm.com \
    --cc=probb@iol.unh.edu \
    --cc=yoan.picchi@foss.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).