Files
TinyTorch/tinytorch/cli/core/exceptions.py
Vijay Janapa Reddi 0cbcbf8a6e Refactor CLI to senior software engineer standards
BREAKING CHANGE: Major architectural refactoring of CLI system

New Professional Architecture:
- Clean separation of concerns with proper package structure
- Command pattern implementation with base classes
- Centralized configuration management
- Proper exception hierarchy and error handling
- Logging framework integration
- Type hints throughout
- Dependency injection pattern

Structure:
tinytorch/cli/
├── __init__.py              # Package initialization
├── main.py                  # Professional CLI entry point
├── core/                    # Core CLI functionality
│   ├── __init__.py
│   ├── config.py           # Configuration management
│   ├── console.py          # Centralized console output
│   └── exceptions.py       # Exception hierarchy
├── commands/               # Command implementations
│   ├── __init__.py
│   ├── base.py            # Base command class
│   └── notebooks.py       # Notebooks command
└── tools/                 # CLI tools
    ├── __init__.py
    └── py_to_notebook.py  # Conversion tool

Features Added:
- Proper entry points in pyproject.toml
- Professional logging with file output
- Environment validation with detailed error messages
- Dry-run mode for notebooks command
- Force rebuild option
- Timeout protection for subprocess calls
- Backward compatibility wrapper (bin/tito)
- Extensible command registration system

Benefits:
- Maintainable: Single responsibility per module
- Testable: Clean interfaces and dependency injection
- Extensible: Easy to add new commands
- Professional: Industry-standard patterns
- Robust: Proper error handling and validation
- Installable: Proper package structure with entry points
2025-07-10 22:05:10 -04:00

23 lines
544 B
Python

"""
Exception hierarchy for TinyTorch CLI.
"""
class TinyTorchCLIError(Exception):
"""Base exception for all CLI errors."""
pass
class ValidationError(TinyTorchCLIError):
"""Raised when validation fails."""
pass
class ExecutionError(TinyTorchCLIError):
"""Raised when command execution fails."""
pass
class EnvironmentError(TinyTorchCLIError):
"""Raised when environment setup is invalid."""
pass
class ModuleNotFoundError(TinyTorchCLIError):
"""Raised when a requested module is not found."""
pass