Skip to content

refactor: extract business logic from compute_provider router into services#1554

Draft
aliasaria wants to merge 1 commit intomainfrom
claude/simplify-compute-providers-9H8CF
Draft

refactor: extract business logic from compute_provider router into services#1554
aliasaria wants to merge 1 commit intomainfrom
claude/simplify-compute-providers-9H8CF

Conversation

@aliasaria
Copy link
Member

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

…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
Copy link

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.

@sentry
Copy link

sentry bot commented Mar 16, 2026

Codecov Report

❌ Patch coverage is 12.29135% with 578 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ransformerlab/services/compute_provider_service.py 9.24% 530 Missing ⚠️
api/transformerlab/shared/cloud_credentials.py 19.60% 41 Missing ⚠️
api/transformerlab/routers/dependencies.py 70.83% 7 Missing ⚠️

📢 Thoughts on this report? Let us know!

@deep1401 deep1401 marked this pull request as draft March 16, 2026 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants