Skip to content

fix 502: portable paths and zero-division guard in llm_simple_qa example#562

Open
Priyanshu6968 wants to merge 1 commit into
kubeedge:mainfrom
Priyanshu6968:fix/issue-502
Open

fix 502: portable paths and zero-division guard in llm_simple_qa example#562
Priyanshu6968 wants to merge 1 commit into
kubeedge:mainfrom
Priyanshu6968:fix/issue-502

Conversation

@Priyanshu6968

Copy link
Copy Markdown

What type of PR is this?

/kind bug

What this PR does / why we need it:
The llm_simple_qa example could not be run in a clean Colab because of machine-specific hardcoded paths, stale config references. This PR solves it.

Which issue(s) this PR fixes:
Fixes #502

@kubeedge-bot kubeedge-bot added the kind/bug Categorizes issue or PR as related to a bug. label Jun 21, 2026
@kubeedge-bot

Copy link
Copy Markdown
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Priyanshu6968
To complete the pull request process, please assign moorezheng after the PR has been reviewed.
You can assign the PR to them by writing /assign @moorezheng in a comment when ready.

The full list of commands accepted by this bot can be found 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

@kubeedge-bot

Copy link
Copy Markdown
Collaborator

Welcome @Priyanshu6968! It looks like this is your first PR to kubeedge/ianvs 🎉

@kubeedge-bot kubeedge-bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jun 21, 2026

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

Copy link
Copy Markdown

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 updates the llm_simple_qa example by replacing absolute local file paths with relative paths and standard Hugging Face model IDs, making the code more portable. It also adds a division-by-zero guard in the accuracy metric calculation. The reviewer noted that this guard is placed too late, as an IndexError can still occur during the list comprehension if the input lengths differ, and recommended validating the inputs at the start of the function.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread examples/llm_simple_qa/testenv/acc.py Outdated
Comment on lines +38 to +40
if not same_elements:
return 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The guard if not same_elements: is introduced to prevent a division-by-zero error. However, if y_true is empty or shorter than y_pred, the list comprehension on line 36 (same_elements = [y_pred[i] == y_true[i] for i in range(len(y_pred))]) will raise an IndexError before this guard is ever reached. To make this function robust against mismatched or empty inputs, the validation should be performed at the beginning of the function.

Signed-off-by: Priyanshu6968 <priyanshunigam469@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Categorizes issue or PR as related to a bug. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Hardcoded absolute paths and unhandled ZeroDivisionError in llm_simple_qa example

2 participants