project

package
v1.14.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 23, 2024 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BuildProjectDockerfileCmd = &cobra.Command{
	Use:   "build-dockerfile",
	Args:  cobra.ExactArgs(0),
	Short: "builds Dockerfile for current project",
	Long:  "builds a local Dockerfile for the project in the current folder. You can use this Dockerfile to build an image and deploy it to any API server.",
	Run: func(cmd *cobra.Command, args []string) {
		err := buildProjectDockerfile()
		if err != nil {
			log.Fatalf("Error generating endpoint configuration: %v", err)
			return
		}
	},
}
View Source
var DeployProjectCmd = &cobra.Command{
	Use:   "deploy",
	Args:  cobra.ExactArgs(0),
	Short: "deploys your project as an endpoint",
	Long:  "deploys a serverless endpoint for the RunPod project in the current folder",
	Run: func(cmd *cobra.Command, args []string) {
		fmt.Println("Deploying project...")
		networkVolumeId, err := selectNetworkVolume()
		if err != nil {
			return
		}
		endpointId, err := deployProject(networkVolumeId)
		if err != nil {
			fmt.Println("Failed to deploy project: ", err)
			return
		}
		printEndpointSuccess(endpointId)
	},
}
View Source
var DeployProjectFromEndpointConfigCmd = &cobra.Command{
	Use:   "deploy-from-config",
	Args:  cobra.ExactArgs(0),
	Short: "deploys your project as an endpoint",
	Long:  "deploys a serverless endpoint from the provided endpoint config",
	Run: func(cmd *cobra.Command, args []string) {
		fmt.Println("Deploying project...")
		endpointId, err := upsertProjectFromEndpointConfig()
		if err != nil {
			fmt.Println("Failed to deploy project: ", err)
			return
		}
		printEndpointSuccess(endpointId)
	},
}
View Source
var EXCLUDE_PATTERNS = []string{
	"__pycache__/",
	"*.pyc",
	".*.swp",
	".git/",
	"*.tmp",
	"*.log",
}
View Source
var GenerateEndpointConfigCmd = &cobra.Command{
	Use:   "generate-endpoint-config",
	Args:  cobra.ExactArgs(0),
	Short: "generates an endpoint configuration file for the current project",
	Long:  "generates an endpoint configuration file for the current project",
	Run: func(cmd *cobra.Command, args []string) {
		projectDir, err := os.Getwd()
		if err != nil {
			log.Fatalf("Error getting current directory: %v", err)
			return
		}
		projectConfig := loadTomlConfig("runpod.toml")
		projectId := mustGetPathAs[string](projectConfig, "project", "uuid")
		err = buildEndpointConfig(projectDir, projectId)
		if err != nil {
			log.Fatalf("Error generating endpoint configuration: %v", err)
			return
		}
	},
}
View Source
var NewProjectCmd = &cobra.Command{
	Use:     "create",
	Aliases: []string{"new"},
	Args:    cobra.ExactArgs(0),
	Short:   "Creates a new project",
	Long:    "Creates a new RunPod project folder on your local machine.",
	Run: func(cmd *cobra.Command, args []string) {
		fmt.Print("Welcome to the RunPod Project Creator!\n--------------------------------------\n\n")

		if projectName == "" {
			fmt.Print("Provide a name for your project:\n")
			projectName = prompt("")
		}
		fmt.Print("\n   Project name set to '" + projectName + "'.\n\n")

		fmt.Print("Select a starter project to begin with:\n")

		if modelType == "" {
			starterExample, err := selectStarterTemplate()
			modelType = starterExample
			if err != nil {
				modelType = ""
			}
		}

		fmt.Println("")

		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("")
		}

		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 + "\n")

		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)

		fmt.Println("\nProject Summary:")
		fmt.Println("----------------")
		fmt.Printf("- Project Name    : %s\n", projectName)
		fmt.Printf("- Starter Project : %s\n", modelType)
		fmt.Printf("- CUDA version    : %s\n", cudaVersion)
		fmt.Printf("- Python version  : %s\n", pythonVersion)

		currentDir, err := os.Getwd()
		if err != nil {
			fmt.Println("Error getting current directory:", err)
			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)
		}

		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)
		fmt.Println("Tip: Run `runpodctl project dev` to start a development session for your project.")
	},
}
View Source
var StartProjectCmd = &cobra.Command{
	Use:     "dev",
	Aliases: []string{"start"},
	Args:    cobra.ExactArgs(0),
	Short:   "Start a development session for the current project",
	Long:    "This command establishes a connection between your local development environment and your RunPod project environment, allowing for real-time synchronization of changes.",
	Run: func(cmd *cobra.Command, args []string) {

		if _, err := os.Stat("runpod.toml"); os.IsNotExist(err) {
			fmt.Println("No 'runpod.toml' found in the current directory.")
			fmt.Println("Please navigate to your project directory and try again.")
			return
		}

		config := loadTomlConfig("runpod.toml")
		projectId := config.GetPath([]string{"project", "uuid"}).(string)
		networkVolumeId := viper.GetString(fmt.Sprintf("project_volumes.%s", projectId))
		cachedNetVolExists := false
		networkVolumes, err := api.GetNetworkVolumes()
		if err == nil {
			for _, networkVolume := range networkVolumes {
				if networkVolume.Id == networkVolumeId {
					cachedNetVolExists = true
				}
			}
		}
		if setDefaultNetworkVolume || networkVolumeId == "" || !cachedNetVolExists {
			netVolId, err := selectNetworkVolume()
			if err != nil {
				return
			}
			networkVolumeId = netVolId
			viper.Set(fmt.Sprintf("project_volumes.%s", projectId), networkVolumeId)
			viper.WriteConfig()
		}
		startProject(networkVolumeId)
	},
}

Functions

func GetIgnoreList

func GetIgnoreList() ([]string, error)

func ShouldIgnore

func ShouldIgnore(filePath string, ignoreList []string) (bool, error)

Types

type NetVolOption

type NetVolOption struct {
	Name  string // The string to display
	Value string // The actual value to use
}

Define a struct that holds the display string and the corresponding value

type SSHConnection

type SSHConnection struct {
	// contains filtered or unexported fields
}

func PodSSHConnection

func PodSSHConnection(podId string) (*SSHConnection, error)

func (*SSHConnection) Rsync

func (sshConn *SSHConnection) Rsync(localDir string, remoteDir string, quiet bool) error

func (*SSHConnection) RunCommand

func (conn *SSHConnection) RunCommand(command string) error

RunCommand runs a command on the remote pod.

func (*SSHConnection) RunCommands

func (sshConn *SSHConnection) RunCommands(commands []string) error

RunCommands runs a list of commands on the remote pod.

func (*SSHConnection) SyncDir

func (sshConn *SSHConnection) SyncDir(localDir string, remoteDir string)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL