Skip to content

Add a new terminal state for skypilot#1426

Merged
deep1401 merged 3 commits intomainfrom
fix/terminal-states-skypilot
Mar 3, 2026
Merged

Add a new terminal state for skypilot#1426
deep1401 merged 3 commits intomainfrom
fix/terminal-states-skypilot

Conversation

@deep1401
Copy link
Copy Markdown
Member

@deep1401 deep1401 commented Mar 2, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Improved cluster status handling to properly recognize failed setup states, ensuring accurate status reporting and error handling.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 2, 2026

📝 Walkthrough

Walkthrough

The change adds explicit mapping of the "FAILED_SETUP" SkyPilot status string to ClusterState.FAILED in cluster status retrieval methods, replacing a previous fallback mechanism that used direct enum lookup with KeyError handling.

Changes

Cohort / File(s) Summary
Status Mapping Enhancement
api/transformerlab/compute_providers/skypilot.py
Explicit handling of "FAILED_SETUP" state mapped to ClusterState.FAILED in get_cluster_status and list_clusters functions. Replaces previous fallback that attempted direct enum lookup with KeyError handling, now falling back to UNKNOWN for unrecognized states.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add a new terminal state for skypilot' accurately describes the main change: explicitly mapping the SkyPilot 'FAILED_SETUP' status to ClusterState.FAILED, which is a new terminal state handling for the SkyPilot compute provider.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/terminal-states-skypilot

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
api/transformerlab/compute_providers/skypilot.py (1)

702-709: Consider centralizing cluster-state mapping logic.

The same status normalization appears in two methods. A small shared helper would reduce drift risk when new SkyPilot states are added.

♻️ Suggested refactor
+    def _map_skypilot_cluster_state(self, state_str: str) -> ClusterState:
+        if state_str == "FAILED_SETUP":
+            return ClusterState.FAILED
+        try:
+            return ClusterState[state_str]
+        except KeyError:
+            return ClusterState.UNKNOWN
-        if state_str == "FAILED_SETUP":
-            state = ClusterState.FAILED
-        else:
-            try:
-                state = ClusterState[state_str]
-            except KeyError:
-                state = ClusterState.UNKNOWN
+        state = self._map_skypilot_cluster_state(state_str)

Also applies to: 858-865

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@api/transformerlab/compute_providers/skypilot.py` around lines 702 - 709,
Create a single helper (e.g., map_skypilot_state or _map_skypilot_state) that
accepts the raw SkyPilot state_str and returns the appropriate ClusterState,
centralizing the logic that maps "FAILED_SETUP" to ClusterState.FAILED and falls
back to ClusterState.UNKNOWN for unknown values (currently done with try:
ClusterState[state_str] except KeyError). Replace the duplicated mapping blocks
in the two places in skypilot.py (the mapping near the shown block and the
similar block around the other occurrence) to call this helper so all state
normalization is in one place.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@api/transformerlab/compute_providers/skypilot.py`:
- Around line 702-709: Create a single helper (e.g., map_skypilot_state or
_map_skypilot_state) that accepts the raw SkyPilot state_str and returns the
appropriate ClusterState, centralizing the logic that maps "FAILED_SETUP" to
ClusterState.FAILED and falls back to ClusterState.UNKNOWN for unknown values
(currently done with try: ClusterState[state_str] except KeyError). Replace the
duplicated mapping blocks in the two places in skypilot.py (the mapping near the
shown block and the similar block around the other occurrence) to call this
helper so all state normalization is in one place.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 86cdafc and 843e66c.

📒 Files selected for processing (1)
  • api/transformerlab/compute_providers/skypilot.py

@paragon-review
Copy link
Copy Markdown

paragon-review bot commented Mar 2, 2026

Paragon Summary

This pull request review identified 1 issue across 1 category in 1 file. The review analyzed code changes, potential bugs, security vulnerabilities, performance issues, and code quality concerns using automated analysis tools.

This PR adds a new terminal state to the skypilot compute provider, likely to better handle job or instance lifecycle completion in the skypilot integration. The change is isolated to the skypilot compute provider module.

Key changes:

  • Based on the limited information provided:
  • Adds a new terminal state for the Skypilot compute provider
  • Modifications isolated to api/transformerlab/compute_providers/skypilot.py
  • PR title suggests enhanced state management for terminal/compute lifecycle

Confidence score: 5/5

  • This PR has low risk with no critical or high-priority issues identified
  • Score reflects clean code review with only minor suggestions or no issues found
  • Code quality checks passed - safe to proceed with merge

1 file reviewed, 1 comment

Severity breakdown: Low: 1


Tip: @paragon-run <instructions> to chat with our agent or push fixes!

Dashboard

state = ClusterState[state_str]
except KeyError:
state = ClusterState.UNKNOWN
# Map SkyPilot's FAILED_SETUP directly to our FAILED state
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Identical state-mapping block is duplicated in two methods

Identical state-mapping block is duplicated in two methods. Future state additions may miss one site. Extract a shared helper method.

View Details

Location: api/transformerlab/compute_providers/skypilot.py (lines 702)

Analysis

Identical state-mapping block is duplicated in two methods

What fails No runtime failure, but the same 8-line state-mapping block is copy-pasted in get_cluster_status and list_clusters, creating a maintenance risk.
Result Two identical blocks must be kept in sync manually; a future mapping change could be applied to only one.
Expected A single private helper (e.g., _map_skypilot_state) should own the mapping logic, called from both methods.
Impact Low risk now, but divergence on the next state-mapping change could silently misreport cluster status.
How to reproduce
grep -n 'FAILED_SETUP' api/transformerlab/compute_providers/skypilot.py  # shows two identical blocks
AI Fix Prompt
Fix this issue: Identical state-mapping block is duplicated in two methods. Future state additions may miss one site. Extract a shared helper method.

Location: api/transformerlab/compute_providers/skypilot.py (lines 702)
Problem: No runtime failure, but the same 8-line state-mapping block is copy-pasted in get_cluster_status and list_clusters, creating a maintenance risk.
Current behavior: Two identical blocks must be kept in sync manually; a future mapping change could be applied to only one.
Expected: A single private helper (e.g., _map_skypilot_state) should own the mapping logic, called from both methods.
Steps to reproduce: grep -n 'FAILED_SETUP' api/transformerlab/compute_providers/skypilot.py  # shows two identical blocks

Provide a code fix.


Tip: Reply with @paragon-run to automatically fix this issue

@sentry
Copy link
Copy Markdown

sentry bot commented Mar 2, 2026

Codecov Report

❌ Patch coverage is 0% with 12 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
api/transformerlab/compute_providers/skypilot.py 0.00% 12 Missing ⚠️

📢 Thoughts on this report? Let us know!

@deep1401 deep1401 merged commit a09b91a into main Mar 3, 2026
8 checks passed
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