-
Notifications
You must be signed in to change notification settings - Fork 487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong case of repo_id
when using upload_folder
or upload_file
causes unpredictable error displayed
#1371
Comments
Hi @ddPn08 , thanks for reporting the issue. I ran
and the script got uploaded to the Hub: https://huggingface.co/Wauplin/1371-GH-issue-upload-file/blob/main/hf_upload.py What command line are you using? |
I tested fish and powershell on different machines, but it didn't work. |
Hi @ddPn08, just to be sure, when you say "it didn't work", is it with the exact same error. I don't really know why this is failing so let's try a simple script. Can you save this script in a file named import huggingface_hub
print(huggingface_hub.__version__)
# Create repo
api = huggingface_hub.HfApi()
repo_url = api.create_repo(repo_id="test_repo_1371", exist_ok=True)
repo_id = repo_url.repo_id
print(f"Created repo {repo_id}")
# Upload regular file from bytes
print("Upload file.txt")
api.upload_file(path_in_repo="file.txt", path_or_fileobj=b"content", repo_id=repo_id)
# Upload LFS file from bytes
print("Upload lfs.bin")
api.upload_file(path_in_repo="lfs.bin", path_or_fileobj=b"content", repo_id=repo_id)
# Upload from disk file
print("Upload test_issue_1371.py")
api.upload_file(path_in_repo="test_issue_1371.py", path_or_fileobj="test_issue_1371.py", repo_id=repo_id) You should have an output like this. Can you confirm?
|
Ok good, that's what it's suppose to do. Now can you change the last line to upload the file you were trying to uploading with your initial script. I.e. run something like that: import huggingface_hub
# Create repo
api = huggingface_hub.HfApi()
repo_url = api.create_repo(repo_id="test_repo_1371", exist_ok=True)
repo_id = repo_url.repo_id
print(f"Created repo {repo_id}")
# Upload from disk file
api.upload_file(path_in_repo="example_file.bin", path_or_fileobj="example_file.bin", repo_id=repo_id) and change |
import os
import argparse
from huggingface_hub import HfApi
api = HfApi()
def upload(args: argparse.Namespace):
src = args.src
dest = args.dest
repo_id = args.repo_id
repo_type = args.repo_type
ignore_patterns = args.ignore_patterns
assert os.path.exists(src), "Source is not exists."
repo_url = api.create_repo(repo_id=repo_id, exist_ok=True)
repo = repo_url.repo_id
if os.path.isfile(src):
api.upload_file(
path_or_fileobj=src,
path_in_repo=dest,
repo_id=repo,
repo_type=repo_type
)
else:
api.upload_folder(
folder_path=src,
path_in_repo=dest,
repo_id=repo,
repo_type=repo_type,
ignore_patterns=ignore_patterns
)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("src", type=str)
parser.add_argument("dest", type=str)
parser.add_argument("--ignore_patterns", type=str)
parser.add_argument("--repo-id", type=str, default="mydataset")
parser.add_argument("--repo-type", type=str, default="dataset")
args = parser.parse_args()
upload(args) I don't know why, but I fixed it by rewriting the code. I get the same error when I put it back. It's strange. |
Hmm... code is really the same. I don't know what else has changed but glad that at least your issue has been solved. Is it ok with you to close it now? Small detail in your latest script, you must be careful to take the repo_url = api.create_repo(repo_id=repo_id, repo_type=repo_type, exist_ok=True) # repo_type was missing here
repo = repo_url.repo_id |
It was a very stupid mistake. |
I thought this fixed it, but maybe I'm wrong? At least the problem is no longer reproducible. |
If the |
Oooh, good to know. Thanks for spotting this. So yes, let's keep it open and if you don't mind I'll update the issue title. |
repo_id
causes unpredictable error displayed
repo_id
causes unpredictable error displayedrepo_id
when using upload_folder
and upload_file
causes unpredictable error displayed
repo_id
when using upload_folder
and upload_file
causes unpredictable error displayedrepo_id
when using upload_folder
or upload_file
causes unpredictable error displayed
@ddPn08 For your info, I opened a PR to fix this. Will be published in next release. |
@ddPn08 problem is fixed! Thanks for reporting :) |
Describe the bug
I get the following error when I run the upload_folder or upload_file function.
Reducing the size of the data made no difference.
Reproduction
Use this code as below
Logs
The text was updated successfully, but these errors were encountered: