-
Notifications
You must be signed in to change notification settings - Fork 1
Performance optimizations and budget creation support #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Performance optimizations and budget creation support #24
Conversation
Performance Optimizations: - Add bulk membership optimization: Check cost center membership before batching to avoid unnecessary API calls - Add newly created cost centers optimization: Skip orphaned user checks for cost centers created in current run (100% API call reduction for clean slate scenarios) - Improve batching logic to happen after membership verification Budget Creation Features: - Add budget creation support with --create-budgets flag for unreleased GitHub Budgets API - Implement graceful error handling when Budgets API is unavailable (404 responses) - Add duplicate budget checking with API bug workaround (name-based lookup) - Create budgets for cost centers automatically when requested Code Quality & Maintenance: - Add BudgetsAPIUnavailableError exception for proper error handling - Enhance logging with performance metrics and optimization status - Clean up debugging scripts and temporary files - Update project naming from 'Copilot-Cost-Center-Manager' to 'cost-center-automation' - Update documentation and container names for consistency GitHub Actions Compatibility: - All optimizations work seamlessly in Actions environment - Graceful degradation when budget features aren't available - Reduced API calls improve rate limit handling - Enhanced logging integrates well with Actions logs Breaking Changes: None - all changes are backward compatible Performance Impact: Significant reduction in API calls, especially for clean slate deployments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces significant performance optimizations to the cost center management system along with new budget creation capabilities. The changes replace file-based caching with in-memory preloading for better performance and add GitHub Budgets API integration with graceful error handling.
Key Changes:
- Replace file-based cache with preload optimization (bulk cost center fetching)
- Add budget creation support with --create-budgets flag and graceful API degradation
- Implement bulk membership checks before batching to reduce unnecessary API calls
- Skip orphaned user checks for newly created cost centers (optimization)
- Update project branding from 'Copilot-Cost-Center-Manager' to 'cost-center-automation'
Reviewed Changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
src/teams_cost_center_manager.py | Removes cache dependency, adds preload optimization, implements newly created cost center tracking, adds budget creation support |
src/github_api.py | Adds BudgetsAPIUnavailableError, implements get_all_active_cost_centers and budget API methods, improves bulk membership checking |
src/cost_center_cache.py | File deleted - removes file-based caching system entirely |
scripts/performance_comparison.py | File deleted - removes cache performance comparison script |
main.py | Updates script description from 'Copilot' to generic 'Cost Center' |
docker-compose.yml | Updates service names from 'copilot-manager' to 'cost-center-automation' |
automation/update_cost_centers.sh | Updates script header comment |
README.md | Updates title from 'Copilot Cost Center' to 'Cost Center' |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
from .github_api import BudgetsAPIUnavailableError | ||
|
||
|
||
from .cost_center_cache import CostCenterCache | ||
|
||
|
Copilot
AI
Oct 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Extra blank lines between imports and class definition. Remove the extra blank lines to improve code readability.
See below for a potential fix:
Copilot uses AI. Check for mistakes.
|
||
# Initialize cost center cache | ||
self.cost_center_cache = CostCenterCache() | ||
|
Copilot
AI
Oct 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Extra blank line after removing cache initialization. Remove one blank line to maintain consistent spacing.
Copilot uses AI. Check for mistakes.
# Check if users are already in the target cost center for safety | ||
# (this may be redundant if bulk check was done at batch level, but ensures correctness) |
Copilot
AI
Oct 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment suggests this check may be redundant. Consider clarifying when this redundancy occurs or if this safety check is necessary in all cases.
# Check if users are already in the target cost center for safety | |
# (this may be redundant if bulk check was done at batch level, but ensures correctness) | |
# Check if users are already in the target cost center for safety. | |
# This check may be redundant if a batch-level membership check was performed before calling this method. | |
# However, it is retained here to ensure correctness in all cases, especially if this method is called independently. |
Copilot uses AI. Check for mistakes.
#!/bin/bash | ||
|
||
# GitHub Copilot Cost Center Update Script | ||
#!/bin/bash |
Copilot
AI
Oct 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate shebang line. Remove the redundant #!/bin/bash
on line 3.
#!/bin/bash |
Copilot uses AI. Check for mistakes.
Performance Optimizations:
Budget Creation Features:
Code Quality & Maintenance:
GitHub Actions Compatibility:
Breaking Changes: None - all changes are backward compatible
Performance Impact: Significant reduction in API calls, especially for clean slate deployments