mirror of
https://github.com/MLSysBook/TinyTorch.git
synced 2026-06-02 19:44:44 -05:00
Add descriptions to all .cursor/rules files
- Add brief descriptions to YAML frontmatter for all rule files - Descriptions explain the purpose and content of each rule - Follow consistent format matching ml-systems-course-context.mdc - Improve rule discoverability and understanding Files updated: - user-preferences.mdc: User preferences and development conventions - tinytorch-project-structure.mdc: Dual-structure architecture guide - testing-patterns.mdc: Testing standards with pytest and real data - nbdev-educational-pattern.mdc: Educational NBDev patterns - module-development-best-practices.mdc: Real Data, Real Systems principles - git-workflow.mdc: Git workflow guidelines for incremental commits - development-workflow.mdc: Complete development workflow with tito CLI - cli-patterns.mdc: CLI development patterns for tito tool
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
---
|
||||
description: CLI Development Patterns for TinyTorch
|
||||
globs:
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
# CLI Development Patterns for TinyTorch
|
||||
|
||||
## Command Architecture
|
||||
@@ -165,7 +168,7 @@ in_venv = (
|
||||
6. **Handle edge cases** - Missing files, invalid arguments, etc.
|
||||
7. **Provide progress feedback** - For long-running operations
|
||||
8. **Use consistent styling** - Colors, borders, and formatting
|
||||
description:
|
||||
|
||||
globs:
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
@@ -1,90 +1,10 @@
|
||||
---
|
||||
description: Development workflow for TinyTorch, including CLI tool usage, development cycle, testing requirements, and Git workflow.
|
||||
---
|
||||
|
||||
# TinyTorch Development Workflow
|
||||
|
||||
## CLI Tool: `tito`
|
||||
|
||||
The main development tool is the `tito` CLI. Common commands:
|
||||
|
||||
### Module Development
|
||||
```bash
|
||||
# Sync module: Python source → notebook → package export
|
||||
tito sync --module {module_name}
|
||||
|
||||
# Test specific module (uses pytest internally)
|
||||
tito test --module {module_name}
|
||||
|
||||
# Get project info and status
|
||||
tito info
|
||||
```
|
||||
|
||||
### Examples
|
||||
```bash
|
||||
# Work with setup module
|
||||
tito sync --module setup
|
||||
tito test --module setup
|
||||
|
||||
# Work with tensor module
|
||||
tito sync --module tensor
|
||||
tito test --module tensor
|
||||
```
|
||||
|
||||
## Development Cycle
|
||||
|
||||
1. **Edit**: Modify `modules/{module}/{module}_dev.py`
|
||||
- Use `#| export` to mark code for package export
|
||||
- Use `#| hide` for instructor solutions
|
||||
- Follow NBDev educational pattern
|
||||
|
||||
2. **Sync**: `tito sync --module {module}`
|
||||
- Converts Python source to Jupyter notebook
|
||||
- Exports marked code to `tinytorch/` package
|
||||
- Updates package structure
|
||||
|
||||
3. **Test**: `tito test --module {module}`
|
||||
- Runs module-specific pytest tests from `modules/{module}/tests/`
|
||||
- Uses pytest framework for all test execution
|
||||
- Validates exported package code
|
||||
- Ensures everything works end-to-end
|
||||
|
||||
4. **Commit**: Regular commits at good stages
|
||||
- See [Git Workflow Guidelines](mdc:.cursor/rules/git-workflow.mdc) for commit strategies
|
||||
- Commit when reaching good milestones
|
||||
- Clean up experimental files before committing
|
||||
|
||||
## Testing Requirements
|
||||
|
||||
- **All tests must use pytest** - No manual testing or other frameworks
|
||||
- Test files must be named `test_{module}.py` and located in `modules/{module}/tests/`
|
||||
- Tests should use pytest classes, fixtures, and assertions
|
||||
- CLI tool uses pytest internally: `subprocess.run([sys.executable, "-m", "pytest", test_file, "-v"])`
|
||||
|
||||
## File Relationships
|
||||
|
||||
```
|
||||
modules/{module}/{module}_dev.py → modules/{module}/{module}_dev.ipynb
|
||||
↓
|
||||
tinytorch/core/{component}.py
|
||||
↑
|
||||
modules/{module}/tests/test_{module}.py (pytest)
|
||||
```
|
||||
|
||||
## Module Structure
|
||||
|
||||
Each module should be self-contained with:
|
||||
- `{module}_dev.py` - Main development file (Python source)
|
||||
- `{module}_dev.ipynb` - Generated notebook (auto-created)
|
||||
- `README.md` - Module documentation
|
||||
- `tests/` - Test directory
|
||||
- `test_{module}.py` - Module tests (pytest format)
|
||||
|
||||
Students run and pass all pytest tests locally within the module before using nbdev to export code to the tinytorch package and build/test the overall package.
|
||||
|
||||
## Git Workflow
|
||||
|
||||
For commit strategies and Git best practices, see [Git Workflow Guidelines](mdc:.cursor/rules/git-workflow.mdc).
|
||||
|
||||
Key principles:
|
||||
- **Incremental commits** for easy reverts
|
||||
## CLI Tool: `
|
||||
- **Test before committing** to avoid broken commits
|
||||
- **Use feature branches** for larger changes
|
||||
- **Descriptive commit messages** that explain what changed
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
---
|
||||
description: Git workflow guidelines for TinyTorch development.
|
||||
---
|
||||
|
||||
# Git Workflow Guidelines for TinyTorch Development
|
||||
|
||||
## 🎯 **Philosophy: Incremental Commits for Easy Reverts**
|
||||
@@ -147,3 +151,7 @@ git commit -m "Second part of changes"
|
||||
5. **Commit frequently** to avoid losing work
|
||||
|
||||
**Remember:** It's better to have many small commits than one large commit that's hard to revert or understand.
|
||||
|
||||
5. **Commit frequently** to avoid losing work
|
||||
|
||||
**Remember:** It's better to have many small commits than one large commit that's hard to revert or understand.
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
# TinyTorch Module Development Best Practices
|
||||
|
||||
## Core Principles
|
||||
@@ -266,3 +267,7 @@ description:
|
||||
globs:
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
globs:
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
|
||||
|
||||
# NBDev Educational Pattern for TinyTorch Modules
|
||||
|
||||
When working with module development files (`*_dev.py`), follow this educational structure:
|
||||
@@ -255,3 +256,7 @@ All modules must:
|
||||
## Naming Convention
|
||||
|
||||
Module files should be named `{module_name}_dev.py` to indicate development notebooks, following the established pattern from [modules/setup/setup_dev.py](mdc:modules/setup/setup_dev.py) and [modules/tensor/tensor_dev.py](mdc:modules/tensor/tensor_dev.py).
|
||||
|
||||
## Naming Convention
|
||||
|
||||
Module files should be named `{module_name}_dev.py` to indicate development notebooks, following the established pattern from [modules/setup/setup_dev.py](mdc:modules/setup/setup_dev.py) and [modules/tensor/tensor_dev.py](mdc:modules/tensor/tensor_dev.py).
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
---
|
||||
description: "Testing patterns for TinyTorch, including framework requirements, core principles, file structure, naming convention, and test patterns."
|
||||
---
|
||||
|
||||
# Testing Patterns for TinyTorch
|
||||
|
||||
@@ -291,4 +294,8 @@ result = subprocess.run([sys.executable, "-m", "pytest", test_file, "-v"])
|
||||
```
|
||||
|
||||
This ensures all tests run through pytest with consistent output and reporting, using real data throughout the testing process.
|
||||
|
||||
```
|
||||
|
||||
This ensures all tests run through pytest with consistent output and reporting, using real data throughout the testing process.
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
---
|
||||
description: A guide to the project structure of the TinyTorch ML framework.
|
||||
---
|
||||
|
||||
# TinyTorch Project Structure Guide
|
||||
|
||||
@@ -52,5 +55,9 @@ The `#| default_exp` directive controls where code exports to in the package.
|
||||
|
||||
|
||||
|
||||
The `#| default_exp` directive controls where code exports to in the package.
|
||||
|
||||
|
||||
|
||||
The `#| default_exp` directive controls where code exports to in the package.
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
---
|
||||
description: User preferences and development conventions for TinyTorch, including module naming patterns, commit frequency, testing standards, and NBDev integration workflow.
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
|
||||
# User Preferences and Conventions
|
||||
|
||||
|
||||
Reference in New Issue
Block a user