IDEALFT_OXT / tools /oxt_hf_write_access.py
Alan0928's picture
Apply OXT final-review name, directory, metadata and gripper-area corrections
cc98837 verified
Raw History Blame Contribute Delete
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)