Skip to content

fix vastai fit loop iteration direction#1715

Merged
hami-robot[bot] merged 3 commits intoProject-HAMi:masterfrom
DSFans2014:fix/vastai
Mar 31, 2026
Merged

fix vastai fit loop iteration direction#1715
hami-robot[bot] merged 3 commits intoProject-HAMi:masterfrom
DSFans2014:fix/vastai

Conversation

@DSFans2014
Copy link
Copy Markdown
Contributor

@DSFans2014 DSFans2014 commented Mar 26, 2026

What type of PR is this?

What this PR does / why we need it:

  • fix vastai fit loop iteration direction

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Signed-off-by: james <open4pd@4paradigm.com>
@github-actions github-actions bot added the kind/bug Something isn't working label Mar 26, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a bug in the device fitting logic by reversing the iteration order of devices. This ensures that the Fit function correctly processes available devices, leading to the intended device selection. A corresponding test case has been updated to validate this corrected behavior.

Highlights

  • Loop Iteration Direction: Corrected the iteration direction in the Fit function within pkg/device/vastai/device.go from a forward loop to a backward loop.
  • Test Case Update: Updated an existing test case in pkg/device/vastai/device_test.go to reflect the correct expected device ID (dev-1 instead of dev-0) after the logic change.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@hami-robot hami-robot bot added the size/XS label Mar 26, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request modifies the device fitting logic in pkg/device/vastai/device.go by reversing the iteration order of the devices slice. A related test case in pkg/device/vastai/device_test.go was updated to reflect a change in expected device IDs. A critical issue was identified where the devices slice might contain nil elements, leading to a panic when dereferenced, and a nil check was suggested as an improvement.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
unittests 51.90% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
pkg/device/vastai/device.go 74.87% <100.00%> (-0.13%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: james <open4pd@4paradigm.com>
This reverts commit de57d5b.

Signed-off-by: james <open4pd@4paradigm.com>
@archlitchi
Copy link
Copy Markdown
Member

Is it done, have you tested?

@DSFans2014
Copy link
Copy Markdown
Contributor Author

Is it done, have you tested?

The device selected by the following test using Fit is the second device, which indicates that the traversal is done in reverse order.
https://github.com/DSFans2014/HAMi/blob/c447cabef6221777aa31fdc38e61865f61f2bf21/pkg/device/vastai/device_test.go#L576-L618

Copy link
Copy Markdown
Member

@Shouren Shouren left a comment

Choose a reason for hiding this comment

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

/lgtm

@hami-robot hami-robot bot added the lgtm label Mar 30, 2026
@hami-robot
Copy link
Copy Markdown
Contributor

hami-robot bot commented Mar 31, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: DSFans2014, FouoF

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@hami-robot hami-robot bot added the approved label Mar 31, 2026
@hami-robot hami-robot bot merged commit 6095d7d into Project-HAMi:master Mar 31, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants