"Dump_all() got an unexpected keyword argument 'sort_keys'" after running trainer.push_to_hub()

Just fine-tuned pegasus-large on Google Colab Pro with trainer.train(), then executed the following commands:

!huggingface-cli login
!pip install hf-lfs
!git config --global user.email "jakemsc@example.com"
!git config --global user.name "JakeMSc"
trainer.push_to_hub("test_model")

Which leads to the following error:

TypeError                                 Traceback (most recent call last)
<ipython-input-29-0cd57aa71f88> in <module>()
----> 1 trainer.push_to_hub("test_model")

3 frames
/usr/local/lib/python3.7/dist-packages/yaml/__init__.py in dump(data, stream, Dumper, **kwds)
    198     If stream is None, return the produced string instead.
    199     """
--> 200     return dump_all([data], stream, Dumper=Dumper, **kwds)
    201 
    202 def safe_dump_all(documents, stream=None, **kwds):

TypeError: dump_all() got an unexpected keyword argument 'sort_keys'

Here are details of my system installation:

  • transformers version: 4.8.2
  • Platform: Linux-5.4.104±x86_64-with-Ubuntu-18.04-bionic
  • Python version: 3.7.10
  • PyTorch version (GPU?): 1.9.0+cu102 (True)
  • Tensorflow version (GPU?): 2.5.0 (True)
  • Flax version (CPU?/GPU?/TPU?): not installed (NA)
  • Jax version: not installed
  • JaxLib version: not installed
  • Using GPU in script?: Yes
  • Using distributed or parallel set-up in script?: No

Any ideas on how to resolve this?

What is your version of pyaml? I think you need a more recent version (pip install --upgrade pyyaml). Will adjust the setup.

1 Like

Thanks, my pyaml was on version 3.4, so that solved the problem after updating to version 5.4. Although now I have a new error. See here: "AttributeError: 'Seq2SeqTrainer' object has no attribute 'repo'" after running trainer.push_to_hub()

Yes, you need to set push_to_hub=True in the training arguments before training. Check the updated notebooks!

1 Like