Check all inits in the transformers repo and raise an error if at least one does not define the same objects in both halves.
()
| 220 | |
| 221 | |
| 222 | def check_all_inits(): |
| 223 | """ |
| 224 | Check all inits in the transformers repo and raise an error if at least one does not define the same objects in |
| 225 | both halves. |
| 226 | """ |
| 227 | failures = [] |
| 228 | for root, _, files in os.walk(PATH_TO_TRANSFORMERS): |
| 229 | if "__init__.py" in files: |
| 230 | fname = os.path.join(root, "__init__.py") |
| 231 | objects = parse_init(fname) |
| 232 | if objects is not None: |
| 233 | errors = analyze_results(*objects) |
| 234 | if len(errors) > 0: |
| 235 | errors[0] = f"Problem in {fname}, both halves do not define the same objects.\n{errors[0]}" |
| 236 | failures.append("\n".join(errors)) |
| 237 | if len(failures) > 0: |
| 238 | raise ValueError("\n\n".join(failures)) |
| 239 | |
| 240 | |
| 241 | def get_transformers_submodules(): |
no test coverage detected