DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Juraj Linkeš" <juraj.linkes@pantheon.tech>
To: Jeremy Spewock <jspewock@iol.unh.edu>,
	Nicholas Pratte <npratte@iol.unh.edu>
Cc: luca.vizzarro@arm.com, 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: Tue, 10 Sep 2024 10:57:49 +0200	[thread overview]
Message-ID: <b576997b-eea5-4424-bfdb-885d325e0fab@pantheon.tech> (raw)
In-Reply-To: <CAAA20UQ=hFEoPFRxXobQeBV2KRX9RUgBZwT=4C6474ZYCvJX9g@mail.gmail.com>



On 14. 6. 2024 20:32, Jeremy Spewock wrote:
> 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.
> 

Since we're splitting the file, we can also split the schema. I like 
splitting the schema since it'll be much clearer which files the schemas 
describe (if we have everything in one schema, we have to carefully look 
for which parts describe which file). It's also going to be easier to 
maintain.

  reply	other threads:[~2024-09-10  8:57 UTC|newest]

Thread overview: 9+ 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
2024-09-10  8:57     ` Juraj Linkeš [this message]
2024-06-14 18:27 ` Jeremy Spewock
2024-09-10  9:00   ` Juraj Linkeš
2024-07-03 14:57 ` [PATCH v2] " Nicholas Pratte
2024-07-16 14:11   ` Jeremy Spewock
2024-09-10  9:19   ` Juraj Linkeš

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=b576997b-eea5-4424-bfdb-885d325e0fab@pantheon.tech \
    --to=juraj.linkes@pantheon.tech \
    --cc=Honnappa.Nagarahalli@arm.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=jspewock@iol.unh.edu \
    --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).