refactor: extract business logic from compute_provider router into services#1554
Draft
refactor: extract business logic from compute_provider router into services#1554
Conversation
…rvices The compute_provider.py router was 3,151 lines with business logic mixed into route handlers. This refactoring follows the project's architecture rule that business logic belongs in services, not routers. Changes: - Create routers/dependencies.py with ProviderContext dataclass and get_provider_for_request FastAPI dependency, eliminating 23 repetitions of the provider lookup boilerplate - Create shared/cloud_credentials.py with AWS/GCP/Azure credential setup helpers (pure utility functions with no HTTP dependency) - Create services/compute_provider_service.py with all business logic: launch_task, create_sweep_parent_job, launch_sweep_jobs, resume_from_checkpoint, and cluster operation wrappers - Slim down the router from 3,151 to 1,250 lines of pure HTTP handling No API contract changes — same routes, same request/response shapes. https://claude.ai/code/session_012xgvfzPziVFpVCscbL8w96
|
Paragon Review Skipped Hi @aliasaria! Your Polarity credit balance is insufficient to complete this review. Please visit https://home.polarity.cc to add more credits and continue using Paragon reviews. |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The compute_provider.py router was 3,151 lines with business logic mixed
into route handlers. This refactoring follows the project's architecture
rule that business logic belongs in services, not routers.
Changes:
get_provider_for_request FastAPI dependency, eliminating 23 repetitions
of the provider lookup boilerplate
helpers (pure utility functions with no HTTP dependency)
launch_task, create_sweep_parent_job, launch_sweep_jobs,
resume_from_checkpoint, and cluster operation wrappers
No API contract changes — same routes, same request/response shapes.
https://claude.ai/code/session_012xgvfzPziVFpVCscbL8w96