create-hf-dataset-pr
Skill329 starsChanged 7 days agoMIT-0View on GitHub
Use when contributing a data or label correction to an external HuggingFace dataset through a community PR: parquet key order, verification and review artefacts.
- Installs packages
In this repository42 other files it gives its agents.
- .claude/rules/agents.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- add-modelSkill
- agent-capability-reviewSkill
- api-rbac-testSkill
- backend-lambdaSkill
- code-reviewSkill
- curate-security-resultsSkill
- cut-release-changelogSkill
- dependabot-prsSkill
- documentationSkill
- extraction-pipelineSkill
- fix-single-issueSkill
- frontend-uiSkill
- full-test-batterySkill
- infrastructureSkill
- live-auth-checksSkill
- live-eval-and-costSkill
- prepare-changelogSkill
- prep-develop-for-releaseSkill
- product-demoSkill
- pr-review-ciSkill
- pr-reviewSkill
- releaseSkill
- release-validationSkill
- remove-classification-flat-keysSkill
- repo-quality-reviewSkill
- run-benchmarksSkill
- run-stack-testsSkill
- srt-security-scanSkill
- sync-pii-anonymizerSkill
- testing-qaSkill
- test-upgradeSkill
- transform-deploy-testSkill
- ui-i18nSkill
- update-solution-profileSkill
- ux-test-ciSkill
- ux-testSkill
- ux-test-stories-ciSkill
- ux-test-storiesSkill
- work-the-backlog-hazardsSkill
- work-the-backlogSkill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 2 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 8
Use when contributing a data or label correction to an external HuggingFace dataset repo via a community Pull Request.
- Distinctive: line 18
Remind the user to rotate the token afterward: if it ever appeared in chat.
- Very specific: line 19
Verify identity first: python3 -c "from huggingface_hub import whoami.
- Distinctive: line 24
Check the dataset LICENSE permits redistributing modified labels (e.g.
- Very specific: line 33
NOT loose JSON. The naive pd.read_parquet → edit dicts → df.to_parquet round-trip
- Very specific: line 35
EVERY struct column (e.g. an untouched json_schema column).
- Very specific: line 79
Add follow-up files to the SAME PR branch with revision="refs/pr/N".
- Very specific: line 88
Add an in-tree corrections/ folder on the PR branch:
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Skill: Create a HuggingFace dataset PR (corrections / data changes)
Use when contributing a data or label correction to an external HuggingFace
dataset repo via a community Pull Request. Written from the RealKIE-FCC-Verified
GT-audit PR (see memory project-realkie-gt-audit-pr).
Prerequisites
pip install huggingface_hub pandas pyarrow(usually already present).- A write-scoped HF token. Do NOT hardcode it. Prefer:
huggingface-cli login(interactive; token stays out of the transcript), orexport HF_TOKEN=hf_...for the command only.
- Remind the user to rotate the token afterward if it ever appeared in chat.
- Verify identity first:
python3 -c "from huggingface_hub import whoami; print(whoami()['name'])".
Guardrails (this is an outward-facing, hard-to-reverse action)
- Get explicit user approval before pushing anything to an external public repo.
- Check the dataset LICENSE permits redistributing modified labels (e.g. CC-BY-NC allows derivatives w/ attribution + non-commercial).
- You almost never have write access to
mainof someone else's repo — you can only open a PR (create_pr=True/ uploading torevision="refs/pr/N"). You cannot self-merge; it lands only when a maintainer merges.
The critical gotcha: Parquet key/struct-order churn
Dataset GT usually lives inside a binary Parquet column (e.g. json_response),
NOT loose JSON. The naive pd.read_parquet → edit dicts → df.to_parquet round-trip
alphabetically reorders JSON object keys and Arrow struct fields on EVERY row of
EVERY struct column (e.g. an untouched json_schema column). Semantically harmless
(key order isn't significant) but it makes the diff huge and contradicts a
"only N cells changed" claim.
Fix — edit at the pyarrow level and preserve the original struct type:
import pyarrow as pa, pyarrow.parquet as pq, json
t = pq.read_table("orig.parquet")
resp = t.column("json_response").to_pylist() # list of dicts
resp_type = t.schema.field("json_response").type # <-- reuse to preserve field order
# ... mutate resp in place, asserting each old value matches before writing new ...
new = pa.array(resp, type=resp_type)
t2 = t.set_column(t.column_names.index("json_response"), "json_response", new)
pq.write_table(t2, "corrected.parquet")
# leaves id/text/json_schema/image_files as the ORIGINAL untouched arraysVerify the diff is EXACTLY what you claim (before AND after upload)
Download both revisions and diff cell-by-cell — don't trust list_repo_files
(it lists the whole tree, not the diff):
a = pd.read_parquet(f"hf://datasets/{repo}@main/data/....parquet")
b = pd.read_parquet(f"hf://datasets/{repo}@refs/pr/{N}/data/....parquet")
# assert only the intended (id,row,field) cells differ; all other columns byte-identical
# (normalize numpy types + sort_keys when comparing struct/schema columns)Submit
from huggingface_hub import HfApi
api = HfApi()
commit = api.upload_file(
path_or_fileobj="corrected.parquet",
path_in_repo="data/test-00000-of-00001.parquet",
repo_id=repo, repo_type="dataset",
commit_message=TITLE, commit_description=BODY, # BODY is the PR writeup
create_pr=True, # opens PR, returns .pr_url
)- Add follow-up files to the SAME PR branch with
revision="refs/pr/N". - Comment:
api.comment_discussion(repo_id, repo_type="dataset", discussion_num=N, comment=...) - Edit description/comment:
api.edit_discussion_comment(..., comment_id=..., new_content=...) - Status check:
api.get_discussion_details(...)→.statusisdraft|open|closed|merged.open= fully submitted (not a draft);draftis a separate WIP state.
Make a binary PR reviewable
A binary Parquet renders as "Binary file not shown" — reviewers can't see the change.
Add an in-tree corrections/ folder on the PR branch:
CORRECTIONS.md— human-readable before→after table with per-edit evidenceMANIFEST.json— machine-readable{doc,row,field,old,new,evidence}- a unified diff of pretty-printed records
- optional review images (bbox-annotated page renders). For scanned PDFs (no text
layer) you can't use PyMuPDF
search_for; OCR each page with Textract (boto3, raw bytes — the AWS CLI double-encodes and fails) and box the value via word geometry. Caveat: when a value repeats in a table the box marks an instance, not the exact row.
Common failures
whoamithrows / "Not authenticated" → no token set.- AWS CLI
textract detect-document-text --document '{"Bytes":"..."}'→ double-encodes; use boto3 with raw file bytes instead. - Stray output files from a crashed run polluting a glob (e.g. an extra
*.pdf.json) → re-verify counts after cleanup.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

