Automatic Output to Results Folder - Implementation Summary
Overview
Both scan_starred_repos.py and repo_recommender.py have been updated to automatically save their outputs to the results/ folder with timestamped filenames.
Changes Made
1. Scanner Script (scripts/scan_starred_repos.py)
- Default Output Location: Automatically generates output filename in
results/folder if not specified - Filename Format:
results/starred_repos_{username}_{timestamp}.json - Timestamp Format:
YYYYMMDD_HHMMSS(UTC timezone-aware) - Behavior:
- If
--outputis not specified, automatically generates a timestamped filename - If
--outputis specified, uses the provided path - Creates
results/directory if it doesnβt exist
- If
Example Usage:
# Automatic output to results/
python3 scripts/scan_starred_repos.py --enhance-description --limit 50
# Custom output path (still works)
python3 scripts/scan_starred_repos.py --output custom/path/repos.json
2. Recommender Script (scripts/repo_recommender.py)
- Default Input Location: Now looks for starred repos in
results/folder by default - Default Output Location: Automatically generates output filename in
results/folder if not specified - Filename Format:
results/recommendations_{timestamp}.{ext}(ext = md or txt based on format) - Timestamp Format:
YYYYMMDD_HHMMSS(UTC timezone-aware) - Behavior:
- Saves report to timestamped file in
results/ - Also prints a preview to stdout for immediate viewing
- Creates
results/directory if it doesnβt exist
- Saves report to timestamped file in
Example Usage:
# Automatic output to results/
python3 scripts/repo_recommender.py --min-score 30
# Specify starred repos file and custom output
python3 scripts/repo_recommender.py --starred-repos custom/repos.json --output custom/report.md
3. .gitignore Updates
- Added
results/directory to.gitignore - Added
!results/.gitkeepto preserve directory structure - All generated files in
results/are ignored by git
4. Directory Structure
results/
βββ .gitkeep # Tracked by git to preserve directory
βββ starred_repos_authenticated_user_YYYYMMDD_HHMMSS.json # Auto-generated (ignored)
βββ recommendations_YYYYMMDD_HHMMSS.md # Auto-generated (ignored)
Benefits
- Organization: All generated outputs are centralized in one location
- Version Control: Outputs are automatically ignored by git while the directory structure is preserved
- Timestamping: Easy to track when each analysis was performed
- Backwards Compatible: Custom output paths still work if specified
- No Manual Configuration: Works out of the box without user intervention
Technical Details
Deprecated Function Fixes
- Replaced
datetime.utcnow()withdatetime.now(timezone.utc)to comply with Python deprecation warnings - Ensures timezone-aware datetime objects for better accuracy
Error Handling
- Both scripts create the
results/directory automatically if it doesnβt exist - Uses
os.makedirs(output_dir, exist_ok=True)to prevent errors if directory already exists
Testing
Both scripts have been tested and confirmed working:
- β
Scanner creates timestamped JSON files in
results/ - β
Recommender creates timestamped markdown reports in
results/ - β Directory is created automatically if missing
- β
.gitignoreproperly excludes generated files - β
.gitkeeppreserves directory structure in git
Migration Notes
If you have existing outputs in other locations:
- Old files in
repos/ordata/remain unaffected - You can continue using custom paths with
--outputflag - Consider moving important outputs to
results/for consistency