Skip to content

perf: [PRODUCT-576] refactor sf nodes to use GET v1/nodes/list?names=... #180

Merged
sigmachirality merged 25 commits into
mainfrom
cursor/refactor-and-add-node-get-commands-21c7
Sep 16, 2025
Merged

perf: [PRODUCT-576] refactor sf nodes to use GET v1/nodes/list?names=... #180
sigmachirality merged 25 commits into
mainfrom
cursor/refactor-and-add-node-get-commands-21c7

Conversation

@sigmachirality
Copy link
Copy Markdown
Member

@sigmachirality sigmachirality commented Aug 15, 2025

Refactor sf nodes set, release, extend to use API filtering and add sf nodes get for efficient node retrieval.

Also fixes sf extend which erroneously assumes users will always extend from NOW. Makes the code for sf extend more resilient in general.

image

Adds sf nodes show/get.

Screenshot 2025-09-15 at 5 02 29 PM
Open in Cursor Open in Web

@semanticdiff-com
Copy link
Copy Markdown

semanticdiff-com Bot commented Aug 15, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  src/lib/buy/index.tsx  84% smaller
  src/lib/nodes/extend.ts  45% smaller
  src/lib/vm/image/list.tsx  42% smaller
  src/lib/nodes/set.ts  36% smaller
  src/lib/nodes/list.tsx  15% smaller
  src/lib/nodes/index.ts  6% smaller
  src/lib/nodes/get.tsx  0% smaller
  src/lib/nodes/release.ts  0% smaller
  src/lib/nodes/utils.ts  0% smaller

@cursor
Copy link
Copy Markdown

cursor Bot commented Aug 15, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

Co-authored-by: danieltaox <danieltaox@gmail.com>
@sigmachirality sigmachirality force-pushed the cursor/refactor-and-add-node-get-commands-21c7 branch from def202f to 09878ca Compare August 28, 2025 20:06
@sigmachirality sigmachirality changed the title Refactor and add node get commands feat: add sf nodes get/show, fix sf nodes extend, improve performance of sf nodes Sep 15, 2025
sigmachirality and others added 9 commits September 15, 2025 16:14
… is passed (#184)

Co-authored-by: danieltaox <danieltaox@gmail.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: GitHub Actions <github-actions[bot]@users.noreply.github.com>
…194)

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Without the duration and name the command will fail when users try to
copy paste it.

nodes/create: highlight --user-data-file in examples
@sigmachirality sigmachirality changed the title feat: add sf nodes get/show, fix sf nodes extend, improve performance of sf nodes perf: refactor sf nodes to use GET v1/nodes/list?names=... Sep 15, 2025
@sigmachirality sigmachirality marked this pull request as ready for review September 16, 2025 00:03
@sigmachirality sigmachirality self-assigned this Sep 16, 2025
Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

Greptile Summary

This PR implements a significant refactoring of the SFCompute CLI to optimize node operations and expand VM management capabilities. The core change involves moving from client-side filtering (fetching all nodes, then filtering locally) to server-side filtering using the API's names parameter (GET v1/nodes/list?names=...). This optimization is applied across multiple node commands including set, release, and extend.

The PR also introduces a new sf nodes get command that allows users to retrieve detailed information about specific nodes by name, leveraging the same API filtering for efficient data retrieval. The extend functionality has been made more resilient by fixing assumptions about extension timing and improving error handling for auto-reserved nodes.

Expanding the VM management suite, the PR adds comprehensive VM image management commands (sf vm images list/upload/show) behind the custom-vm-images feature flag, along with new VM operations like sf vm logs, sf vm replace, and sf vm script. The VM module has been restructured from a monolithic 477-line file into a modular directory structure with separate files for each command.

Additional enhancements include cloud-init user data support in node creation, multipart upload functionality for VM images with progress tracking and retry mechanisms, and various UI improvements like better error handling and more informative output formatting. The schema has been updated to remove admin-specific endpoints while adding new VM image management endpoints.

Confidence score: 2/5

  • This PR contains several critical issues including potential runtime crashes and broken functionality that require immediate attention before merging
  • Score lowered due to a critical bug in src/lib/nodes/release.ts that removes ID-based node lookup, potential runtime crash in src/lib/vm/list.ts, and magic numbers that should be extracted as constants
  • Pay close attention to src/lib/nodes/release.ts, src/lib/vm/list.ts, and src/lib/vm/image/upload.ts

Context used:

Rule - Extract magic numbers into named constants at the top of files with documentation comments explaining their purpose and units. (link)

23 files reviewed, 12 comments

Edit Code Review Bot Settings | Greptile

Comment thread src/lib/vm/logs.ts
Comment thread src/lib/vm/logs.ts
Comment thread src/lib/vm/logs.ts
Comment thread src/lib/vm/image/list.tsx Outdated
Comment thread src/lib/nodes/extend.ts Outdated
Comment thread src/lib/vm/list.ts
Comment thread src/lib/vm/replace.ts
Comment thread src/lib/vm/image/upload.ts
Comment thread src/lib/vm/image/upload.ts
Comment thread src/lib/nodes/release.ts Outdated
@sigmachirality sigmachirality changed the title perf: refactor sf nodes to use GET v1/nodes/list?names=... perf: [PRODUCT-576] refactor sf nodes to use GET v1/nodes/list?names=... Sep 16, 2025
@sigmachirality sigmachirality merged commit 2783756 into main Sep 16, 2025
1 check 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.

4 participants