Skip to content

Commit b2593d2

Browse files
committed
Change new kwarg name
1 parent 666e212 commit b2593d2

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/transformers/generation/configuration_utils.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ def save_pretrained(
755755

756756
output_config_file = os.path.join(save_directory, config_file_name)
757757

758-
self.to_json_file(output_config_file, use_diff=True, pop_keys=["compile_config"])
758+
self.to_json_file(output_config_file, use_diff=True, keys_to_pop=["compile_config"])
759759
logger.info(f"Configuration saved in {output_config_file}")
760760

761761
if push_to_hub:
@@ -1030,7 +1030,7 @@ def to_dict(self) -> dict[str, Any]:
10301030
return output
10311031

10321032
def to_json_string(
1033-
self, use_diff: bool = True, ignore_metadata: bool = False, pop_keys: list[str] | None = None
1033+
self, use_diff: bool = True, ignore_metadata: bool = False, keys_to_pop: list[str] | None = None
10341034
) -> str:
10351035
"""
10361036
Serializes this instance to a JSON string.
@@ -1041,7 +1041,7 @@ def to_json_string(
10411041
is serialized to JSON string.
10421042
ignore_metadata (`bool`, *optional*, defaults to `False`):
10431043
Whether to ignore the metadata fields present in the instance
1044-
pop_keys (`list[str]`, *optional*):
1044+
keys_to_pop (`list[str]`, *optional*):
10451045
Keys to pop from the config dictionary before serializing
10461046
10471047
Returns:
@@ -1052,8 +1052,8 @@ def to_json_string(
10521052
else:
10531053
config_dict = self.to_dict()
10541054

1055-
if pop_keys is not None:
1056-
for key in pop_keys:
1055+
if keys_to_pop is not None:
1056+
for key in keys_to_pop:
10571057
config_dict.pop(key, None)
10581058

10591059
if ignore_metadata:
@@ -1082,7 +1082,7 @@ def convert_dataclass_to_dict(obj):
10821082
return json.dumps(config_dict, indent=2, sort_keys=True) + "\n"
10831083

10841084
def to_json_file(
1085-
self, json_file_path: str | os.PathLike, use_diff: bool = True, pop_keys: list[str] | None = None
1085+
self, json_file_path: str | os.PathLike, use_diff: bool = True, keys_to_pop: list[str] | None = None
10861086
) -> None:
10871087
"""
10881088
Save this instance to a JSON file.
@@ -1093,11 +1093,11 @@ def to_json_file(
10931093
use_diff (`bool`, *optional*, defaults to `True`):
10941094
If set to `True`, only the difference between the config instance and the default `GenerationConfig()`
10951095
is serialized to JSON file.
1096-
pop_keys (`list[str]`, *optional*):
1096+
keys_to_pop (`list[str]`, *optional*):
10971097
Keys to pop from the config dictionary before serializing
10981098
"""
10991099
with open(json_file_path, "w", encoding="utf-8") as writer:
1100-
writer.write(self.to_json_string(use_diff=use_diff, pop_keys=pop_keys))
1100+
writer.write(self.to_json_string(use_diff=use_diff, keys_to_pop=keys_to_pop))
11011101

11021102
@classmethod
11031103
def from_model_config(cls, model_config: PreTrainedConfig | dict) -> "GenerationConfig":

0 commit comments

Comments
 (0)