Skip to content

Commit 5d80a7a

Browse files
author
Sagi Polaczek
committed
handle depracted arguments
1 parent 7eb8ba4 commit 5d80a7a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

mammal/model.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ def from_dict(cls, config_dict: dict[str, Any]) -> "MammalConfig":
5353
config = cls(**config_dict)
5454
return config
5555

56+
@classmethod
57+
def get_deprecated_arguments(cls) -> list[str]:
58+
"""Property of deprecated arguments to support backward compatibility."""
59+
deprecated_arguments = ["load_weights", "t5_pretrained_name"]
60+
return deprecated_arguments
61+
5662
def override(self, config_overrides: dict[str, Any]) -> None:
5763
"""
5864
Override existing (loaded configuration)
@@ -410,6 +416,13 @@ def from_pretrained(
410416
weights_only=False,
411417
)
412418
config = pl_ckpt_dict["config"]
419+
for deprecated_arg in MammalConfig.get_deprecated_arguments():
420+
# Remove deprecated arg if exists
421+
if hasattr(config, deprecated_arg):
422+
print(
423+
f"Found deprecated argument '{deprecated_arg}'. Deleting it!"
424+
)
425+
delattr(config, deprecated_arg)
413426

414427
if isinstance(config, str):
415428
# Config path was given or was located in the parent directory

0 commit comments

Comments
 (0)