# Push\_to\_hub\_callback doesn't work

**URL:** <https://discuss.huggingface.co/t/push-to-hub-callback-doesnt-work/16033>\
**Category:** 🤗Hub\
**Created:** [March 24, 2022, 11:06am UTC](https://discuss.huggingface.co/t/push-to-hub-callback-doesnt-work/16033 "2022-03-24T11:06:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gozdi](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/gozdi/32/4221_2.png) [@Gozdi](https://discuss.huggingface.co/u/Gozdi)\
**Post date:** [March 24, 2022, 11:06am UTC](https://discuss.huggingface.co/t/push-to-hub-callback-doesnt-work/16033/1 "2022-03-24T11:06:22Z")

</div>

Im using push to hub callback but it doesn’t work as it’s suppose to, it only creates new repo but doesn’t push anything after each epoch and when all epochs are done training just keeps going I need to manuali interrupt it. I tried puting my token directly into push\_to\_hub\_callback but it changes nothing

---

<div class="post-metadata">

**Author:** ![merve](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/merve/32/49809_2.png) [@merve](https://discuss.huggingface.co/u/merve)\
**Post date:** [March 24, 2022, 11:10am UTC](https://discuss.huggingface.co/t/push-to-hub-callback-doesnt-work/16033/2 "2022-03-24T11:10:52Z")

</div>

@Gozdi Hello, can you post your code here and also the repository?

---

<div class="post-metadata">

**Author:** ![Gozdi](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/gozdi/32/4221_2.png) [@Gozdi](https://discuss.huggingface.co/u/Gozdi)\
**Post date:** [March 24, 2022, 11:18am UTC](https://discuss.huggingface.co/t/push-to-hub-callback-doesnt-work/16033/3 "2022-03-24T11:18:56Z")

</div>

@merve  
here is colab notebook I used for training

> **[Google Colaboratory](https://colab.research.google.com/drive/1jchbTRsnM7RM9urLIQcpIsPCjhsT7Qpv?usp=sharing)**

and here is repository [https://huggingface.co/Gozdi/electra-base-finetuned-coqa](https://huggingface.co/Gozdi/electra-base-finetuned-coqa)  
but i created it manually

---

<div class="post-metadata">

**Author:** ![merve](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/merve/32/49809_2.png) [@merve](https://discuss.huggingface.co/u/merve)\
**Post date:** [March 24, 2022, 3:33pm UTC](https://discuss.huggingface.co/t/push-to-hub-callback-doesnt-work/16033/4 "2022-03-24T15:33:30Z")

</div>

@Gozdi we’re investigating the issue 🤗

---

<div class="post-metadata">

**Author:** ![daveharshil7](https://avatars.discourse-cdn.com/v4/letter/d/c6cbf5/32.png) [@daveharshil7](https://discuss.huggingface.co/u/daveharshil7)\
**Post date:** [May 27, 2022, 9:04am UTC](https://discuss.huggingface.co/t/push-to-hub-callback-doesnt-work/16033/5 "2022-05-27T09:04:22Z")

</div>

I am facing the exact same issue @Gozdi mentioned. My training arguments are following. I am already using notebook\_login interface to provide token. Surprisingly, everything works seamless except the push\_to\_hub part. I am noticing that it is saying several commits will be pushed upstream, but nothing shows up in the hub. This is happening in google colab and I am storing my model in mounted google drive (maybe that could be a trouble?).

At the end I used used in [this tutorial](https://www.youtube.com/watch?v=9yY3RB_GSPM&list=PLo2EIpI_JMQvBf9VwoyXCkHldK6-4aGPQ&index=4&ab_channel=HuggingFace) to push the model to hub manually. Happy to share more info if required.

```auto
args = TrainingArguments(
    output_dir='/content/drive/MyDrive/'+folder_name,
    evaluation_strategy="epoch",
    save_total_limit = 2, 
    save_strategy="epoch",
    learning_rate=learning_rate,
    metric_for_best_model='f1',
    greater_is_better=True, 
    load_best_model_at_end=True,
    num_train_epochs=num_epochs,
    weight_decay=0.01,
    logging_steps=100,
    hub_private_repo=True,
    push_to_hub=True,
    hub_model_id=folder_name
    )

```

---

<div class="post-metadata">

**Author:** ![kasrahabib](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/kasrahabib/32/26667_2.png) [@kasrahabib](https://discuss.huggingface.co/u/kasrahabib)\
**Post date:** [May 6, 2024, 2:38pm UTC](https://discuss.huggingface.co/t/push-to-hub-callback-doesnt-work/16033/6 "2024-05-06T14:38:11Z")

</div>

It does not work for me either, but I found a way around, here is how I do it:

I define my push to hub call back as normal and train my model, it saves everything in the output directory and when the training is finished, it will produce the below error and I just ignore it:

```python

SError: EOF
error: failed to push some refs to 'https://huggingface.co/your-user-name/your-name-of-the-model'

```

Then, I use the below code to manually upload it:

```python

from huggingface_hub import HfApi

api = HfApi()

api.upload_folder(
    folder_path = "path-to-your-output-directory",
    repo_id = "hf-username/" + name-of-the-model,
    repo_type = "model",
)

```

It works for me.
