Repository: huggingface/transformers
Pull request: Less verbose library helpers

# What does this PR do?

As per the title. All those prints does not give any useful informations and create noise
Let's print only important informations, i.e. a file has been changed, but let's not print if everything is good

Changed files:
filename: setup.py
patch: @@ -219,7 +219,6 @@ def run(self):
             "",
         ]
         target = "src/transformers/dependency_versions_table.py"
-        print(f"updating {target}")
         with open(target, "w", encoding="utf-8", newline="\n") as f:
             f.write("\n".join(content))
 

filename: utils/add_dates.py
patch: @@ -343,12 +343,10 @@ def main(all=False, models=None, check_only=False):
     if check_only:
         # Check all model cards for missing dates
         all_model_cards = get_all_model_cards()
-        print(f"Checking all {len(all_model_cards)} model cards for missing dates...")
         missing_dates = check_missing_dates(all_model_cards)
 
         # Check modified model cards for incorrect dates
         modified_cards = get_modified_cards()
-        print(f"Checking {len(modified_cards)} modified model cards for incorrect dates...")
         incorrect_dates = check_incorrect_dates(modified_cards)
 
         if missing_dates or incorrect_dates:
@@ -358,22 +356,17 @@ def main(all=False, models=None, check_only=False):
                 f"Missing or incorrect dates in the following model cards: {' '.join(problematic_cards)}\n"
                 f"Run `python utils/add_dates.py --models {' '.join(model_names)}` to fix them."
             )
-        print("All dates are present and correct!")
         return
 
     # Determine which model cards to process
     if all:
         model_cards = get_all_model_cards()
-        print(f"Processing all {len(model_cards)} model cards from docs directory")
     elif models:
         model_cards = models
-        print(f"Processing specified model cards: {model_cards}")
     else:
         model_cards = get_modified_cards()
         if not model_cards:
-            print("No modified model cards found.")
             return
-        print(f"Processing modified model cards: {model_cards}")
 
     insert_dates(model_cards)
 

filename: utils/check_docstrings.py
patch: @@ -1012,8 +1012,6 @@ def find_matching_model_files(check_all: bool = False):
         # intersect with module_diff_files
         matching_files = sorted([file for file in matching_files if file in module_diff_files])
 
-    print("    Checking auto_docstrings in the following files:" + "\n    - " + "\n    - ".join(matching_files))
-
     return matching_files
 
 
@@ -1942,7 +1940,6 @@ def check_docstrings(overwrite: bool = False, check_all: bool = False):
         # quick escape route: if there are no module files in the diff, skip this check
         if len(module_diff_files) == 0:
             return
-        print("    Checking docstrings in the following files:" + "\n    - " + "\n    - ".join(module_diff_files))
 
     failures = []
     hard_failures = []

filename: utils/check_modular_conversion.py
patch: @@ -50,15 +50,15 @@ def process_file(
         # we always save the generated content, to be able to update dependant files
         with open(file_path, "w", encoding="utf-8", newline="\n") as modeling_file:
             modeling_file.write(generated_modeling_content[file_type])
-        console.print(f"[bold blue]Overwritten {file_path} with the generated content.[/bold blue]")
+        if not show_diff:
+            console.print(f"[bold blue]Overwritten {file_path} with the generated content.[/bold blue]")
         if show_diff:
             console.print(f"\n[bold red]Differences found between the generated code and {file_path}:[/bold red]\n")
             diff_text = "\n".join(diff_list)
             syntax = Syntax(diff_text, "diff", theme="ansi_dark", line_numbers=True)
             console.print(syntax)
         return 1
     else:
-        console.print(f"[bold green]No differences found for {file_path}.[/bold green]")
         return 0
 
 
@@ -181,12 +181,8 @@ def guaranteed_no_diff(modular_file_path, dependencies, models_in_diff):
     else:
         models_in_diff = get_models_in_diff()
         if not models_in_diff and not args.check_all:
-            console.print(
-                "[bold green]No models files or model tests in the diff, skipping modular checks[/bold green]"
-            )
             exit(0)
 
-    skipped_models = set()
     non_matching_files = []
     ordered_files, dependencies = find_priority_list(args.files)
     flat_ordered_files = [item for sublist in ordered_files for item in sublist]
@@ -198,18 +194,12 @@ def guaranteed_no_diff(modular_file_path, dependencies, models_in_diff):
     #  - ... and so on
     # files (models) within the same list are *independent* of each other;
     # we start applying modular conversion to each list in parallel, starting from the first list
-
-    console.print(f"[bold yellow]Number of dependency levels: {len(ordered_files)}[/bold yellow]")
-    console.print(f"[bold yellow]Files per level: {tuple(len(x) for x in ordered_files)}[/bold yellow]")
-
     try:
         for dependency_level_files in ordered_files:
             # Filter files guaranteed no diff
             files_to_check = []
             for file_path in dependency_level_files:
-                if not args.check_all and guaranteed_no_diff(file_path, dependencies, models_in_diff):
-                    skipped_models.add(file_path.split("/")[-2])  # save model folder name
-                else:
+                if args.check_all or not guaranteed_no_diff(file_path, dependencies, models_in_diff):
                     files_to_check.append(file_path)
 
             if not files_to_check:
@@ -260,9 +250,3 @@ def guaranteed_no_diff(modular_file_path, dependencies, models_in_diff):
         diff_models = set(file_path.split("/")[-2] for file_path in non_matching_files)  # noqa
         models_str = "\n - " + "\n - ".join(sorted(diff_models))
         raise ValueError(f"Some diff and their modeling code did not match. Models in diff:{models_str}")
-
-    if skipped_models:
-        console.print(
-            f"[bold green]Skipped {len(skipped_models)} models and their dependencies that are not in the diff: "
-            f"{', '.join(sorted(skipped_models))}[/bold green]"
-        )