MCPcopy Create free account
hub / github.com/Thunder-Compute/thunder-cli / renderComputeStep

Method renderComputeStep

tui/modify.go:696–751  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

694}
695
696func (m modifyModel) renderComputeStep() string {
697 var s strings.Builder
698
699 if m.gpuCountPhase {
700 s.WriteString("Select number of GPUs:\n\n")
701
702 currentNumGPUs, _ := strconv.Atoi(m.currentInstance.NumGPUs)
703 gpuCounts := m.specs.GPUCounts(m.config.GPUType)
704 for i, num := range gpuCounts {
705 option := fmt.Sprintf("%d GPU(s)", num)
706
707 if num == currentNumGPUs {
708 option += " [current]"
709 }
710
711 cursor := " "
712 if m.cursor == i {
713 cursor = m.styles.Cursor.Render("▶ ")
714 }
715 if !m.specs.IsSpecAvailable(m.config.GPUType, num) {
716 option = subtleTextStyle.Render(option + " (unavailable)")
717 } else if m.cursor == i {
718 option = m.styles.Selected.Render(option)
719 }
720 s.WriteString(fmt.Sprintf("%s%s\n", cursor, option))
721 }
722 if len(gpuCounts) > 0 && !m.specs.IsSpecAvailable(m.config.GPUType, gpuCounts[m.cursor]) {
723 s.WriteString("\n")
724 s.WriteString(warningStyleTUI.Render("This GPU count is currently unavailable. Choose another count."))
725 s.WriteString("\n")
726 }
727 } else {
728 ramPerVCPU := m.specs.RamPerVCPU(m.config.GPUType, m.config.NumGPUs)
729 s.WriteString(fmt.Sprintf("Select vCPU count (%dGB RAM per vCPU):\n\n", ramPerVCPU))
730
731 currentVCPUs, _ := strconv.Atoi(m.currentInstance.CPUCores)
732 vcpuOptions := m.specs.VCPUOptions(m.config.GPUType, m.config.NumGPUs)
733 for i, vcpus := range vcpuOptions {
734 ram := vcpus * ramPerVCPU
735 option := fmt.Sprintf("%d vCPUs (%d GB RAM)", vcpus, ram)
736
737 if vcpus == currentVCPUs {
738 option += " [current]"
739 }
740
741 cursor := " "
742 if m.cursor == i {
743 cursor = m.styles.Cursor.Render("▶ ")
744 option = m.styles.Selected.Render(option)
745 }
746 s.WriteString(fmt.Sprintf("%s%s\n", cursor, option))
747 }
748 }
749
750 return s.String()
751}
752
753func (m modifyModel) renderDiskSizeStep() string {

Callers 1

ViewMethod · 0.95

Calls 4

GPUCountsMethod · 0.80
IsSpecAvailableMethod · 0.80
RamPerVCPUMethod · 0.80
VCPUOptionsMethod · 0.80

Tested by

no test coverage detected