Files
TinyTorch/scripts/generate_module_metadata.py
Vijay Janapa Reddi eed32f4e0d Reorganize repository structure and add build tooling
## Repository Organization
- Move scripts from bin/ to scripts/ directory
  - activate-tinytorch: Environment activation script
  - generate_module_metadata.py: Module metadata generator
  - generate_student_notebooks.py: Student notebook generator
  - tito: TinyTorch CLI tool

## Build System
- Add site/build.sh: Jupyter Book 1.x build automation script
  - Auto-detects project root or site directory
  - Activates virtual environment if available
  - Handles clean builds with proper error handling

## Documentation
- Add docs/history/ for migration documentation
  - ROLLBACK_TO_JB1.md: Jupyter Book 1.x rollback documentation
  - MIGRATION_TO_V2.md: Jupyter Book 2.0 migration attempt notes

## Infrastructure Updates
- Update all site/modules/*_ABOUT.md symlinks: modules/ → src/
- Update all src/*/ABOUT.md symlinks: modules/ → src/
- Update .envrc: Reflect new scripts/ directory structure
- Update pyproject.toml: Add build system dependencies

This commit completes the src-modules separation restructuring and
adds necessary tooling for the new repository layout.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-25 11:29:41 -05:00

71 lines
1.9 KiB
Python

#!/usr/bin/env python3
"""
Generate module.yaml metadata template for TinyTorch modules.
"""
import argparse
import sys
from pathlib import Path
def generate_metadata_template(module_name: str) -> str:
"""Generate a simplified module metadata template."""
template = f"""# TinyTorch Module Metadata
# Essential system information for CLI tools and build systems
name: "{module_name}"
title: "{module_name.title()}"
description: "Brief description of what this module does"
# Dependencies
dependencies:
prerequisites: [] # e.g., ["setup", "tensor"]
enables: [] # e.g., ["layers", "networks"]
# Package Export
exports_to: "tinytorch.core.{module_name}"
# File Structure
files:
dev_file: "{module_name}.py"
test_file: "tests/test_{module_name}.py"
readme: "README.md"
# Components
components:
- "component1"
- "component2"
- "component3"
"""
return template.strip()
def main():
parser = argparse.ArgumentParser(description="Generate module metadata template")
parser.add_argument("module_name", help="Name of the module")
parser.add_argument("--output", help="Output file path (default: modules/{module_name}/module.yaml)")
args = parser.parse_args()
# Generate template
template = generate_metadata_template(args.module_name)
# Determine output path
if args.output:
output_path = Path(args.output)
else:
output_path = Path("modules") / args.module_name / "module.yaml"
# Create directory if it doesn't exist
output_path.parent.mkdir(parents=True, exist_ok=True)
# Write template
with open(output_path, 'w') as f:
f.write(template)
print(f"✅ Generated metadata template: {output_path}")
print(f"📝 Edit the file to customize the module information")
print(f"💡 Module status will be determined automatically by test results")
if __name__ == "__main__":
main()