MCPcopy Create free account
hub / github.com/Francis-Rings/FlashPortrait / _write_to_excel

Function _write_to_excel

wan/utils/utils.py:415–440  ·  view source on GitHub ↗
(model_name, time_sum)

Source from the content-addressed store, hash-verified

413 return decorator
414
415def _write_to_excel(model_name, time_sum):
416 import os
417
418 import pandas as pd
419
420 row_env = os.environ.get(f"{model_name}_EXCEL_ROW", "1") # 默认第1行
421 col_env = os.environ.get(f"{model_name}_EXCEL_COL", "1") # 默认第A列
422 file_path = os.environ.get("EXCEL_FILE", "timing_records.xlsx") # 默认文件名
423
424 try:
425 df = pd.read_excel(file_path, sheet_name="Sheet1", header=None)
426 except FileNotFoundError:
427 df = pd.DataFrame()
428
429 row_idx = int(row_env)
430 col_idx = int(col_env)
431
432 if row_idx >= len(df):
433 df = pd.concat([df, pd.DataFrame([ [None] * (len(df.columns) if not df.empty else 0) ] * (row_idx - len(df) + 1))], ignore_index=True)
434
435 if col_idx >= len(df.columns):
436 df = pd.concat([df, pd.DataFrame(columns=range(len(df.columns), col_idx + 1))], axis=1)
437
438 df.iloc[row_idx, col_idx] = time_sum
439
440 df.to_excel(file_path, index=False, header=False, sheet_name="Sheet1")
441
442def get_autocast_dtype():
443 try:

Callers 1

wrapperFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected