Spaces:
Paused
Paused
Download utils/common.py from ljm565-org/H-AdminSim_Arena: direct link, hf CLI and curl.
- Browser
- Download file 861 Bytes
-
https://huggingface.co/spaces/ljm565-org/H-AdminSim_Arena/resolve/main/utils/common.py
- Command line
-
hf download hf://spaces/ljm565-org/H-AdminSim_Arena/utils/common.py
-
curl -L -o common.py https://huggingface.co/spaces/ljm565-org/H-AdminSim_Arena/resolve/main/utils/common.py
861 Bytes
| import os | |
| from github import Github | |
| from dotenv import load_dotenv | |
| from utils import log | |
| def upload_to_github(file_path, content): | |
| load_dotenv(override=True) | |
| g = Github(os.getenv("GITHUB_TOKEN")) | |
| repo = g.get_repo("ljm565/adminsim-human-eval") | |
| try: | |
| contents = None | |
| try: | |
| contents = repo.get_contents(file_path, ref="main") | |
| except Exception: | |
| pass | |
| if contents is None: | |
| repo.create_file(file_path, "feat: Add new results", content, branch="main") | |
| log(f"File created successfully at {file_path}!") | |
| else: | |
| repo.update_file(file_path, "feat: Update the results", content, contents.sha, branch="main") | |
| log(f"File updated successfully at {file_path}!") | |
| except Exception as e: | |
| log(f"An error occurred: {e}", level="error") |