Unverified Commit 5b5b48b1 authored by amyeroberts's avatar amyeroberts Committed by GitHub
Browse files

Remove copied froms for deprecated models (#31153)

* Remove copied froms for deprecated models

* Remove automatically in script
parent 97e5a707
......@@ -124,6 +124,25 @@ def update_relative_imports(filename, model):
f.write("\n".join(new_file_lines))
def remove_copied_from_statements(model):
model_path = REPO_PATH / f"src/transformers/models/{model}"
for file in os.listdir(model_path):
if file == "__pycache__":
continue
file_path = model_path / file
with open(file_path, "r") as f:
file_lines = f.read()
new_file_lines = []
for line in file_lines.split("\n"):
if "# Copied from" in line:
continue
new_file_lines.append(line)
with open(file_path, "w") as f:
f.write("\n".join(new_file_lines))
def move_model_files_to_deprecated(model):
model_path = REPO_PATH / f"src/transformers/models/{model}"
deprecated_model_path = REPO_PATH / f"src/transformers/models/deprecated/{model}"
......@@ -321,6 +340,10 @@ def deprecate_models(models):
print("Adding tip message to model doc page")
insert_tip_to_model_doc(model_info["model_doc_path"], tip_message)
# Remove #Copied from statements from model's files
print("Removing #Copied from statements from model's files")
remove_copied_from_statements(model)
# Move the model file to deprecated: src/transfomers/models/model -> src/transformers/models/deprecated/model
print("Moving model files to deprecated for model")
move_model_files_to_deprecated(model)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment