Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

to_json_string兼容性升级 #8608

Merged
merged 2 commits into from
Jun 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion paddlenlp/transformers/configuration_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from __future__ import annotations

import copy
import inspect
import json
import os
import re
Expand Down Expand Up @@ -1109,8 +1110,14 @@
If set to `True`, only the difference between the config instance and the default `PretrainedConfig()`
is serialized to JSON file.
"""
spec = inspect.getfullargspec(self.to_json_string)
has_saving_file_arg = "saving_file" in spec.args or spec.varkw
with open(json_file_path, "w", encoding="utf-8") as writer:
writer.write(self.to_json_string(use_diff=use_diff, saving_file=saving_file))
if has_saving_file_arg:
s = self.to_json_string(use_diff=use_diff, saving_file=saving_file)
else:
s = self.to_json_string(use_diff=use_diff)

Check warning on line 1119 in paddlenlp/transformers/configuration_utils.py

View check run for this annotation

Codecov / codecov/patch

paddlenlp/transformers/configuration_utils.py#L1119

Added line #L1119 was not covered by tests
writer.write(s)

def update(self, config_dict: Dict[str, Any]):
"""
Expand Down