Spaces:
Runtime error
Runtime error
Download utils.py from DataAnalyticsLab/Sorvad: direct link, hf CLI and curl.
- Browser
- Download file 978 Bytes
-
https://huggingface.co/spaces/DataAnalyticsLab/Sorvad/resolve/main/utils.py
- Command line
-
hf download hf://spaces/DataAnalyticsLab/Sorvad/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/DataAnalyticsLab/Sorvad/resolve/main/utils.py
978 Bytes
| import subprocess | |
| from huggingface_hub.repository import _lfs_log_progress | |
| def force_git_push( | |
| repo, | |
| ): | |
| """ | |
| force a simple git push | |
| Blocking. Will return url to commit on remote | |
| repo. | |
| """ | |
| command = "git push --force" | |
| try: | |
| with _lfs_log_progress(): | |
| process = subprocess.Popen( | |
| command.split(), | |
| stderr=subprocess.PIPE, | |
| stdout=subprocess.PIPE, | |
| encoding="utf-8", | |
| cwd=repo.local_dir, | |
| ) | |
| stdout, stderr = process.communicate() | |
| return_code = process.poll() | |
| process.kill() | |
| if len(stderr): | |
| print(stderr) | |
| if return_code: | |
| raise subprocess.CalledProcessError(return_code, process.args, output=stdout, stderr=stderr) | |
| except subprocess.CalledProcessError as exc: | |
| raise EnvironmentError(exc.stderr) | |
| return repo.git_head_commit_url() | |