huggingface_hub: Incorrect validation error

Describe the bug

I’m not able to push my adapter model to hub because of incorrect validation error:

huggingface_hub.utils.validators.HFValidationError: Repo id must use alphanumeric chars or ‘-’, ‘’, ‘.’, ‘–’ and ‘…’ are forbidden, ‘-’ and ‘.’ cannot start or end the name, max length is 96: ‘aXFQcyOEpksZmnbENRFdTmaKaSBhTYFjRfYIgsuTegBoJlhMjqzzsScRkstravxQFPkmstYSjKcEZZmMVFaYRBOHilKgotGBWwqTFBhzVJrVpNzOPLjyYMKXkYeqKkxj’.

my repo name is joint_dt_fiction_travel which is perfectly valid but it’s not letting me push models because of invalid name error. This is how I’m pushing the model:

model.push_adapter_to_hub(
        repo_name= "joint_dt_fiction_travel",
        adapter_name= f"{adapter_name}",
        organization="UDApter",
        adapterhub_tag="nli/multinli",
        datasets_tag="multi_nli"
    )

Any help will be appreciated. Thanks!

Reproduction

No response

Logs

Some weights of the model checkpoint at bert-base-uncased were not used when initializing BertModelWithHeads: ['cls.predictions.decoder.weight', 'cls.predictions.transform.LayerNorm.weight', 'cls.predictions.bias', 'cls.predictions.transform.dense.weight', 'cls.seq_relationship.weight', 'cls.predictions.transform.dense.bias', 'cls.predictions.transform.LayerNorm.bias', 'cls.seq_relationship.bias']
- This IS expected if you are initializing BertModelWithHeads from the checkpoint of a model trained on another task or with another architecture (e.g. initializing a BertForSequenceClassification model from a BertForPreTraining model).
- This IS NOT expected if you are initializing BertModelWithHeads from the checkpoint of a model that you expect to be exactly identical (initializing a BertForSequenceClassification model from a BertForSequenceClassification model).
Traceback (most recent call last):
  File "push_to_hub.py", line 62, in <module>
    model.push_adapter_to_hub(
  File "/home/bhavitvya/.cache/pypoetry/virtualenvs/domadapter-VESkl83O-py3.8/lib/python3.8/site-packages/transformers/adapters/hub_mixin.py", line 155, in push_adapter_to_hub
    repo_url = self._get_repo_url_from_name(
  File "/home/bhavitvya/.cache/pypoetry/virtualenvs/domadapter-VESkl83O-py3.8/lib/python3.8/site-packages/transformers/file_utils.py", line 2056, in _get_repo_url_from_name
    return HfApi(endpoint=HUGGINGFACE_CO_RESOLVE_ENDPOINT).create_repo(
  File "/home/bhavitvya/.cache/pypoetry/virtualenvs/domadapter-VESkl83O-py3.8/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn
    validate_repo_id(arg_value)
  File "/home/bhavitvya/.cache/pypoetry/virtualenvs/domadapter-VESkl83O-py3.8/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py", line 172, in validate_repo_id
    raise HFValidationError(
huggingface_hub.utils._validators.HFValidationError: Repo id must use alphanumeric chars or '-', '_', '.', '--' and '..' are forbidden, '-' and '.' cannot start or end the name, max length is 96: 'aXFQcyOEpksZmnbENRFdTmaKaSBhTYFjRfYIgsuTegBoJlhMjqzzsScRkstravxQFPkmstYSjKcEZZmMVFaYRBOHilKgotGBWwqTFBhzVJrVpNzOPLjyYMKXkYeqKkxj'.

System info

- huggingface_hub version: 0.12.0
- Platform: Linux-5.8.0-59-generic-x86_64-with-glibc2.29
- Python version: 3.8.10
- Running in iPython ?: No
- Running in notebook ?: No
- Running in Google Colab ?: No
- Token path ?: /home/bhavitvya/.cache/huggingface/token
- Has saved token ?: True
- Who am I ?: bhavitvyamalik
- Configured git credential helpers: 
- FastAI: N/A
- Tensorflow: N/A
- Torch: 1.9.1+cu111
- Jinja2: N/A
- Graphviz: N/A
- Pydot: N/A
- Pillow: N/A
- hf_transfer: N/A
- ENDPOINT: https://huggingface.co
- HUGGINGFACE_HUB_CACHE: /home/bhavitvya/.cache/huggingface/hub
- HUGGINGFACE_ASSETS_CACHE: /home/bhavitvya/.cache/huggingface/assets
- HF_HUB_OFFLINE: False
- HF_TOKEN_PATH: /home/bhavitvya/.cache/huggingface/token
- HF_HUB_DISABLE_PROGRESS_BARS: None
- HF_HUB_DISABLE_SYMLINKS_WARNING: False
- HF_HUB_DISABLE_IMPLICIT_TOKEN: False
- HF_HUB_ENABLE_HF_TRANSFER: False

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 20 (10 by maintainers)

Most upvoted comments

I’ve no idea from where this long string came from. I’m just trying to loop through all adapter models and push them to hub. I tried something similar few days back and was able to push the model but when I tried the same thing within a loop, I couldn’t push that. In (3) I’ve added a bare minimum reproducible script (even without loop it isn’t working). Thank you for your help!

  1. adapter-transformers 2.1.2
  2. adapter name: adapter_fiction_slate
from transformers import AutoTokenizer
from transformers import AutoModelWithHeads, AutoConfig

config = AutoConfig.from_pretrained("bert-base-uncased", output_hidden_states=True)
tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
model = AutoModelWithHeads.from_pretrained("bert-base-uncased", config=config)

full_path = os.path.join(os.getcwd(), "experiments", "fiction_slate", "joint_domain_task_adapter", "10bl8z6y", "checkpoints")
# load adapter checkpoints and activate it
adapter_name = model.load_adapter(full_path)
model.train_adapter([adapter_name])

repo_name = f"joint_dt_fiction_slate"

model.push_adapter_to_hub(
    repo_name=f"{repo_name}",
    adapter_name=adapter_name,
    organization="UDApter",
    adapterhub_tag="nli/multinli",
    datasets_tag="multi_nli"
)

Great! Happy to know all your problems are solved 🎉 We can close this issue now 😃

I can push model to my repo

🎉 Good news to have at least that solved.

But not to my organization

Still something to fix then. Could you tell me - what is your user and organization name please ? And what code do you have when pushing to organization (are you passing org name in repo_id or organization field?).

And do you know that once you’ve pushed a model to the hub, you can change its namespace (if your case, transfer it to your organization). This can be done in the settings page of the repo or using move_repo. Could you try that and tell me if you are able to do it? Hope we will figure out together what’s your issue now 😃