I developed a script which predicts some values and saves them into the predictions.csv file using github actions.
I then need to update the predictions.csv file on github, because i need to query it externaly.
But for some reason i get the bad credentials expection. Here is the part of the code which causes the exception.
# github credentials
owner = 'kmeans27'
repo = 'ball-classification'
branch = 'main'
path = 'output'
token = ""
# Push changes to GitHub
g = Github(token)
repo = g.get_repo(f"{owner}/{repo}")
branch = repo.get_branch(branch)
file_name = "predictions.csv"
file_path = f"{path}/{file_name}"
contents = repo.get_contents(file_path, ref=branch.name)
with open(csv_path, "r") as file:
content = file.read()
if contents:
repo.update_file(contents.path, f'Update {file_name}', content, contents.sha, branch=branch.name)
else:
repo.create_file(file_path, f'Add {file_name}', content, branch=branch.name)
here is the link for the github repo: https://github.com/kmeans27/ball-classification owner and repo name should be correct or am i missing something? The rights I set for the github token are: repo (all of them) and read:user
This is the error message im getting:
Traceback (most recent call last):
File "/home/runner/work/ball-classification/ball-classification/batch_predict.py", line 59, in <module>
repo = g.get_repo(f"{owner}/{repo}")
File "/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/github/MainClass.py", line 321, in get_repo
headers, data = self.__requester.requestJsonAndCheck("GET", url)
File "/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/github/Requester.py", line 400, in requestJsonAndCheck
return self.__check(
File "/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/github/Requester.py", line 425, in __check
raise self.__createException(status, responseHeaders, output)
github.GithubException.BadCredentialsException: 401 {"message": "Bad credentials", "documentation_url": "https://docs.github.com/rest"}
Error: Process completed with exit code 1.
Thank you for your valuable time!