project

package
v0.0.0-...-83a6fd2 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2024 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BuildProjectCmd = &cobra.Command{
	Use:   "build",
	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) {
		buildProjectDockerfile()

	},
}
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
		}
		fmt.Printf("Project deployed successfully! Endpoint ID: %s\n", endpointId)
		fmt.Println("Monitor and edit your endpoint at:")
		fmt.Printf("https://www.runpod.io/console/serverless/user/endpoint/%s\n", endpointId)
		fmt.Println("The following URLs are available:")
		fmt.Printf("    - https://api.runpod.ai/v2/%s/runsync\n", endpointId)
		fmt.Printf("    - https://api.runpod.ai/v2/%s/run\n", endpointId)
		fmt.Printf("    - https://api.runpod.ai/v2/%s/health\n", endpointId)
	},
}
View Source
var EXCLUDE_PATTERNS = []string{
	"__pycache__/",
	"*.pyc",
	".*.swp",
	".git/",
	"*.tmp",
	"*.log",
}
View Source
var NewProjectCmd = &cobra.Command{
	Use:   "create",
	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.Println("Creating a new project...")

		if projectName == "" {
			projectName = prompt("Enter the project name")
		}
		fmt.Println("Project name: " + projectName)

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

		cudaVersion := promptChoice("Select CUDA version [default: 11.8.0]: ",
			[]string{"11.1.1", "11.8.0", "12.1.0"}, "11.8.0")

		pythonVersion := promptChoice("Select Python version [default: 3.10]: ",
			[]string{"3.8", "3.9", "3.10", "3.11"}, "3.10")

		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)
		fmt.Println("------------------------------------------------")

		currentDir, err := os.Getwd()
		if err != nil {
			fmt.Println("Error getting current directory:", err)
			return
		}

		fmt.Printf("\nThe project will be created in the current directory: %s\n", currentDir)
		confirm := promptChoice("Proceed with creation? [yes/no, default: yes]: ", []string{"yes", "no"}, "yes")
		if confirm != "yes" {
			fmt.Println("Project creation cancelled.")
			return
		}

		createNewProject(projectName, cudaVersion, pythonVersion, modelType, modelName, initCurrentDir)
		fmt.Printf("\nProject %s created successfully! Run `cd %s` to change directory to your project.\n", projectName, projectName)
		fmt.Println("From your project root run `runpodctl project dev` to start a development session.")
	},
}
View Source
var StartProjectCmd = &cobra.Command{
	Use:     "dev",
	Aliases: []string{"start"},
	Args:    cobra.ExactArgs(0),
	Short:   "starts a development session for the current project",
	Long:    "connects your local environment and the project environment on your Pod. Changes propagate to the project environment in real time.",
	Run: func(cmd *cobra.Command, args []string) {
		config := loadProjectConfig()
		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