Commit 38d2d21
committed
fix(dataset): raise a clear error when custom dataset_info is not a list
register_dataset_info loads the --custom_dataset_info JSON and then does
`for d_info in dataset_info: _register_d_info(d_info)`. When a user writes a
single entry as a top-level object `{...}` instead of the documented one-element
list `[{...}]`, `for d_info in dataset_info` iterates the dict keys (strings),
and _preprocess_d_info then does `d_info['preprocess_func'] = ...` on a str,
raising a cryptic `TypeError: 'str' object does not support item assignment`.
The built-in dataset_info.json is a list and the docs state it "is a list of
metadata for datasets", so a non-list is a user mistake that deserves a clear
message.
Validate the loaded dataset_info is a list and raise a helpful ValueError
otherwise. Valid list inputs are unaffected.1 parent 225b1a0 commit 38d2d21
2 files changed
Lines changed: 25 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
106 | 110 | | |
107 | 111 | | |
108 | 112 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
82 | 103 | | |
83 | 104 | | |
84 | 105 | | |
| |||
0 commit comments