Skip to content

Commit

Permalink
fix: naming and prompting
Browse files Browse the repository at this point in the history
  • Loading branch information
justinmerrell committed Feb 12, 2024
1 parent 3e0eadb commit 232f373
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 75 deletions.
2 changes: 1 addition & 1 deletion cmd/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

var projectCmd = &cobra.Command{
Use: "project [command]",
Short: "(NEW) Manage RunPod projects",
Short: "Manage RunPod projects",
Long: "Develop and deploy projects entirely on RunPod's infrastructure.",
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/project/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ func getDefaultModelName(modelType string) string {
switch modelType {
case "LLM":
return "google/flan-t5-base"
case "Stable Diffusion":
case "Stable_Diffusion":
return "stabilityai/sdxl-turbo"
case "Text to Audio":
case "Text_to_Audio":
return "facebook/musicgen-small"
}

Expand Down
70 changes: 39 additions & 31 deletions cmd/project/project.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package project

import (
"bufio"
"cli/api"
"errors"
"fmt"
"os"
"path/filepath"
"strings"

"github.com/manifoldco/promptui"
"github.com/spf13/cobra"
Expand All @@ -24,10 +27,18 @@ var (
const inputPromptPrefix string = " > "

func prompt(message string) string {
var selection string = ""
for selection == "" {
fmt.Print(inputPromptPrefix + message)
fmt.Scanln(&selection)
reader := bufio.NewReader(os.Stdin)
fmt.Print(inputPromptPrefix + message)

selection, err := reader.ReadString('\n')
if err != nil {
fmt.Println("An error occurred while reading input. Please try again.", err)
return prompt(message)
}

selection = strings.TrimSpace(selection)
if selection == "" {
return prompt(message)
}
return selection
}
Expand Down Expand Up @@ -124,10 +135,13 @@ func selectStarterTemplate() (template string, err error) {
}
options := []StarterTemplateOption{}
for _, template := range templates {
options = append(options, StarterTemplateOption{Name: template.Name(), Value: template.Name()})
// For the printed name, replace _ with spaces
var name = template.Name()
name = strings.Replace(name, "_", " ", -1)
options = append(options, StarterTemplateOption{Name: name, Value: template.Name()})
}
getStarterTemplate := promptui.Select{
Label: "Select a Starter Example:",
Label: "Select a Starter Project:",
Items: options,
Templates: promptTemplates,
}
Expand Down Expand Up @@ -157,15 +171,13 @@ var NewProjectCmd = &cobra.Command{

// Project Name
if projectName == "" {
fmt.Print("1. Project Name:\n")
fmt.Print(" Please enter the name of your project.\n")
fmt.Print("Provide a name for your project:\n")
projectName = prompt("")
}
fmt.Print("\n Project name set to '" + projectName + "'.\n\n")

// Project Examples
fmt.Print("2. Starter Example:\n")
fmt.Print(" Choose a starter example to begin with.\n")
fmt.Print("Select a starter project to begin with:\n")

if modelType == "" {
starterExample, err := selectStarterTemplate()
Expand All @@ -178,28 +190,21 @@ var NewProjectCmd = &cobra.Command{
fmt.Println("")

// Model Name
if modelType != "Hello World" {
fmt.Print(" Model Name:\n")
fmt.Print(" Please enter the name of the Hugging Face model you would like to use.\n")
fmt.Print(" Leave blank to use the default model for the selected example.\n > ")
if modelType != "Hello_World" {
fmt.Print(" Enter the name of the Hugging Face model you would like to use:\n")
fmt.Print(" Leave blank to use the default model for the selected project.\n > ")
fmt.Scanln(&modelName)
fmt.Println("")
}

// Project Configuration
fmt.Print("3. Configuration:\n")
fmt.Print(" Let's configure the project environment.\n\n")

// CUDA Version
fmt.Println(" CUDA Version:")
cudaVersion := promptChoice(" Choose a CUDA version for your project.",
cudaVersion := promptChoice("Select a CUDA version for your project:",
[]string{"11.8.0", "12.1.0", "12.2.0"}, "11.8.0")

fmt.Println("\n Using CUDA version: " + cudaVersion)
fmt.Println("\n Using CUDA version: " + cudaVersion + "\n")

// Python Version
fmt.Println("\n Python Version:")
pythonVersion := promptChoice(" Choose a Python version for your project.",
pythonVersion := promptChoice("Select a Python version for your project:",
[]string{"3.8", "3.9", "3.10", "3.11"}, "3.10")

fmt.Println("\n Using Python version: " + pythonVersion)
Expand All @@ -208,7 +213,7 @@ var NewProjectCmd = &cobra.Command{
fmt.Println("\nProject Summary:")
fmt.Println("----------------")
fmt.Printf("- Project Name : %s\n", projectName)
fmt.Printf("- Starter Example : %s\n", modelType)
fmt.Printf("- Starter Project : %s\n", modelType)
fmt.Printf("- CUDA version : %s\n", cudaVersion)
fmt.Printf("- Python version : %s\n", pythonVersion)

Expand All @@ -219,15 +224,18 @@ var NewProjectCmd = &cobra.Command{
return
}

fmt.Printf("\nThe project will be created in the current directory: \n%s\n\n", currentDir)
confirm := promptChoice("Proceed with creation?", []string{"yes", "no"}, "yes")
if confirm != "yes" {
fmt.Println("Project creation cancelled.")
return
projectDir := filepath.Join(currentDir, projectName)
if _, err := os.Stat(projectDir); !os.IsNotExist(err) {
fmt.Printf("\nA directory with the name '%s' already exists in the current path.\n", projectName)
confirm := promptChoice("Continue with overwrite?", []string{"yes", "no"}, "no")
if confirm != "yes" {
fmt.Println("Project creation cancelled.")
return
}
} else {
fmt.Printf("\nCreating project '%s' in directory '%s'\n", projectName, projectDir)
}

fmt.Println("\nCreating project...")

// Create Project
createNewProject(projectName, cudaVersion, pythonVersion, modelType, modelName, initCurrentDir)
fmt.Printf("\nProject %s created successfully! \nNavigate to your project directory with `cd %s`\n\n", projectName, projectName)
Expand Down
62 changes: 21 additions & 41 deletions cmd/project/tomlBuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,23 @@ import (
func generateProjectToml(projectFolder, filename, projectName, cudaVersion, pythonVersion string) {
template := `# RunPod Project Configuration
name = "%s"
[project]
uuid = "%s" # Unique identifier for the project. Generated automatically.
# Base Docker image used for the project environment. Includes essential packages and CUDA support.
# Use 'runpod/base' as a starting point. Customize only if you need additional packages or configurations.
# uuid - Unique identifier for the project. Generated automatically.
# volume_mount_path - Default volume mount path in serverless environment. Changing this may affect data persistence.
# base_image - Base Docker image used for the project environment. Includes essential packages and CUDA support.
# Use 'runpod/base' as a starting point. Customize only if you need additional packages or configurations.
# gpu_types - List of preferred GPU types for your development pod, ordered by priority.
# The pod will use the first available type from this list.
# For a full list of supported GPU types, visit: https://docs.runpod.io/references/gpu-types
# gpu_count - Number of GPUs to allocate for the pod.
# volume_mount_path - Default volume mount path in serverless environment. Changing this may affect data persistence.
# ports - Ports to expose and their protocols. Configure as needed for your application's requirements.
# container_disk_size_gb - Disk space allocated for the container. Adjust according to your project's needs.
uuid = "%s"
base_image = "runpod/base:0.5.0-cuda%s"
# List of preferred GPU types for your development pod, ordered by priority.
# The pod will use the first available type from this list.
# For a full list of supported GPU types, visit: https://docs.runpod.io/references/gpu-types
gpu_types = [
"NVIDIA GeForce RTX 4080", # 16GB
"NVIDIA RTX A4000", # 16GB
Expand All @@ -35,47 +38,26 @@ gpu_types = [
"NVIDIA RTX A6000", # 48GB
"NVIDIA A100 80GB PCIe", # 80GB
]
gpu_count = 1
# Default volume mount path in serverless environment. Changing this may affect data persistence.
volume_mount_path = "/runpod-volume"
# Ports to expose and their protocols. Configure as needed for your application's requirements.
# The base image uses 4040 for FileBrowser, 8080 for FastAPI and 22 for SSH
ports = "4040/http, 8080/http, 22/tcp"
# Disk space allocated for the container. Adjust according to your project's needs.
ports = "4040/http, 8080/http, 22/tcp" # FileBrowser, FastAPI, SSH
container_disk_size_gb = 100
[project.env_vars]
# Environment variables for the pod.
# For full list of base environment variables, visit: https://github.com/runpod/containers/blob/main/official-templates/base/Dockerfile
# POD_INACTIVITY_TIMEOUT - Duration (in seconds) before terminating the pod after the last SSH session ends.
# RUNPOD_DEBUG_LEVEL - Log level for RunPod. Set to 'debug' for detailed logs.
# UVICORN_LOG_LEVEL - Log level for Uvicorn. Set to 'warning' for minimal logs.
# Duration (in seconds) before terminating the pod after the last SSH session ends.
POD_INACTIVITY_TIMEOUT = "120"
RUNPOD_DEBUG_LEVEL = "debug"
UVICORN_LOG_LEVEL = "warning"
# Configurations for caching Hugging Face models and datasets to improve load times and reduce bandwidth.
HF_HOME = "/runpod-volume/.cache/huggingface/"
HF_DATASETS_CACHE = "/runpod-volume/.cache/huggingface/datasets/"
DEFAULT_HF_METRICS_CACHE = "/runpod-volume/.cache/huggingface/metrics/"
DEFAULT_HF_MODULES_CACHE = "/runpod-volume/.cache/huggingface/modules/"
HUGGINGFACE_HUB_CACHE = "/runpod-volume/.cache/huggingface/hub/"
HUGGINGFACE_ASSETS_CACHE = "/runpod-volume/.cache/huggingface/assets/"
# Enable this to use the HF Hub transfer service for faster Hugging Face downloads.
HF_HUB_ENABLE_HF_TRANSFER = "1" # Requires 'hf_transfer' Python package.
# Directories for caching Python dependencies, speeding up subsequent installations.
VIRTUALENV_OVERRIDE_APP_DATA = "/runpod-volume/.cache/virtualenv/"
PIP_CACHE_DIR = "/runpod-volume/.cache/pip/"
[runtime]
# Runtime configuration for the project.
# python_version - Python version to use for the project.
# handler_path - Path to the handler file for the project.
# requirements_path - Path to the requirements file for the project.
python_version = "%s"
handler_path = "src/handler.py"
Expand All @@ -90,7 +72,5 @@ requirements_path = "builder/requirements.txt"
err := os.WriteFile(tomlPath, []byte(content), 0644)
if err != nil {
fmt.Printf("Failed to write the TOML file: %s\n", err)
} else {
fmt.Println("TOML file generated successfully with dynamic content.")
}
}

0 comments on commit 232f373

Please sign in to comment.