-
Notifications
You must be signed in to change notification settings - Fork 105
Rename accelerator_flavor to keep both local and global variables #1783
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -346,8 +346,8 @@ function _handle_test() | |
local notebook_id= | ||
|
||
# Due to existing logic - cuda accelerator value needs to be treated as empty string | ||
local accelerator_flavor="${accelerator_flavor}" | ||
accelerator_flavor="${accelerator_flavor##'cuda'}" | ||
local accelerator="${accelerator_flavor}" | ||
accelerator="${accelerator_flavor##'cuda'}" | ||
Comment on lines
+349
to
+350
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainGood fix; consider collapsing to a single assignment for clarity Keeping Apply this minimal diff: - local accelerator="${accelerator_flavor}"
- accelerator="${accelerator_flavor##'cuda'}"
+ local accelerator="${accelerator_flavor##'cuda'}" Optionally verify no other unintended mutations of 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Look for places removing prefixes from accelerator_flavor (potentially problematic if global)
rg -n -- '\$\{accelerator_flavor##' || true
# Look for any reassignments of accelerator_flavor that depend on its own value
rg -n -- '^\s*accelerator_flavor=.*\$\{accelerator_flavor' || true
# Look for prefix-insertion sites still using accelerator_flavor (should be local accelerator in _handle_test())
rg -n -- '\$\{accelerator_flavor:\+\$accelerator_flavor/' || true Length of output: 283 Collapse redundant The initial local accelerator="${accelerator_flavor}" is immediately overridden by accelerator="${accelerator_flavor##'cuda'}" so you can simplify to a single assignment without changing behavior. Files to update:
Proposed diff: - local accelerator="${accelerator_flavor}"
- accelerator="${accelerator_flavor##'cuda'}"
+ local accelerator="${accelerator_flavor##'cuda'}" 🤖 Prompt for AI Agents
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shellcheck dislikes I would not mess with this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jiridanek, you're absolutely right. ShellCheck would indeed flag The current two-line approach in the PR is the correct pattern for maximum portability: local accelerator="${accelerator_flavor}"
accelerator="${accelerator_flavor##'cuda'}" I withdraw my suggestion to collapse these lines. The fix as implemented properly addresses the original issue while maintaining shell script best practices. Thanks for catching that! 🧠 Learnings used
|
||
|
||
|
||
case "${notebook_workload_name}" in | ||
|
@@ -361,10 +361,10 @@ function _handle_test() | |
notebook_id="${jupyter_trustyai_notebook_id}" | ||
;; | ||
*${jupyter_tensorflow_notebook_id}-*) | ||
notebook_id="${accelerator_flavor:+$accelerator_flavor/}${jupyter_tensorflow_notebook_id}" | ||
notebook_id="${accelerator:+$accelerator/}${jupyter_tensorflow_notebook_id}" | ||
;; | ||
*${jupyter_pytorch_notebook_id}-*) | ||
notebook_id="${accelerator_flavor:+$accelerator_flavor/}${jupyter_pytorch_notebook_id}" | ||
notebook_id="${accelerator:+$accelerator/}${jupyter_pytorch_notebook_id}" | ||
;; | ||
*) | ||
printf '%s\n' "No matching condition found for ${notebook_workload_name}." | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@coderabbitai explain to me what just happened there, I don't understand the Bash magic of
accelerator="${accelerator_flavor##'cuda'}"
, and${accelerator:+$accelerator/},
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jiridanek
Short version:
accelerator="${accelerator_flavor##'cuda'}"
strips the longest match of the pattern from the start of the string.
"${accelerator:+$accelerator/}"
Why: CUDA should have no prefix in paths (default), ROCm should use "rocm/". We compute a local accelerator for path-building without clobbering the global accelerator_flavor (which is still needed later for imagestream selection). If you prefer less “Bash magic,” this is equivalent and a bit more explicit:
If you want, I can rewrite it to this more explicit form for readability.
🧠 Learnings used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need, I see that the tests are now progressing further, looking at https://github.com/daniellutz/odh-notebooks/actions/runs/16835369495/job/47693428021, so this does fix problem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jiridanek Thanks! Glad this unblocked the tests. Nothing else from my side.
🧠 Learnings used
If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jiridanek Great—thanks for confirming. Glad the tests are moving and the fix resolves the issue. No further changes from my side; happy to convert to the explicit case-form later if you ever want it for readability.
✏️ Learnings added
🧠 Learnings used
If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!