Trainer push to hub (#11328)

* Initial support for upload to hub

* push -> upload

* Fixes + examples

* Fix torchhub test

* Torchhub test I hate you

* push_model_to_hub -> push_to_hub

* Apply mixin to other pretrained models

* Remove ABC inheritance

* Add tests

* Typo

* Run tests

* Install git-lfs

* Change approach

* Add push_to_hub to all

* Staging test suite

* Typo

* Maybe like this?

* More deps

* Cache

* Adapt name

* Quality

* MOAR tests

* Put it in testing_utils

* Docs + torchhub last hope

* Styling

* Wrong method

* Typos

* Update src/transformers/file_utils.py

Co-authored-by: Julien Chaumond <julien@huggingface.co>

* Address review comments

* Apply suggestions from code review

Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>

Co-authored-by: Julien Chaumond <julien@huggingface.co>
Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
This commit is contained in:
Sylvain Gugger
2021-04-23 09:17:37 -04:00
committed by GitHub
parent 7bc86bea68
commit bf2e0cf70b
31 changed files with 766 additions and 31 deletions

View File

View File

@@ -447,6 +447,9 @@ def main():
trainer.log_metrics("eval", metrics)
trainer.save_metrics("eval", metrics)
if training_args.push_to_hub:
trainer.push_to_hub()
def _mp_fn(index):
# For xla_spawn (TPUs)

View File

@@ -476,6 +476,9 @@ def main():
trainer.log_metrics("eval", metrics)
trainer.save_metrics("eval", metrics)
if training_args.push_to_hub:
trainer.push_to_hub()
def _mp_fn(index):
# For xla_spawn (TPUs)

View File

@@ -452,6 +452,9 @@ def main():
trainer.log_metrics("eval", metrics)
trainer.save_metrics("eval", metrics)
if training_args.push_to_hub:
trainer.push_to_hub()
def _mp_fn(index):
# For xla_spawn (TPUs)

View File

@@ -428,6 +428,9 @@ def main():
trainer.log_metrics("eval", metrics)
trainer.save_metrics("eval", metrics)
if training_args.push_to_hub:
trainer.push_to_hub()
def _mp_fn(index):
# For xla_spawn (TPUs)

View File

@@ -599,6 +599,9 @@ def main():
trainer.log_metrics("test", metrics)
trainer.save_metrics("test", metrics)
if training_args.push_to_hub:
trainer.push_to_hub()
def _mp_fn(index):
# For xla_spawn (TPUs)

View File

@@ -638,6 +638,9 @@ def main():
trainer.log_metrics("test", metrics)
trainer.save_metrics("test", metrics)
if training_args.push_to_hub:
trainer.push_to_hub()
def _mp_fn(index):
# For xla_spawn (TPUs)

View File

@@ -579,6 +579,9 @@ def main():
with open(output_test_preds_file, "w") as writer:
writer.write("\n".join(test_preds))
if training_args.push_to_hub:
trainer.push_to_hub()
return results

View File

@@ -517,6 +517,9 @@ def main():
item = label_list[item]
writer.write(f"{index}\t{item}\n")
if training_args.push_to_hub:
trainer.push_to_hub()
def _mp_fn(index):
# For xla_spawn (TPUs)

View File

@@ -491,6 +491,9 @@ def main():
for prediction in true_predictions:
writer.write(" ".join(prediction) + "\n")
if training_args.push_to_hub:
trainer.push_to_hub()
def _mp_fn(index):
# For xla_spawn (TPUs)

View File

@@ -571,6 +571,9 @@ def main():
with open(output_test_preds_file, "w") as writer:
writer.write("\n".join(test_preds))
if training_args.push_to_hub:
trainer.push_to_hub()
return results