PY-54
Validate a Configuration Record
Task
Define the RunConfig record below and write validate_configs(configs):
Return (valid, rejected). valid contains the original configuration objects
that pass. rejected contains (index, name, reason) tuples. Apply only the
first failing rule to each item, in this order:
- a name already seen earlier:
"duplicate name"; - an empty
input_path:"empty input path"; - an unsafe
output_name:"unsafe output name"; batch_sizeis not a positive integer:"invalid batch size";shuffleis true whileseedisNone:"shuffle requires seed".
An output name is safe only when it is non-empty and every character is a
letter, digit, hyphen, or underscore. A boolean is not a valid batch size even
though Python treats bool as a kind of integer. A rejected name still counts
as seen when a later item repeats it.
Example
The first item is valid. The second becomes (1, "base", "duplicate name").
Your implementation
Edit solution.py, keep the record definition above, and keep this function
signature:
Do not change a configuration or the input list, print, or ask for input.