Skip to content

Commit 6cc4707

Browse files
committed
update
1 parent 1150cb0 commit 6cc4707

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

benchmarks/run_all.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
import glob
2+
import logging as std_logging
23
import os
34
import subprocess
45

56
import pandas as pd
67

8+
from diffusers.utils import logging
9+
10+
11+
std_logging.basicConfig(level=std_logging.INFO, format="%(asctime)s %(levelname)s %(name)s: %(message)s")
12+
logger = logging.get_logger(__name__)
713

814
PATTERN = "benchmarking_*.py"
915
FINAL_CSV_FILENAME = "collated_results.py"
@@ -26,7 +32,7 @@ def run_command(command: list[str], return_stdout=False):
2632
def merge_csvs(final_csv: str = "collated_results.csv"):
2733
all_csvs = glob.glob("*.csv")
2834
if not all_csvs:
29-
print("No result CSVs found to merge.")
35+
logger.info("No result CSVs found to merge.")
3036
return
3137

3238
df_list = []
@@ -39,14 +45,14 @@ def merge_csvs(final_csv: str = "collated_results.csv"):
3945
df_list.append(d)
4046

4147
if not df_list:
42-
print("All result CSVs were empty or invalid; nothing to merge.")
48+
logger.info("All result CSVs were empty or invalid; nothing to merge.")
4349
return
4450

4551
final_df = pd.concat(df_list, ignore_index=True)
4652
if GITHUB_SHA is not None:
4753
final_df["github_sha"] = GITHUB_SHA
4854
final_df.to_csv(final_csv, index=False)
49-
print(f"Merged {len(all_csvs)} partial CSVs → {final_csv}.")
55+
logger.info(f"Merged {len(all_csvs)} partial CSVs → {final_csv}.")
5056

5157

5258
def run_scripts():
@@ -55,24 +61,24 @@ def run_scripts():
5561

5662
for file in python_files:
5763
script_name = file.split(".py")[0].split("_")[-1] # example: benchmarking_foo.py -> foo
58-
print(f"\n****** Running file: {file} ******")
64+
logger.info(f"\n****** Running file: {file} ******")
5965

6066
partial_csv = f"{script_name}.csv"
6167
if os.path.exists(partial_csv):
62-
print(f"Found {partial_csv}. Removing for safer numbers and duplication.")
68+
logger.info(f"Found {partial_csv}. Removing for safer numbers and duplication.")
6369
os.remove(partial_csv)
6470

6571
command = ["python", file]
6672
try:
6773
run_command(command)
68-
print(f"→ {file} finished normally.")
74+
logger.info(f"→ {file} finished normally.")
6975
except SubprocessCallException as e:
70-
print(f"Error running {file}:\n{e}")
76+
logger.info(f"Error running {file}:\n{e}")
7177
finally:
72-
print(f"→ Merging partial CSVs after {file} …")
78+
logger.info(f"→ Merging partial CSVs after {file} …")
7379
merge_csvs(final_csv=FINAL_CSV_FILENAME)
7480

75-
print(f"\nAll scripts attempted. Final collated CSV: {FINAL_CSV_FILENAME}")
81+
logger.info(f"\nAll scripts attempted. Final collated CSV: {FINAL_CSV_FILENAME}")
7682

7783

7884
if __name__ == "__main__":

0 commit comments

Comments
 (0)