GitHub issue #5833: Unable to push dataset - `create_pr` problem
State: closed | Created: 2023-05-09T15:32:55Z

### Describe the bug

I can't upload to the hub the dataset I manually created locally (Image dataset). I have a problem when using the method `.push_to_hub` which asks for a `create_pr` attribute which is not compatible.

### Steps to reproduce the bug

here what I have:

```python
dataset.push_to_hub("agomberto/FrenchCensus-handwritten-texts")
```
Output:
```python
Pushing split train to the Hub.
Pushing dataset shards to the dataset hub:   0%|                                                                                                                                      | 0/2 [00:00<?, ?it/s]
Creating parquet from Arrow format:   0%|                                                                                                                                             | 0/3 [00:00<?, ?ba/s]
Creating parquet from Arrow format: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 3/3 [00:00<00:00, 12.70ba/s]
Pushing dataset shards to the dataset hub:   0%|                                                                                                                                      | 0/2 [00:01<?, ?it/s]

---------------------------------------------------------------------------
HTTPError                                 Traceback (most recent call last)
File ~/miniconda3/envs/hwocr/lib/python3.8/site-packages/huggingface_hub/utils/_errors.py:259, in hf_raise_for_status(response, endpoint_name)
    258 try:
--> 259     response.raise_for_status()
    260 except HTTPError as e:

File ~/miniconda3/envs/hwocr/lib/python3.8/site-packages/requests/models.py:1021, in Response.raise_for_status(self)
   1020 if http_error_msg:
-> 1021     raise HTTPError(http_error_msg, response=self)

HTTPError: 403 Client Error: Forbidden for url: https://huggingface.co/api/datasets/agomberto/FrenchCensus-handwritten-texts/commit/main

The above exception was the direct cause of the following exception:

HfHubHTTPError                            Traceback (most recent call last)
Cell In[7], line 1
----> 1 dataset.push_to_hub("agomberto/FrenchCensus-handwritten-texts")

File ~/miniconda3/envs/hwocr/lib/python3.8/site-packages/datasets/dataset_dict.py:1583, in DatasetDict.push_to_hub(self, repo_id, private, token, branch, max_shard_size, num_shards, embed_external_files)
   1581 logger.warning(f"Pushing split {split} to the Hub.")
   1582 # The split=key needs to be removed before merging
-> 1583 repo_id, split, uploaded_size, dataset_nbytes, _, _ = self[split]._push_parquet_shards_to_hub(
   1584     repo_id,
   1585     split=split,
   1586     private=private,
   1587     token=token,
   1588     branch=branch,
   1589     max_shard_size=max_shard_size,
   1590     num_shards=num_shards.get(split),
   1591     embed_external_files=embed_external_files,
   1592 )
   1593 total_uploaded_size += uploaded_size
   1594 total_dataset_nbytes += dataset_nbytes

File ~/miniconda3/envs/hwocr/lib/python3.8/site-packages/datasets/arrow_dataset.py:5275, in Dataset._push_parquet_shards_to_hub(self, repo_id, split, private, token, branch, max_shard_size, num_shards, embed_external_files)
   5273         shard.to_parquet(buffer)
   5274         uploaded_size += buffer.tell()
-> 5275         _retry(
   5276             api.upload_file,
   5277             func_kwargs={
   5278                 "path_or_fileobj": buffer.getvalue(),
   5279                 "path_in_repo": shard_path_in_repo,
   5280                 "repo_id": repo_id,
   5281                 "token": token,
   5282                 "repo_type": "dataset",
   5283                 "revision": branch,
   5284             },
   5285             exceptions=HTTPError,
   5286             status_codes=[504],
   5287             base_wait_time=2.0,
   5288             max_retries=5,
   5289             max_wait_time=20.0,
   5290         )
   5291     shards_path_in_repo.append(shard_path_in_repo)
   5293 # Cleanup to remove unused files

File ~/miniconda3/envs/hwocr/lib/python3.8/site-packages/datasets/utils/file_utils.py:285, in _retry(func, func_args, func_kwargs, exceptions, status_codes, max_retries, base_wait_time, max_wait_time)
    283 except exceptions as err:
    284     if retry >= max_retries or (status_codes and err.response.status_code not in status_codes):
--> 285         raise err
    286     else:
    287         sleep_time = min(max_wait_time, base_wait_time * 2**retry)  # Exponential backoff

File ~/miniconda3/envs/hwocr/lib/python3.8/site-packages/datasets/utils/file_utils.py:282, in _retry(func, func_args, func_kwargs, exceptions, status_codes, max_retries, base_wait_time, max_wait_time)
    280 while True:
    281     try:
--> 282         return func(*func_args, **func_kwargs)
    283     except exceptions as err:
    284         if retry >= max_retries or (status_codes and err.response.status_code not in status_codes):

File ~/miniconda3/envs/hwocr/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py:120, in validate_hf_hub_args.<locals>._inner_fn(*args, **kwargs)
    117 if check_use_auth_token:
    118     kwargs = smoothly_deprecate_use_auth_token(fn_name=fn.__name__, has_token=has_token, kwargs=kwargs)
--> 120 return fn(*args, **kwargs)

File ~/miniconda3/envs/hwocr/lib/python3.8/site-packages/huggingface_hub/hf_api.py:2998, in HfApi.upload_file(self, path_or_fileobj, path_in_repo, repo_id, token, repo_type, revision, commit_message, commit_description, create_pr, parent_commit)
   2990 commit_message = (
   2991     commit_message if commit_message is not None else f"Upload {path_in_repo} with huggingface_hub"
   2992 )
   2993 operation = CommitOperationAdd(
   2994     path_or_fileobj=path_or_fileobj,
   2995     path_in_repo=path_in_repo,
   2996 )
-> 2998 commit_info = self.create_commit(
   2999     repo_id=repo_id,
   3000     repo_type=repo_type,
   3001     operations=[operation],
   3002     commit_message=commit_message,
   3003     commit_description=commit_description,
   3004     token=token,
   3005     revision=revision,
   3006     create_pr=create_pr,
   3007     parent_commit=parent_commit,
   3008 )
   3010 if commit_info.pr_url is not None:
   3011     revision = quote(_parse_revision_from_pr_url(commit_info.pr_url), safe="")

File ~/miniconda3/envs/hwocr/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py:120, in validate_hf_hub_args.<locals>._inner_fn(*args, **kwargs)
    117 if check_use_auth_token:
    118     kwargs = smoothly_deprecate_use_auth_token(fn_name=fn.__name__, has_token=has_token, kwargs=kwargs)
--> 120 return fn(*args, **kwargs)

File ~/miniconda3/envs/hwocr/lib/python3.8/site-packages/huggingface_hub/hf_api.py:2548, in HfApi.create_commit(self, repo_id, operations, commit_message, commit_description, token, repo_type, revision, create_pr, num_threads, parent_commit)
   2546 try:
   2547     commit_resp = get_session().post(url=commit_url, headers=headers, data=data, params=params)
-> 2548     hf_raise_for_status(commit_resp, endpoint_name="commit")
   2549 except RepositoryNotFoundError as e:
   2550     e.append_to_message(_CREATE_COMMIT_NO_REPO_ERROR_MESSAGE)

File ~/miniconda3/envs/hwocr/lib/python3.8/site-packages/huggingface_hub/utils/_errors.py:301, in hf_raise_for_status(response, endpoint_name)
    297     raise BadRequestError(message, response=response) from e
    299 # Convert `HTTPError` into a `HfHubHTTPError` to display request information
    300 # as well (request id and/or server error message)
--> 301 raise HfHubHTTPError(str(e), response=response) from e

HfHubHTTPError: 403 Client Error: Forbidden for url: https://huggingface.co/api/datasets/agomberto/FrenchCensus-handwritten-texts/commit/main (Request ID: Root=1-645a66bf-255ad91602a6404e6cb70fba)

Forbidden: pass `create_pr=1` as a query parameter to create a Pull Request
```

And then when I do

```python
dataset.push_to_hub("agomberto/FrenchCensus-handwritten-texts", create_pr=1)
```

I get 

```python
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[8], line 1
----> 1 dataset.push_to_hub("agomberto/FrenchCensus-handwritten-texts", create_pr=1)

TypeError: push_to_hub() got an unexpected keyword argument 'create_pr'
```

### Expected behavior

I would like to have the dataset updloaded [here](https://huggingface.co/datasets/agomberto/FrenchCensus-handwritten-texts).

### Environment info

```bash
- `datasets` version: 2.12.0
- Platform: macOS-13.3.1-arm64-arm-64bit
- Python version: 3.8.16
- Huggingface_hub version: 0.14.1
- PyArrow version: 12.0.0
- Pandas version: 1.5.3
```