feat: generate model card on local save (#258)#388
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the model card creation logic by introducing a helper function create_model_card in src/heretic/utils.py and using it in src/heretic/main.py both when saving the model locally and when pushing it to the Hugging Face Hub. Feedback was provided to improve the robustness of create_model_card by handling potential exceptions during model card loading and preventing a TypeError when card.text is None.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
I Noticed that if someone hits "Save to local folder", the model card/README gets entirely skipped and only the weights drop.
To fix it without duplicating any code, I just pulled the
ModelCardgeneration logic out of the HF upload block into a cleancreate_model_card()helper function over inutils.py.Now the local save routine just hits that exact same helper to automatically drop the
README.mdright next to the local weight files. Works perfectly and keeps the HF upload logic a lot cleaner too! Let me know if you need anything tweaked.