Last active
January 31, 2025 11:00
-
-
Save mskrajnowski/c19f593c826b093b151e26e0e6177373 to your computer and use it in GitHub Desktop.
sky show-gpus as CSV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -euo pipefail | |
sky show-gpus "$@" | awk ' | |
BEGIN { skip = 1; skip_heading = 0 } | |
# skip lines until the first GPU table heading | |
skip && /^GPU / { skip = 0; } | |
skip { next; } | |
# skip empty lines | |
/^\s*$/ { next; } | |
# skip following GPU table headings | |
skip_heading && /^GPU / { next; } | |
/^GPU / { skip_heading = 1 } | |
# convert line to CSV | |
{ | |
gsub(/ {2,}/, ","); | |
gsub(/\$ /, ""); | |
while (gsub(/,\-,/, ",,")) {}; | |
gsub(/,\s*$/, ""); | |
print; | |
} | |
' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment