Simplify .tinytorch structure and add file update notifications

Changes:
- Move profile.json from nested community/ to flat ~/.tinytorch/profile.json
- Add file update notifications when .tinytorch files are created/updated
- Print "📝 Updated: ~/.tinytorch/filename" for better visibility
- Update benchmark.py to use new flat structure
- Update auth.py to print when credentials are saved

Benefits:
- Simpler, flatter directory structure (no unnecessary nesting)
- Users see exactly which files are being modified during setup
- Consistent location for all user data (~/.tinytorch/)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Vijay Janapa Reddi
2025-12-01 12:13:46 -05:00
parent aae2ac16bf
commit d186e5ba17
4 changed files with 41 additions and 17 deletions

View File

@@ -578,11 +578,12 @@ class BenchmarkCommand(BaseCommand):
console.print("[cyan]💡 To submit: Create a PR with this file or run 'tito community submit'[/cyan]")
def _get_community_data(self) -> Optional[Dict[str, Any]]:
"""Get user's community data if they've joined (project-local)."""
community_file = self.config.project_root / ".tinytorch" / "community" / "profile.json"
if community_file.exists():
"""Get user's community profile from ~/.tinytorch (flat structure)."""
from pathlib import Path
profile_file = Path.home() / ".tinytorch" / "profile.json"
if profile_file.exists():
try:
with open(community_file, 'r') as f:
with open(profile_file, 'r') as f:
return json.load(f)
except Exception:
return None

View File

@@ -25,6 +25,17 @@ from rich.progress import Progress, SpinnerColumn, TextColumn
from .base import BaseCommand
from ..core.console import get_console
def _print_file_update(console, file_path: Path) -> None:
"""Print a notification when a file is created or updated."""
try:
if file_path.is_relative_to(Path.home()):
relative_path = file_path.relative_to(Path.home())
console.print(f"[dim]📝 Updated: ~/{relative_path}[/dim]")
else:
console.print(f"[dim]📝 Updated: {file_path}[/dim]")
except (ValueError, AttributeError):
console.print(f"[dim]📝 Updated: {file_path}[/dim]")
class SetupCommand(BaseCommand):
"""First-time setup command for Tiny🔥Torch development environment."""
@@ -61,19 +72,19 @@ class SetupCommand(BaseCommand):
def check_existing_setup(self) -> bool:
"""Check if Tiny🔥Torch is already set up."""
# Check for profile file
profile_path = self.config.project_root / "profile.json"
# Check for profile file in .tinytorch (flat structure)
profile_path = Path.home() / ".tinytorch" / "profile.json"
# Check for virtual environment
venv_paths = [
self.config.project_root / ".venv",
self.config.project_root / "venv",
self.config.project_root / "tinytorch-env",
Path.home() / ".tinytorch" / "venv"
]
has_profile = profile_path.exists()
has_venv = any(venv_path.exists() for venv_path in venv_paths)
return has_profile and has_venv
def install_packages(self) -> bool:
@@ -215,20 +226,23 @@ class SetupCommand(BaseCommand):
def create_user_profile(self) -> Dict[str, Any]:
"""Create user profile for development tracking."""
self.console.print("👋 Creating your Tiny🔥Torch development profile...")
profile_path = self.config.project_root / "profile.json"
# Use .tinytorch directory (flat structure, not nested under community/)
tinytorch_dir = Path.home() / ".tinytorch"
tinytorch_dir.mkdir(parents=True, exist_ok=True)
profile_path = tinytorch_dir / "profile.json"
if profile_path.exists():
if not Confirm.ask("Profile already exists. Update it?"):
import json
with open(profile_path, 'r') as f:
return json.load(f)
# Collect user information
name = Prompt.ask("Your name", default="Tiny🔥Torch Developer")
email = Prompt.ask("Your email (optional)", default="dev@tinytorch.local")
affiliation = Prompt.ask("Your affiliation (university, company, etc.)", default="Independent")
# Create profile
profile = {
"name": name,
@@ -241,12 +255,13 @@ class SetupCommand(BaseCommand):
"modules_completed": [],
"last_active": datetime.datetime.now().isoformat()
}
# Save profile
import json
with open(profile_path, 'w') as f:
json.dump(profile, f, indent=2)
_print_file_update(self.console, profile_path)
self.console.print(f"✅ Profile created for {profile['name']}")
return profile

View File

@@ -52,6 +52,7 @@ def _ensure_dir() -> None:
def save_credentials(data: Dict[str, str]) -> None:
"""Persist credentials to disk safely and atomically."""
from tito.core.console import get_console
_ensure_dir()
p = _credentials_path()
tmp = p.with_suffix(".tmp")
@@ -65,6 +66,11 @@ def save_credentials(data: Dict[str, str]) -> None:
except OSError:
pass
# Print file update notification
console = get_console()
relative_path = p.relative_to(Path.home())
console.print(f"[dim]📝 Updated: ~/{relative_path}[/dim]")
def load_credentials() -> Optional[Dict[str, str]]:
p = _credentials_path()
if not p.exists():

View File

@@ -185,3 +185,5 @@ echo " cd docs && ./build.sh"
echo ""