mirror of
https://github.com/open-thought/reasoning-gym.git
synced 2026-04-29 17:35:16 +00:00
feat: Add dataset gallery markdown generator script
This commit is contained in:
parent
2ec8a1bcbb
commit
9b023cc4c6
2 changed files with 64 additions and 30 deletions
63
python
Normal file
63
python
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
"""Generate a markdown gallery of all available datasets with examples"""
|
||||
|
||||
from pathlib import Path
|
||||
import textwrap
|
||||
|
||||
from reasoning_gym.factory import DATASETS, create_dataset
|
||||
|
||||
|
||||
def generate_gallery() -> str:
|
||||
"""Generate markdown content for the gallery"""
|
||||
|
||||
# Start with header
|
||||
content = ["# Dataset Gallery\n"]
|
||||
|
||||
# Add index
|
||||
content.append("## Available Datasets\n")
|
||||
for name in sorted(DATASETS.keys()):
|
||||
# Create anchor link
|
||||
anchor = name.replace("_", "-")
|
||||
content.append(f"- [{name}](#{anchor})\n")
|
||||
content.append("\n")
|
||||
|
||||
# Add examples for each dataset
|
||||
content.append("## Examples\n")
|
||||
for name in sorted(DATASETS.keys()):
|
||||
dataset = create_dataset(name)
|
||||
|
||||
# Add dataset header
|
||||
content.append(f"### {name}\n")
|
||||
|
||||
# Get dataset class docstring if available
|
||||
if dataset.__class__.__doc__:
|
||||
doc = textwrap.dedent(dataset.__class__.__doc__.strip())
|
||||
content.append(f"{doc}\n")
|
||||
|
||||
content.append("```\n")
|
||||
# Show 3 examples
|
||||
for i, item in enumerate(dataset):
|
||||
if i >= 3:
|
||||
break
|
||||
content.append(f"Example {i+1}:\n")
|
||||
content.append(f"Question: {item['question']}\n")
|
||||
content.append(f"Answer: {item['answer']}\n")
|
||||
content.append(f"Metadata: {item['metadata']}\n")
|
||||
content.append("\n")
|
||||
content.append("```\n\n")
|
||||
|
||||
return "".join(content)
|
||||
|
||||
|
||||
def main():
|
||||
"""Generate gallery markdown file"""
|
||||
gallery_path = Path(__file__).parent.parent / "GALLERY.md"
|
||||
gallery_content = generate_gallery()
|
||||
|
||||
with open(gallery_path, "w") as f:
|
||||
f.write(gallery_content)
|
||||
|
||||
print(f"Generated gallery at {gallery_path}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue