mirror of
https://github.com/huggingface/transformers.git
synced 2025-07-02 12:20:05 +06:00
Allow make-fixup on main branch, albeit slowly (#38892)
* Allow make-fixup on main branch, albeit slowly * Make the other style checks work correctly on main too * More update * More makefile update
This commit is contained in:
parent
9a02e7602d
commit
89b35be618
18
Makefile
18
Makefile
@ -8,13 +8,19 @@ check_dirs := examples tests src utils
|
|||||||
exclude_folders := ""
|
exclude_folders := ""
|
||||||
|
|
||||||
modified_only_fixup:
|
modified_only_fixup:
|
||||||
$(eval modified_py_files := $(shell python utils/get_modified_files.py $(check_dirs)))
|
@current_branch=$$(git branch --show-current); \
|
||||||
@if test -n "$(modified_py_files)"; then \
|
if [ "$$current_branch" = "main" ]; then \
|
||||||
echo "Checking/fixing $(modified_py_files)"; \
|
echo "On main branch, running 'style' target instead..."; \
|
||||||
ruff check $(modified_py_files) --fix --exclude $(exclude_folders); \
|
$(MAKE) style; \
|
||||||
ruff format $(modified_py_files) --exclude $(exclude_folders);\
|
|
||||||
else \
|
else \
|
||||||
echo "No library .py files were modified"; \
|
modified_py_files=$$(python utils/get_modified_files.py $(check_dirs)); \
|
||||||
|
if [ -n "$$modified_py_files" ]; then \
|
||||||
|
echo "Checking/fixing files: $${modified_py_files}"; \
|
||||||
|
ruff check $${modified_py_files} --fix --exclude $(exclude_folders); \
|
||||||
|
ruff format $${modified_py_files} --exclude $(exclude_folders); \
|
||||||
|
else \
|
||||||
|
echo "No library .py files were modified"; \
|
||||||
|
fi; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Update src/transformers/dependency_versions_table.py
|
# Update src/transformers/dependency_versions_table.py
|
||||||
|
@ -133,10 +133,19 @@ if __name__ == "__main__":
|
|||||||
# Assuming there is a topological sort on the dependency mapping: if the file being checked and its dependencies
|
# Assuming there is a topological sort on the dependency mapping: if the file being checked and its dependencies
|
||||||
# are not in the diff, then there it is guaranteed to have no differences. If no models are in the diff, then this
|
# are not in the diff, then there it is guaranteed to have no differences. If no models are in the diff, then this
|
||||||
# script will do nothing.
|
# script will do nothing.
|
||||||
models_in_diff = get_models_in_diff()
|
current_branch = subprocess.check_output(["git", "branch", "--show-current"], text=True).strip()
|
||||||
if not models_in_diff:
|
if current_branch == "main":
|
||||||
console.print("[bold green]No models files or model tests in the diff, skipping modular checks[/bold green]")
|
console.print(
|
||||||
exit(0)
|
"[bold red]You are developing on the main branch. We cannot identify the list of changed files and will have to check all files. This may take a while.[/bold red]"
|
||||||
|
)
|
||||||
|
models_in_diff = {file_path.split("/")[-2] for file_path in args.files}
|
||||||
|
else:
|
||||||
|
models_in_diff = get_models_in_diff()
|
||||||
|
if not models_in_diff:
|
||||||
|
console.print(
|
||||||
|
"[bold green]No models files or model tests in the diff, skipping modular checks[/bold green]"
|
||||||
|
)
|
||||||
|
exit(0)
|
||||||
|
|
||||||
skipped_models = set()
|
skipped_models = set()
|
||||||
non_matching_files = 0
|
non_matching_files = 0
|
||||||
@ -149,7 +158,8 @@ if __name__ == "__main__":
|
|||||||
skipped_models.add(model_name)
|
skipped_models.add(model_name)
|
||||||
continue
|
continue
|
||||||
non_matching_files += compare_files(modular_file_path, args.fix_and_overwrite)
|
non_matching_files += compare_files(modular_file_path, args.fix_and_overwrite)
|
||||||
models_in_diff = get_models_in_diff() # When overwriting, the diff changes
|
if current_branch != "main":
|
||||||
|
models_in_diff = get_models_in_diff() # When overwriting, the diff changes
|
||||||
else:
|
else:
|
||||||
new_ordered_files = []
|
new_ordered_files = []
|
||||||
for modular_file_path in ordered_files:
|
for modular_file_path in ordered_files:
|
||||||
|
Loading…
Reference in New Issue
Block a user