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

On Mon, Jun 10, 2024 at 3:37 PM Nicholas Pratte <npratte@iol.unh.edu> wrote:
>
> <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.

That's an interesting idea and on one hand it makes the schema a
little less confusing because it wouldn't need to say "oneOf" when
both of the attributes are actually required for DTS to run, but on
the other it removes the ability for developers to know if they made a
mistake without actually running DTS. Making it a runtime error
wouldn't be the worst thing since it would at least be very early in
the run that the error is shown, but it loses some of its purpose I
feel if your IDE doesn't also show you some of the errors before
actually using the config. I could go either way on it personally.

>
> <snip>

  reply	other threads:[~2024-06-14 18:32 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
2024-06-14 18:32   ` Jeremy Spewock [this message]
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='CAAA20UQ=hFEoPFRxXobQeBV2KRX9RUgBZwT=4C6474ZYCvJX9g@mail.gmail.com' \
    --to=jspewock@iol.unh.edu \
    --cc=Honnappa.Nagarahalli@arm.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=juraj.linkes@pantheon.tech \
    --cc=luca.vizzarro@arm.com \
    --cc=npratte@iol.unh.edu \
    --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).