Download tools/oxt_hf_write_access.py from Alan0928/IDEALFT_OXT: direct link, hf CLI and curl.
- Browser
- Download file 1.22 kB
-
https://huggingface.co/datasets/Alan0928/IDEALFT_OXT/resolve/main/tools/oxt_hf_write_access.py
- Command line
-
hf download hf://datasets/Alan0928/IDEALFT_OXT/tools/oxt_hf_write_access.py
-
curl -L -o oxt_hf_write_access.py https://huggingface.co/datasets/Alan0928/IDEALFT_OXT/resolve/main/tools/oxt_hf_write_access.py
1.22 kB
| """Preflight permission to upload to the dataset's main branch. | |
| This module imports no Hub SDK until called. The small, already-verified | |
| manifest is checked through the normal preupload API with ``create_pr=False``; | |
| no commit is created. The frozen dataset attributes keep JSON in regular Git, | |
| so this preflight does not upload the large dataset files. | |
| """ | |
| def check_write_access(api, repo_id, checked, network): | |
| """Check write access even when a prior run already committed provenance.""" | |
| from huggingface_hub import CommitOperationAdd | |
| def preflight(): | |
| # The SDK mutates additions. Reconstruct on every retry so cached | |
| # upload-mode/uploaded flags cannot accidentally bypass the API check. | |
| addition = CommitOperationAdd( | |
| path_in_repo="upload_manifest.json", | |
| path_or_fileobj=checked["folder"] / "upload_manifest.json", | |
| ) | |
| return api.preupload_lfs_files( | |
| repo_id=repo_id, | |
| additions=[addition], | |
| repo_type="dataset", | |
| revision="main", | |
| create_pr=False, | |
| num_threads=1, | |
| free_memory=False, | |
| ) | |
| return network.call("Check dataset write access", preflight) | |