Upload Error when api.upload_file
Hello,I am new to the HuggingFace space API and I am currently attempting to upload a file to my existing model repository using the upload_file API. My upload part is as below:try:
    api.upload_file(
        path_or_fileobj="/home/user/app/tmp/test.zip",
        path_in_repo="test.zip",
        repo_id="emmajoanne/models",
        repo_type="model",
    )
except:
    return "Upload error!"It always falls into the except but doesn’t provide any more details.From the official document (Upload files to the Hub) I don’t see any error handling information or what exceptions it throws.Appreciate.
2023-01-25T03:45:46Z
hi@emmajoanne, what’s the error message? do you have the write access token? have you login before attempting to write on your repo?huggingface.coQuickstartWe’re on a journey to advance and democratize artificial intelligence through open source and open science.huggingface.coHugging Face – The AI community building the future.We’re on a journey to advance and democratize artificial intelligence through open source and open science.
2023-01-25T05:17:49Z
Thank you for your response.I was able to locate the error message by printing out theBaseException as e. The problem is related to unauthorized access. From this error, I was able to determine that the root cause is an issue with the way I initialized the api lib.So I updated my code from:api = HfApi(token)to :api = HfApi(token=token)Then, problem solved.