Files
TinyTorch/tito/commands/system.py
Vijay Janapa Reddi 85cf03be15 feat: Implement comprehensive student protection system for TinyTorch
🛡️ **CRITICAL FIXES & PROTECTION SYSTEM**

**Core Variable/Tensor Compatibility Fixes:**
- Fix bias shape corruption in Adam optimizer (CIFAR-10 blocker)
- Add Variable/Tensor compatibility to matmul, ReLU, Softmax, MSE Loss
- Enable proper autograd support with gradient functions
- Resolve broadcasting errors with variable batch sizes

**Student Protection System:**
- Industry-standard file protection (read-only core files)
- Enhanced auto-generated warnings with prominent ASCII-art headers
- Git integration (pre-commit hooks, .gitattributes)
- VSCode editor protection and warnings
- Runtime validation system with import hooks
- Automatic protection during module exports

**CLI Integration:**
- New `tito system protect` command group
- Protection status, validation, and health checks
- Automatic protection enabled during `tito module complete`
- Non-blocking validation with helpful error messages

**Development Workflow:**
- Updated CLAUDE.md with protection guidelines
- Comprehensive validation scripts and health checks
- Clean separation of source vs compiled file editing
- Professional development practices enforcement

**Impact:**
 CIFAR-10 training now works reliably with variable batch sizes
 Students protected from accidentally breaking core functionality
 Professional development workflow with industry-standard practices
 Comprehensive testing and validation infrastructure

This enables reliable ML systems training while protecting students
from common mistakes that break the Variable/Tensor compatibility.
2025-09-21 12:22:18 -04:00

98 lines
3.4 KiB
Python

"""
System command group for TinyTorch CLI: environment, configuration, and system tools.
"""
from argparse import ArgumentParser, Namespace
from rich.panel import Panel
from .base import BaseCommand
from .info import InfoCommand
from .doctor import DoctorCommand
from .jupyter import JupyterCommand
from .protect import ProtectCommand
class SystemCommand(BaseCommand):
@property
def name(self) -> str:
return "system"
@property
def description(self) -> str:
return "System environment and configuration commands"
def add_arguments(self, parser: ArgumentParser) -> None:
subparsers = parser.add_subparsers(
dest='system_command',
help='System subcommands',
metavar='SUBCOMMAND'
)
# Info subcommand
info_parser = subparsers.add_parser(
'info',
help='Show system information and course navigation'
)
info_cmd = InfoCommand(self.config)
info_cmd.add_arguments(info_parser)
# Doctor subcommand
doctor_parser = subparsers.add_parser(
'doctor',
help='Run environment diagnosis'
)
doctor_cmd = DoctorCommand(self.config)
doctor_cmd.add_arguments(doctor_parser)
# Jupyter subcommand
jupyter_parser = subparsers.add_parser(
'jupyter',
help='Start Jupyter notebook server'
)
jupyter_cmd = JupyterCommand(self.config)
jupyter_cmd.add_arguments(jupyter_parser)
# Protect subcommand
protect_parser = subparsers.add_parser(
'protect',
help='🛡️ Student protection system to prevent core file edits'
)
protect_cmd = ProtectCommand(self.config)
protect_cmd.add_arguments(protect_parser)
def run(self, args: Namespace) -> int:
console = self.console
if not hasattr(args, 'system_command') or not args.system_command:
console.print(Panel(
"[bold cyan]System Commands[/bold cyan]\n\n"
"Available subcommands:\n"
" • [bold]info[/bold] - Show system information and course navigation\n"
" • [bold]doctor[/bold] - Run environment diagnosis\n"
" • [bold]jupyter[/bold] - Start Jupyter notebook server\n"
" • [bold]protect[/bold] - 🛡️ Student protection system management\n\n"
"[dim]Example: tito system info[/dim]",
title="System Command Group",
border_style="bright_cyan"
))
return 0
# Execute the appropriate subcommand
if args.system_command == 'info':
cmd = InfoCommand(self.config)
return cmd.execute(args)
elif args.system_command == 'doctor':
cmd = DoctorCommand(self.config)
return cmd.execute(args)
elif args.system_command == 'jupyter':
cmd = JupyterCommand(self.config)
return cmd.execute(args)
elif args.system_command == 'protect':
cmd = ProtectCommand(self.config)
return cmd.execute(args)
else:
console.print(Panel(
f"[red]Unknown system subcommand: {args.system_command}[/red]",
title="Error",
border_style="red"
))
return 1