Files
TinyTorch/tito/commands/jupyter.py
Vijay Janapa Reddi 15f5a84863 RESTORE: Complete CLI functionality in new architecture
- Ported all commands from bin/tito.py to new tito/ CLI architecture
- Added InfoCommand with system info and module status
- Added TestCommand with pytest integration
- Added DoctorCommand with environment diagnosis
- Added SyncCommand for nbdev export functionality
- Added ResetCommand for package cleanup
- Added JupyterCommand for notebook server
- Added NbdevCommand for nbdev development tools
- Added SubmitCommand and StatusCommand (placeholders)
- Fixed missing imports in tinytorch/core/tensor.py
- All commands now work with 'tito' command in shell
- Maintains professional architecture while restoring full functionality

Commands restored:
 info - System information and module status
 test - Run module tests with pytest
 doctor - Environment diagnosis
 sync - Export notebooks to package
 reset - Clean tinytorch package
 nbdev - nbdev development commands
 jupyter - Start Jupyter server
 submit - Module submission
 status - Module status
 notebooks - Build notebooks from Python files

The CLI now has both the professional architecture and all original functionality.
2025-07-10 22:39:23 -04:00

52 lines
1.9 KiB
Python

"""
Jupyter command for TinyTorch CLI: starts Jupyter notebook server.
"""
import subprocess
from argparse import ArgumentParser, Namespace
from rich.panel import Panel
from .base import BaseCommand
class JupyterCommand(BaseCommand):
@property
def name(self) -> str:
return "jupyter"
@property
def description(self) -> str:
return "Start Jupyter notebook server"
def add_arguments(self, parser: ArgumentParser) -> None:
parser.add_argument("--notebook", action="store_true", help="Start classic notebook")
parser.add_argument("--lab", action="store_true", help="Start JupyterLab")
parser.add_argument("--port", type=int, default=8888, help="Port to run on (default: 8888)")
def run(self, args: Namespace) -> int:
console = self.console
console.print(Panel("📓 Jupyter Notebook Server",
title="Interactive Development", border_style="bright_green"))
# Determine which Jupyter to start
if args.lab:
cmd = ["jupyter", "lab", "--port", str(args.port)]
console.print(f"🚀 Starting JupyterLab on port {args.port}...")
else:
cmd = ["jupyter", "notebook", "--port", str(args.port)]
console.print(f"🚀 Starting Jupyter Notebook on port {args.port}...")
console.print("💡 Open your browser to the URL shown above")
console.print("📁 Navigate to your module's notebook directory")
console.print("🔄 Press Ctrl+C to stop the server")
try:
subprocess.run(cmd)
except KeyboardInterrupt:
console.print("\n🛑 Jupyter server stopped")
except FileNotFoundError:
console.print(Panel("[red]❌ Jupyter not found. Install with: pip install jupyter[/red]",
title="Error", border_style="red"))
return 1
return 0