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

Fix regression on Processor.save_pretrained caused by #31691 #32921

Merged
merged 1 commit into from
Aug 22, 2024

Conversation

leloykun
Copy link
Contributor

@leloykun leloykun commented Aug 21, 2024

What does this PR do?

Fix regression on Processor.save_pretrained caused by #31691

tl;dr: a month ago, we made a change that removed "chat_template" from processor_dict when saving a processor. This caused processor_config.json to not get saved at all. See:

processor_dict = self.to_dict()
chat_template = processor_dict.pop("chat_template", None)
if chat_template is not None:
    chat_template_json_string = json.dumps({"chat_template": chat_template}, indent=2, sort_keys=True) + "\n"
    with open(output_chat_template_file, "w", encoding="utf-8") as writer:
        writer.write(chat_template_json_string)
    logger.info(f"chat template saved in {output_chat_template_file}")

# For now, let's not save to `processor_config.json` if the processor doesn't have extra attributes and
# `auto_map` is not specified.
if set(processor_dict.keys()) != {"processor_class"}:
    self.to_json_file(output_processor_file)
    logger.info(f"processor saved in {output_processor_file}")

but we kept these lines as is:

if set(self.to_dict().keys()) == {"processor_class"}:
    return []
return [output_processor_file]

So, for a month now, we've not been saving processor_config.json but still returning [processor_config.json] as the saved files. This has caused a test in my other PR (#32906) to fail

Who can review?

@amyeroberts @zucchini-nlp

@leloykun leloykun marked this pull request as ready for review August 21, 2024 14:40
Copy link
Member

@zucchini-nlp zucchini-nlp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right, thanks for fixing!

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, tho we need a small test to make sure we don't break that again 😓

@zucchini-nlp
Copy link
Member

I guess that had a tests, but it wasn't triggered when the prev PR was merged. I ran only VLMs when merging the prev PR...

@ArthurZucker
Copy link
Collaborator

Okay, merging and patching!

@ArthurZucker ArthurZucker merged commit 273c0af into huggingface:main Aug 22, 2024
16 of 20 checks passed
ArthurZucker pushed a commit that referenced this pull request Aug 22, 2024
zucchini-nlp pushed a commit to zucchini-nlp/transformers that referenced this pull request Aug 30, 2024
zucchini-nlp pushed a commit to zucchini-nlp/transformers that referenced this pull request Aug 30, 2024
itazap pushed a commit to NielsRogge/transformers that referenced this pull request Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants