Small Fix to modular converter (#34051)

* small_fix

* supporting both src/tranformers and examples/

* make style
This commit is contained in:
Mohamed Mekkouri 2024-10-10 18:43:27 +02:00 committed by GitHub
parent 211f1d93db
commit 24b82f3cd5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1088,8 +1088,9 @@ def convert_modular_file(modular_file, old_model_name=None, new_model_name=None,
if node != {}:
# Get relative path starting from src/transformers/
relative_path = re.search(
f"{os.sep}(src{os.sep}transformers{os.sep}.*)", os.path.abspath(modular_file)
rf"(src{os.sep}transformers{os.sep}.*|examples{os.sep}.*)", os.path.abspath(modular_file)
).group(1)
header = AUTO_GENERATED_MESSAGE.format(
relative_path=relative_path, short_name=os.path.basename(relative_path)
)