mirror of
https://github.com/open-compass/opencompass.git
synced 2025-05-30 16:03:24 +08:00
fix hook
This commit is contained in:
parent
ffe00a830d
commit
b1c2f60d32
@ -94,21 +94,21 @@ def check_and_rename(filepath):
|
|||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
|
|
||||||
def update_imports(data):
|
# def update_imports(data):
|
||||||
python_file, name_pairs = data
|
# python_file, name_pairs = data
|
||||||
for filepath, new_file in name_pairs:
|
# for filepath, new_file in name_pairs:
|
||||||
old_name = os.path.basename(filepath)[:-3]
|
# old_name = os.path.basename(filepath)[:-3]
|
||||||
new_name = os.path.basename(new_file)[:-3]
|
# new_name = os.path.basename(new_file)[:-3]
|
||||||
if not os.path.exists(python_file):
|
# if not os.path.exists(python_file):
|
||||||
return
|
# return
|
||||||
with open(python_file, 'r') as file:
|
# with open(python_file, 'r') as file:
|
||||||
filedata = file.read()
|
# filedata = file.read()
|
||||||
# Replace the old name with new name
|
# # Replace the old name with new name
|
||||||
new_data = filedata.replace(old_name, new_name)
|
# new_data = filedata.replace(old_name, new_name)
|
||||||
if filedata != new_data:
|
# if filedata != new_data:
|
||||||
with open(python_file, 'w') as file:
|
# with open(python_file, 'w') as file:
|
||||||
file.write(new_data)
|
# file.write(new_data)
|
||||||
# print(f"Updated imports in {python_file}")
|
# # print(f"Updated imports in {python_file}")
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@ -134,11 +134,11 @@ def main():
|
|||||||
return
|
return
|
||||||
with Pool(16) as p:
|
with Pool(16) as p:
|
||||||
p.starmap(os.rename, name_pairs)
|
p.starmap(os.rename, name_pairs)
|
||||||
root_folder = 'configs'
|
# root_folder = 'configs'
|
||||||
python_files = glob.glob(f'{root_folder}/**/*.py', recursive=True)
|
# python_files = glob.glob(f'{root_folder}/**/*.py', recursive=True)
|
||||||
update_data = [(python_file, name_pairs) for python_file in python_files]
|
# update_data = [(python_file, name_pairs) for python_file in python_files]
|
||||||
with Pool(16) as p:
|
# with Pool(16) as p:
|
||||||
p.map(update_imports, update_data)
|
# p.map(update_imports, update_data)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
Reference in New Issue
Block a user