mirror of
https://github.com/MLSysBook/TinyTorch.git
synced 2026-04-27 19:19:42 -05:00
Rename sync command to export for clarity
- Rename SyncCommand to ExportCommand and sync.py to export.py - Update all CLI references from 'tito package sync' to 'tito package export' - Update help text and internal messages to use 'Export' terminology - Update imports across all command files - Update help text in main CLI, reset, clean, info, and notebooks commands - Command now clearly communicates that it exports notebook code to Python package - Maintains same functionality but with clearer naming for user experience
This commit is contained in:
@@ -12,7 +12,7 @@ from .notebooks import NotebooksCommand
|
||||
from .info import InfoCommand
|
||||
from .test import TestCommand
|
||||
from .doctor import DoctorCommand
|
||||
from .sync import SyncCommand
|
||||
from .export import ExportCommand
|
||||
from .reset import ResetCommand
|
||||
from .jupyter import JupyterCommand
|
||||
from .nbdev import NbdevCommand
|
||||
@@ -31,7 +31,7 @@ __all__ = [
|
||||
'InfoCommand',
|
||||
'TestCommand',
|
||||
'DoctorCommand',
|
||||
'SyncCommand',
|
||||
'ExportCommand',
|
||||
'ResetCommand',
|
||||
'JupyterCommand',
|
||||
'NbdevCommand',
|
||||
|
||||
@@ -144,7 +144,7 @@ class CleanCommand(BaseCommand):
|
||||
result_text.append("\n💡 Next steps:\n", style="bold yellow")
|
||||
result_text.append(" • Run: tito module notebooks - Regenerate notebooks\n", style="white")
|
||||
result_text.append(" • Run: tito module test --all - Test all modules\n", style="white")
|
||||
result_text.append(" • Run: tito package sync - Export to package\n", style="white")
|
||||
result_text.append(" • Run: tito package export - Export to package\n", style="white")
|
||||
|
||||
border_style = "green" if error_count == 0 else "yellow"
|
||||
console.print(Panel(result_text, title="Cleanup Complete", border_style=border_style))
|
||||
|
||||
@@ -11,22 +11,22 @@ from rich.text import Text
|
||||
|
||||
from .base import BaseCommand
|
||||
|
||||
class SyncCommand(BaseCommand):
|
||||
class ExportCommand(BaseCommand):
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return "sync"
|
||||
return "export"
|
||||
|
||||
@property
|
||||
def description(self) -> str:
|
||||
return "Export notebook code to Python package"
|
||||
|
||||
def add_arguments(self, parser: ArgumentParser) -> None:
|
||||
parser.add_argument("--module", help="Sync specific module (e.g., setup, tensor)")
|
||||
parser.add_argument("--module", help="Export specific module (e.g., setup, tensor)")
|
||||
|
||||
def run(self, args: Namespace) -> int:
|
||||
console = self.console
|
||||
|
||||
# Determine what to sync
|
||||
# Determine what to export
|
||||
if hasattr(args, 'module') and args.module:
|
||||
module_path = f"modules/{args.module}"
|
||||
if not Path(module_path).exists():
|
||||
@@ -34,14 +34,14 @@ class SyncCommand(BaseCommand):
|
||||
title="Module Not Found", border_style="red"))
|
||||
return 1
|
||||
|
||||
console.print(Panel(f"🔄 Synchronizing Module: {args.module}",
|
||||
console.print(Panel(f"🔄 Exporting Module: {args.module}",
|
||||
title="nbdev Export", border_style="bright_cyan"))
|
||||
console.print(f"🔄 Exporting {args.module} notebook to tinytorch package...")
|
||||
|
||||
# Use nbdev_export with --path for specific module
|
||||
cmd = ["nbdev_export", "--path", module_path]
|
||||
else:
|
||||
console.print(Panel("🔄 Synchronizing All Notebooks to Package",
|
||||
console.print(Panel("🔄 Exporting All Notebooks to Package",
|
||||
title="nbdev Export", border_style="bright_cyan"))
|
||||
console.print("🔄 Exporting all notebook code to tinytorch package...")
|
||||
|
||||
@@ -85,7 +85,7 @@ class InfoCommand(BaseCommand):
|
||||
cmd_text.append("🧪 Run Tests: ", style="dim")
|
||||
cmd_text.append("tito module test --all\n", style="bold cyan")
|
||||
cmd_text.append("🔄 Export Code: ", style="dim")
|
||||
cmd_text.append("tito package sync\n", style="bold cyan")
|
||||
cmd_text.append("tito package export\n", style="bold cyan")
|
||||
cmd_text.append("🩺 Check Environment: ", style="dim")
|
||||
cmd_text.append("tito system doctor", style="bold cyan")
|
||||
|
||||
|
||||
@@ -30,13 +30,13 @@ class NbdevCommand(BaseCommand):
|
||||
title="Notebook Tools", border_style="bright_cyan"))
|
||||
|
||||
if args.export:
|
||||
# Use the sync command logic
|
||||
from .sync import SyncCommand
|
||||
sync_cmd = SyncCommand(self.config)
|
||||
sync_args = ArgumentParser()
|
||||
sync_cmd.add_arguments(sync_args)
|
||||
sync_args = sync_args.parse_args([]) # Empty args for sync
|
||||
return sync_cmd.run(sync_args)
|
||||
# Use the export command logic
|
||||
from .export import ExportCommand
|
||||
export_cmd = ExportCommand(self.config)
|
||||
export_args = ArgumentParser()
|
||||
export_cmd.add_arguments(export_args)
|
||||
export_args = export_args.parse_args([]) # Empty args for export
|
||||
return export_cmd.run(export_args)
|
||||
|
||||
elif args.build_docs:
|
||||
console.print("📚 Building documentation from notebooks...")
|
||||
|
||||
@@ -147,7 +147,7 @@ class NotebooksCommand(BaseCommand):
|
||||
summary_text.append("\n💡 Next steps:\n", style="bold yellow")
|
||||
summary_text.append(" • Open notebooks with: jupyter lab\n", style="white")
|
||||
summary_text.append(" • Work interactively in the notebooks\n", style="white")
|
||||
summary_text.append(" • Export code with: tito package sync\n", style="white")
|
||||
summary_text.append(" • Export code with: tito package export\n", style="white")
|
||||
summary_text.append(" • Run tests with: tito module test\n", style="white")
|
||||
|
||||
border_style = "green" if error_count == 0 else "yellow"
|
||||
|
||||
@@ -6,7 +6,7 @@ from argparse import ArgumentParser, Namespace
|
||||
from rich.panel import Panel
|
||||
|
||||
from .base import BaseCommand
|
||||
from .sync import SyncCommand
|
||||
from .export import ExportCommand
|
||||
from .reset import ResetCommand
|
||||
from .nbdev import NbdevCommand
|
||||
|
||||
@@ -26,13 +26,13 @@ class PackageCommand(BaseCommand):
|
||||
metavar='SUBCOMMAND'
|
||||
)
|
||||
|
||||
# Sync subcommand
|
||||
sync_parser = subparsers.add_parser(
|
||||
'sync',
|
||||
# Export subcommand
|
||||
export_parser = subparsers.add_parser(
|
||||
'export',
|
||||
help='Export notebook code to Python package'
|
||||
)
|
||||
sync_cmd = SyncCommand(self.config)
|
||||
sync_cmd.add_arguments(sync_parser)
|
||||
export_cmd = ExportCommand(self.config)
|
||||
export_cmd.add_arguments(export_parser)
|
||||
|
||||
# Reset subcommand
|
||||
reset_parser = subparsers.add_parser(
|
||||
@@ -57,11 +57,11 @@ class PackageCommand(BaseCommand):
|
||||
console.print(Panel(
|
||||
"[bold cyan]Package Commands[/bold cyan]\n\n"
|
||||
"Available subcommands:\n"
|
||||
" • [bold]sync[/bold] - Export notebook code to Python package\n"
|
||||
" • [bold]reset[/bold] - Reset tinytorch package to clean state\n"
|
||||
" • [bold]nbdev[/bold] - nbdev notebook development commands\n\n"
|
||||
" • [bold]export[/bold] - Export notebook code to Python package\n"
|
||||
" • [bold]reset[/bold] - Reset tinytorch package to clean state\n"
|
||||
" • [bold]nbdev[/bold] - nbdev notebook development commands\n\n"
|
||||
"[dim]Examples:[/dim]\n"
|
||||
"[dim] tito package sync --module tensor[/dim]\n"
|
||||
"[dim] tito package export --module tensor[/dim]\n"
|
||||
"[dim] tito package reset --force[/dim]\n"
|
||||
"[dim] tito package nbdev --export[/dim]",
|
||||
title="Package Command Group",
|
||||
@@ -70,8 +70,8 @@ class PackageCommand(BaseCommand):
|
||||
return 0
|
||||
|
||||
# Execute the appropriate subcommand
|
||||
if args.package_command == 'sync':
|
||||
cmd = SyncCommand(self.config)
|
||||
if args.package_command == 'export':
|
||||
cmd = ExportCommand(self.config)
|
||||
return cmd.execute(args)
|
||||
elif args.package_command == 'reset':
|
||||
cmd = ResetCommand(self.config)
|
||||
|
||||
@@ -86,8 +86,8 @@ class ResetCommand(BaseCommand):
|
||||
if files_removed > 0:
|
||||
reset_text.append(f"\n✅ Reset complete! Removed {files_removed} generated files.\n", style="bold green")
|
||||
reset_text.append("\n💡 Next steps:\n", style="bold yellow")
|
||||
reset_text.append(" • Run: tito sync - Re-export notebooks\n", style="white")
|
||||
reset_text.append(" • Run: tito sync --module setup - Export specific module\n", style="white")
|
||||
reset_text.append(" • Run: tito package export - Re-export notebooks\n", style="white")
|
||||
reset_text.append(" • Run: tito package export --module setup - Export specific module\n", style="white")
|
||||
reset_text.append(" • Run: tito test --all - Test everything\n", style="white")
|
||||
|
||||
console.print(Panel(reset_text, title="Reset Complete", border_style="green"))
|
||||
|
||||
@@ -24,7 +24,7 @@ from .commands.notebooks import NotebooksCommand
|
||||
from .commands.info import InfoCommand
|
||||
from .commands.test import TestCommand
|
||||
from .commands.doctor import DoctorCommand
|
||||
from .commands.sync import SyncCommand
|
||||
from .commands.export import ExportCommand
|
||||
from .commands.reset import ResetCommand
|
||||
from .commands.jupyter import JupyterCommand
|
||||
from .commands.nbdev import NbdevCommand
|
||||
@@ -74,7 +74,7 @@ Command Groups:
|
||||
Examples:
|
||||
tito system info Show system information
|
||||
tito module status --metadata Module status with metadata
|
||||
tito package sync Export notebooks to package
|
||||
tito package export Export notebooks to package
|
||||
"""
|
||||
)
|
||||
|
||||
@@ -169,7 +169,7 @@ Examples:
|
||||
"[bold]Quick Start:[/bold]\n"
|
||||
" [dim]tito system info[/dim] - Show system information\n"
|
||||
" [dim]tito module status --metadata[/dim] - Module status with metadata\n"
|
||||
" [dim]tito package sync[/dim] - Export notebooks to package\n\n"
|
||||
" [dim]tito package export[/dim] - Export notebooks to package\n\n"
|
||||
"[bold]Get Help:[/bold]\n"
|
||||
" [dim]tito system[/dim] - Show system subcommands\n"
|
||||
" [dim]tito module[/dim] - Show module subcommands\n"
|
||||
|
||||
Reference in New Issue
Block a user