Datasets:
Formats:
parquet
Size:
10K - 100K
Download python-balanced-20261007/provenance/publish.py from lightonai/SASS-Post-Training-Dataset: direct link, hf CLI and curl.
- Browser
- Download file 10.1 kB
-
https://huggingface.co/datasets/lightonai/SASS-Post-Training-Dataset/resolve/main/python-balanced-20261007/provenance/publish.py
- Command line
-
hf download hf://datasets/lightonai/SASS-Post-Training-Dataset/python-balanced-20261007/provenance/publish.py
-
curl -L -o publish.py https://huggingface.co/datasets/lightonai/SASS-Post-Training-Dataset/resolve/main/python-balanced-20261007/provenance/publish.py
10.1 kB
| """Publish only unfiltered SFT configurations and the shared RL corpus.""" | |
| from pathlib import Path | |
| import argparse, json, hashlib, yaml, tarfile | |
| from huggingface_hub import HfApi, hf_hub_download, CommitOperationAdd, CommitOperationCopy, CommitOperationDelete | |
| from datasets import load_dataset | |
| parser=argparse.ArgumentParser();parser.add_argument('--baseline-only',action='store_true');args=parser.parse_args() | |
| BASE=Path(__file__).resolve().parent;api=HfApi();repo='lightonai/SASS-Data' | |
| prep=json.loads((BASE/'preparation.json').read_text()) | |
| report=None | |
| if not args.baseline_only: | |
| import subprocess,sys | |
| subprocess.run([sys.executable,str(BASE/'export.py')],check=True) | |
| report=json.loads((BASE/'release/generation-report.json').read_text()) | |
| for arm in ['grep','colgrep']: | |
| assert report['arms'][arm]['unfiltered']['total_rows']==14500 | |
| complete=json.loads((BASE/arm/'COMPLETE.json').read_text()) | |
| for f,h in report['new_files_sha256'].items(): | |
| if '/unfiltered/' in f: assert hashlib.sha256((BASE/'release'/f).read_bytes()).hexdigest()==h | |
| info=api.dataset_info(repo,files_metadata=True);assert info.private | |
| remote={f.rfilename:f for f in info.siblings} | |
| cache=str(BASE/'publish-cache');stage=BASE/('baseline-publication' if args.baseline_only else 'publication');stage.mkdir(exist_ok=True) | |
| ops=[];expected={};configs=[];sources=[];counts={} | |
| source_specs=[('grep-python',prep['baseline']['grep']['repo'],prep['baseline']['grep']['revision']),('colgrep-python',prep['baseline']['colgrep']['repo'],prep['baseline']['colgrep']['revision']),('grep-multi','lightonai/code-search-Deepseek-Grep-Multi-SFT','5ccc5e2e1a35fba0ec9567775568fd84333538b8'),('colgrep-multi','lightonai/code-search-Deepseek-ColGrep-Multi-SFT','5980dc519832a48b5685b859b640f1abd70bb017')] | |
| for label,src,revision in source_specs: | |
| source=api.dataset_info(src,revision=revision,files_metadata=True);assert source.private | |
| card=Path(hf_hub_download(src,'README.md',repo_type='dataset',revision=source.sha,cache_dir=cache)).read_text() | |
| smeta=yaml.safe_load(card.split('---',2)[1]) | |
| stat=next(c for c in smeta['dataset_info'] if c['config_name']=='unfiltered') | |
| count=next(s['num_examples'] for s in stat['splits'] if s['name']=='train') | |
| shards=[] | |
| for f in source.siblings: | |
| if not (f.rfilename.startswith('unfiltered/') and f.rfilename.endswith('.parquet')):continue | |
| dst=f'sources/{label}/{f.rfilename}';shards.append(dst) | |
| expected[dst]=f.lfs.sha256 if f.lfs else f.blob_id | |
| if dst in remote:assert (remote[dst].lfs.sha256 if remote[dst].lfs else remote[dst].blob_id)==expected[dst],dst | |
| else:ops.append(CommitOperationCopy(src_path_in_repo=f.rfilename,path_in_repo=dst,src_revision=source.sha,src_repo_id=src,src_repo_type='dataset')) | |
| assert shards | |
| if report and label.endswith('python'): | |
| arm=label.split('-')[0];count=report['arms'][arm]['unfiltered']['total_rows'] | |
| for p in sorted((BASE/'release'/label/'unfiltered').glob('*.parquet')): | |
| dst='python-balanced-20261007/'+str(p.relative_to(BASE/'release'));shards.append(dst) | |
| expected[dst]=hashlib.sha256(p.read_bytes()).hexdigest() | |
| ops.append(CommitOperationAdd(path_in_repo=dst,path_or_fileobj=str(p))) | |
| name=label+'-unfiltered';counts[name]=count | |
| configs.append({'config_name':name,'data_files':[{'split':'sft','path':sorted(shards)}]}) | |
| sources.append({'configuration':name,'source_repo':src,'revision':source.sha,'baseline_rows':next(s['num_examples'] for s in stat['splits'] if s['name']=='train')}) | |
| configs.append({'config_name':'rl-multi','data_files':[{'split':'rl','path':'rl/rl-*.parquet'}]});counts['rl-multi']=10899 | |
| # Remove the superseded weighted/filtered files from the current revision only. | |
| removed=[] | |
| for name in remote: | |
| parts=name.split('/') | |
| remove=name.startswith(('grep/sft-','colgrep/sft-','raw/')) | |
| if name.startswith('sources/'): | |
| remove=not (len(parts)>3 and parts[2]=='unfiltered' and name.endswith('.parquet')) | |
| if name.startswith('python-balanced-20261007/') and name.endswith('.parquet'): | |
| remove='/unfiltered/' not in name | |
| if remove:ops.append(CommitOperationDelete(path_in_repo=name));removed.append(name) | |
| body='''\n# SASS training data\n\nUnfiltered DeepSeek SFT trajectories for four search/language setups, plus the shared multilingual RL task corpus. This repository contains no weighted or localization-filtered SFT subsets.\n\n| Configuration | Split | Rows |\n|---|---|---:|\n''' | |
| for name,count in counts.items():body+=f'| `{name}` | `{"rl" if name=="rl" else "sft"}` | {count:,} |\n' | |
| body+='''\n```python\nfrom datasets import load_dataset\nsft = load_dataset("lightonai/SASS-Data", "colgrep-python-unfiltered", split="sft", token=True)\nrl = load_dataset("lightonai/SASS-Data", "rl-multi", split="rl", token=True)\n```\n\nThe `rl-multi` configuration contains the same 10,899 source tasks used for both GREP and ColGREP RL: problem statements, repositories, base commits and gold file/line spans, not policy rollouts. It replaces the duplicated `rl` splits formerly nested under `grep` and `colgrep`. Those two ambiguous configurations previously exposed weighted multilingual SFT and have been removed. RL files are unchanged; SFT-only columns in their shared nullable schema are null.\n\n## Provenance\n\nSFT source revisions and checksums are recorded in `release-manifest.json`. Unfiltered source rows are retained without applying localization-quality filters or turn weighting. The original source repositories still provide the weighted and filtered variants used for the paper's existing checkpoints; removing those copies here does not alter any model or source repository.\n\nRL comes from `lightonai/code-search-corpus-RL-multi` at revision `47af6636335e5515be3e9b50cd673ca1940c2d79` (33 repositories, eight languages). Both historical RL environment logs confirm that `indexed_only=true` retained all 10,899/10,899 source tasks. All source tasks were eligible; eligibility does not imply that every task was sampled during the finite training run.\n\nPython generation preserves its archived harness lifecycle (ten search turns, a reminder, two finish-only turns and rescue). Multilingual v2 uses a hard ten-response cap and stricter protocol cleaning. Matching unfiltered counts does not remove these existing protocol differences. ColGREP Python unfiltered trajectories retain their strict teacher prompt. `protocols/` contains historical student protocols; the packaged ColGREP protocol differs from the printed Appendix A.6 prompt. Source/model terms continue to apply.\n''' | |
| if report: | |
| body+='''\n## Python count-matching extension\n\nBoth Python setups now contain 14,500 unfiltered trajectories. Added trajectories were generated with DeepSeek-V4-Flash-0731 using the frozen Python harness, temperature 0.3, thinking disabled, and existing decontaminated tasks screened against original Python tasks and evaluation overlap. Candidate tasks, generation manifests, frozen runtime and added-shard hashes are retained under `python-balanced-20261007/`. These additions postdate the reported paper experiments and were not used by the existing checkpoints.\n''' | |
| else: | |
| body+='\nPython top-up generation is still running toward 14,500 unfiltered rows per setup. The counts above describe the currently published data.\n' | |
| manifest={'layout':'unfiltered-sft-and-shared-rl-v1','sources':sources,'counts':counts,'sft_sha256':expected,'rl_source':{'repo':'lightonai/code-search-corpus-RL-multi','revision':'47af6636335e5515be3e9b50cd673ca1940c2d79'},'previous_release_commit':info.sha} | |
| if report: | |
| manifest['python_extension']={'counts':{a:report['arms'][a]['unfiltered'] for a in ['grep','colgrep']},'not_used_by_existing_paper_checkpoints':True} | |
| for arm in ['grep','colgrep']: | |
| for name in ['generation-manifest.json','COMPLETE.json']: | |
| ops.append(CommitOperationAdd(path_in_repo=f'python-balanced-20261007/provenance/{arm}-{name}',path_or_fileobj=str(BASE/arm/name))) | |
| archive=stage/'frozen-runtime.tar.gz' | |
| with tarfile.open(archive,'w:gz') as tar: | |
| for p in sorted((BASE/'runtime').rglob('*.py')):tar.add(p,arcname=str(p.relative_to(BASE))) | |
| ops.append(CommitOperationAdd(path_in_repo='python-balanced-20261007/provenance/frozen-runtime.tar.gz',path_or_fileobj=str(archive))) | |
| for name in ['tasks.jsonl','preparation.json','generate.py','export.py','run.sbatch','publish.py']: | |
| ops.append(CommitOperationAdd(path_in_repo='python-balanced-20261007/provenance/'+name,path_or_fileobj=str(BASE/name))) | |
| meta={'language':['en'],'tags':['code','code-search','sft','reinforcement-learning'],'configs':configs} | |
| (stage/'README.md').write_text('---\n'+yaml.safe_dump(meta,sort_keys=False)+'---\n'+body) | |
| (stage/'release-manifest.json').write_text(json.dumps(manifest,indent=2)+'\n') | |
| for name in ['README.md','release-manifest.json']:ops.append(CommitOperationAdd(path_in_repo=name,path_or_fileobj=str(stage/name))) | |
| (stage/'plan.json').write_text(json.dumps({'parent_commit':info.sha,'counts':counts,'removed':removed,'operations':len(ops)},indent=2)) | |
| commit=api.create_commit(repo,repo_type='dataset',parent_commit=info.sha,operations=ops,commit_message='Keep four unfiltered SFT configurations and expose shared RL explicitly') | |
| receipt={'repo':repo,'commit':commit.oid,'counts':counts,'private':True,'removed_files':removed} | |
| receipt_path=BASE/('baseline-publication-receipt.json' if args.baseline_only else 'publication-receipt.json') | |
| receipt_path.write_text(json.dumps(receipt,indent=2)+'\n');print('Published',commit.oid,flush=True) | |
| after=api.dataset_info(repo,revision=commit.oid,files_metadata=True);assert after.private | |
| files={f.rfilename:f for f in after.siblings} | |
| for name,h in expected.items():assert (files[name].lfs.sha256 if files[name].lfs else files[name].blob_id)==h,name | |
| assert not set(removed)&set(files) | |
| for name,count in counts.items(): | |
| ds=load_dataset(repo,name,split='rl' if name=='rl-multi' else 'sft',revision=commit.oid,token=True,cache_dir=str(BASE/'remote-validation-cache')) | |
| assert len(ds)==count,(name,len(ds),count) | |
| assert len(set(ds['instance_id']))==len(ds),name | |
| print('Verified',name,len(ds),flush=True) | |
| receipt['hashes_counts_uniqueness_verified']=True | |
| receipt_path.write_text(json.dumps(receipt,indent=2)+'\n') | |