Check every file is copy-consistent with the original. Also check the model list in the main README and other READMEs are consistent. Args: overwrite (`bool`, *optional*, defaults to `False`): Whether or not to overwrite the copies when they don't match. fil
(overwrite: bool = False, file: str | None = None)
| 840 | |
| 841 | |
| 842 | def check_copies(overwrite: bool = False, file: str | None = None): |
| 843 | """ |
| 844 | Check every file is copy-consistent with the original. Also check the model list in the main README and other |
| 845 | READMEs are consistent. |
| 846 | |
| 847 | Args: |
| 848 | overwrite (`bool`, *optional*, defaults to `False`): |
| 849 | Whether or not to overwrite the copies when they don't match. |
| 850 | file (`bool`, *optional*): |
| 851 | The path to a specific file to check and/or fix. |
| 852 | """ |
| 853 | buffer = {} |
| 854 | |
| 855 | if file is None: |
| 856 | all_files = glob.glob(os.path.join(TRANSFORMERS_PATH, "**/*.py"), recursive=True) |
| 857 | all_test_files = glob.glob(os.path.join(MODEL_TEST_PATH, "**/*.py"), recursive=True) |
| 858 | all_files = list(all_files) + list(all_test_files) |
| 859 | else: |
| 860 | all_files = [file] |
| 861 | |
| 862 | diffs = [] |
| 863 | for filename in all_files: |
| 864 | new_diffs = is_copy_consistent(filename, overwrite, buffer) |
| 865 | diffs += [f"- {filename}: copy does not match {d[0]} at line {d[1]}" for d in new_diffs] |
| 866 | if not overwrite and len(diffs) > 0: |
| 867 | diff = "\n".join(diffs) |
| 868 | raise Exception( |
| 869 | "Found the following copy inconsistencies:\n" |
| 870 | + diff |
| 871 | + "\nRun `make fix-repo` or `python utils/check_copies.py --fix_and_overwrite` to fix them." |
| 872 | ) |
| 873 | |
| 874 | |
| 875 | def get_model_list(filename: str, start_prompt: str, end_prompt: str) -> str: |
no test coverage detected