separate model card git push from the rest (#13514)

Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
This commit is contained in:
elishowk 2021-09-14 18:07:36 +02:00 committed by GitHub
parent 9f318be3d3
commit 054b6013c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions

View File

@ -341,8 +341,8 @@ Add a model card
To make sure everyone knows what your model can do, what its limitations, potential bias or ethical considerations are,
please add a README.md model card to your model repo. You can just create it, or there's also a convenient button
titled "Add a README.md" on your model page. A model card template can be found `here
<https://github.com/huggingface/model_card>`__ (meta-suggestions are welcome). model card template (meta-suggestions
titled "Add a README.md" on your model page. A model card documentation can be found `here
<https://huggingface.co/docs/hub/model-repos>`__ (meta-suggestions are welcome). model card template (meta-suggestions
are welcome).
.. note::

View File

@ -2625,7 +2625,6 @@ class Trainer:
model_name = Path(self.args.output_dir).name
else:
model_name = self.args.hub_model_id.split("/")[-1]
self.create_model_card(model_name=model_name, **kwargs)
# Needs to be executed on all processes for TPU training, but will only save on the processed determined by
# self.args.should_save.
self.save_model()
@ -2634,7 +2633,16 @@ class Trainer:
if not self.is_world_process_zero():
return
return self.repo.push_to_hub(commit_message=commit_message, blocking=blocking)
git_head_commit_url = self.repo.push_to_hub(commit_message=commit_message, blocking=blocking)
# push separately the model card to be independant from the rest of the model
if self.args.should_save:
self.create_model_card(model_name=model_name, **kwargs)
try:
self.repo.push_to_hub(commit_message="update model card README.md", blocking=blocking)
except EnvironmentError as exc:
logger.error(f"Error pushing update to the model card. Please read logs and retry.\n${exc}")
return git_head_commit_url
#
# Deprecated code