Download fix_visibility.py from coderdecoder01/retirement-invitation-mamta: direct link, hf CLI and curl.
- Browser
- Download file 1.75 kB
-
https://huggingface.co/datasets/coderdecoder01/retirement-invitation-mamta/resolve/main/fix_visibility.py
- Command line
-
hf download hf://datasets/coderdecoder01/retirement-invitation-mamta/fix_visibility.py
-
curl -L -o fix_visibility.py https://huggingface.co/datasets/coderdecoder01/retirement-invitation-mamta/resolve/main/fix_visibility.py
1.75 kB
| """Make the invitation dataset repo public so the MP4 link works without login.""" | |
| import os | |
| import requests | |
| from huggingface_hub import HfApi | |
| R = "coderdecoder01/retirement-invitation-mamta" | |
| t = os.environ["HF_TOKEN"] | |
| h = {"Authorization": "Bearer " + t} | |
| api = HfApi() | |
| def vis(repo=R): | |
| try: | |
| r = requests.get("https://huggingface.co/api/datasets/" + repo, headers=h, timeout=60) | |
| return r.json().get("private") | |
| except Exception as e: | |
| return "? %s" % repr(e)[:80] | |
| print("before:", vis(), flush=True) | |
| try: | |
| api.update_repo_settings(repo_id=R, repo_type="dataset", private=False) | |
| print("update_repo_settings: OK", flush=True) | |
| except Exception as e: | |
| print("update_repo_settings FAIL:", repr(e)[:300], flush=True) | |
| print("after1:", vis(), flush=True) | |
| if vis() is not False: | |
| r = requests.patch("https://huggingface.co/api/datasets/%s/settings" % R, headers=h, | |
| json={"private": False}, timeout=60) | |
| print("PATCH /settings:", r.status_code, r.text[:300], flush=True) | |
| print("after2:", vis(), flush=True) | |
| if vis() is not False: | |
| r = requests.post("https://huggingface.co/api/datasets/%s/settings" % R, headers=h, | |
| json={"private": False}, timeout=60) | |
| print("POST /settings:", r.status_code, r.text[:300], flush=True) | |
| print("after3:", vis(), flush=True) | |
| if vis() is not False: | |
| try: | |
| api.create_repo(repo_id="coderdecoder01/retirement-invite-mamta-public", repo_type="dataset", | |
| private=False, exist_ok=True) | |
| print("new repo private:", vis("coderdecoder01/retirement-invite-mamta-public"), flush=True) | |
| except Exception as e: | |
| print("create public repo FAIL:", repr(e)[:300], flush=True) | |