Skip to content

Commit

Permalink
Merge pull request #83 from AllysonRosenthal/main
Browse files Browse the repository at this point in the history
Docs review of project cmd
  • Loading branch information
DireLines authored Feb 2, 2024
2 parents 30e6f63 + 2f876b0 commit 085d2c3
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 54 deletions.
4 changes: 2 additions & 2 deletions cmd/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (

var projectCmd = &cobra.Command{
Use: "project [command]",
Short: "manage projects",
Long: "Project management for Runpod projects",
Short: "Manage RunPod projects",
Long: "Develop and deploy projects entirely on RunPod's infrastructure",
}

func init() {
Expand Down
12 changes: 6 additions & 6 deletions cmd/project/exampleDockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
# DockerHub -> https://hub.docker.com/r/runpod/base/tags
FROM <<BASE_IMAGE>>

# The base image comes with many system dependencies pre-installed to help you get started quickly.
# Please refer to the base image's Dockerfile for more information before adding additional dependencies.
# IMPORTANT: The base image overrides the default huggingface cache location.
# The RunPod base image pre-installs many system dependencies to help you get started quickly.
# Check the base image's Dockerfile before adding more dependencies.
# IMPORTANT: The base image overrides the default Hugging Face cache location.

# System dependencies
# if you need additional system dependencies beyond those included in the base image, feel free to add them here
# but be aware those changes will not be reflected in the development pod
# unless you override the base image in runpod.toml to an image that includes them.
# If you need system dependencies that are not included in the base image, add them here.
# You must override the base image in runpod.toml with an image that includes your dependencies
# for changes to propagate to your Project pod.

# Python dependencies
COPY <<REQUIREMENTS_PATH>> /requirements.txt
Expand Down
32 changes: 16 additions & 16 deletions cmd/project/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func attemptPodLaunch(config *toml.Tree, networkVolumeId string, environmentVari
projectConfig := config.Get("project").(*toml.Tree)
//attempt to launch a pod with the given configuration.
for _, gpuType := range selectedGpuTypes {
fmt.Printf("Trying to get a pod with %s... ", gpuType)
fmt.Printf("Trying to get a Pod with %s... ", gpuType)
podEnv := mapToApiEnv(environmentVariables)
input := api.CreatePodInput{
CloudType: "ALL",
Expand Down Expand Up @@ -171,7 +171,7 @@ func attemptPodLaunch(config *toml.Tree, networkVolumeId string, environmentVari
}

func launchDevPod(config *toml.Tree, networkVolumeId string) (string, error) {
fmt.Println("Deploying development pod on RunPod...")
fmt.Println("Deploying project Pod on RunPod...")
//construct env vars
environmentVariables := createEnvVars(config)
// prepare gpu types
Expand All @@ -192,7 +192,7 @@ func launchDevPod(config *toml.Tree, networkVolumeId string) (string, error) {
fmt.Println(err)
return "", err
}
fmt.Printf("Check on pod status at https://www.runpod.io/console/pods/%s\n", new_pod["id"].(string))
fmt.Printf("Check on Pod status at https://www.runpod.io/console/pods/%s\n", new_pod["id"].(string))
return new_pod["id"].(string), nil
}

Expand Down Expand Up @@ -243,10 +243,10 @@ func startProject(networkVolumeId string) error {
//open ssh connection
sshConn, err := PodSSHConnection(projectPodId)
if err != nil {
fmt.Println("error establishing ssh connection to pod: ", err)
fmt.Println("error establishing SSH connection to Pod: ", err)
return err
}
fmt.Println(fmt.Sprintf("Project %s pod (%s) created.", projectName, projectPodId))
fmt.Println(fmt.Sprintf("Project %s Pod (%s) created.", projectName, projectPodId))
//create remote folder structure
projectConfig := config.Get("project").(*toml.Tree)
volumePath := projectConfig.Get("volume_mount_path").(string)
Expand All @@ -257,13 +257,13 @@ func startProject(networkVolumeId string) error {
fmt.Printf("Checking remote project folder: %s on Pod %s\n", remoteProjectPath, projectPodId)
sshConn.RunCommands([]string{fmt.Sprintf("mkdir -p %s %s", remoteProjectPath, projectPathUuidProd)})
//rsync project files
fmt.Printf("Syncing files to pod %s\n", projectPodId)
fmt.Printf("Syncing files to Pod %s\n", projectPodId)
cwd, _ := os.Getwd()
sshConn.Rsync(cwd, projectPathUuidDev, false)
//activate venv on remote
venvPath := "/" + path.Join(projectId, "venv")
archivedVenvPath := path.Join(projectPathUuid, "dev-venv.tar.zst")
fmt.Printf("Activating Python virtual environment %s on pod %s\n", venvPath, projectPodId)
fmt.Printf("Activating Python virtual environment %s on Pod %s\n", venvPath, projectPodId)
sshConn.RunCommands([]string{
fmt.Sprintf(`
if ! [ -f %s/bin/activate ]
Expand All @@ -284,7 +284,7 @@ func startProject(networkVolumeId string) error {
venvPath, remoteProjectPath, config.GetPath([]string{"runtime", "requirements_path"}).(string)),
})
//create file watcher
fmt.Println("Creating file watcher...")
fmt.Println("Creating Project watcher...")
go sshConn.SyncDir(cwd, projectPathUuidDev)
//run launch api server / hot reload loop
pipReqPath := path.Join(remoteProjectPath, config.GetPath([]string{"runtime", "requirements_path"}).(string))
Expand Down Expand Up @@ -321,9 +321,9 @@ func startProject(networkVolumeId string) error {
trap cleanup EXIT SIGINT
if source %s/bin/activate; then
echo -e "- Activated virtual environment."
echo -e "- Activated project environment."
else
echo "Failed to activate virtual environment."
echo "Failed to activate project environment."
exit 1
fi
Expand Down Expand Up @@ -364,9 +364,9 @@ func startProject(networkVolumeId string) error {
while true; do
if changed_file=$(notify_nonignored_file); then
echo "Detected changes in: $changed_file"
echo "Found changes in: $changed_file"
else
echo "Failed to detect changes."
echo "No changes found."
exit 1
fi
Expand All @@ -385,7 +385,7 @@ func startProject(networkVolumeId string) error {
done
`, venvPath, projectPathUuidDev, projectName, venvPath, archivedVenvPath, handlerPath, remoteProjectPath, remoteProjectPath, pipReqPath, handlerPath)
fmt.Println()
fmt.Println("Starting project development endpoint...")
fmt.Println("Starting project endpoint...")
sshConn.RunCommand(launchApiServer)
return nil
}
Expand All @@ -411,17 +411,17 @@ func deployProject(networkVolumeId string) (endpointId string, err error) {
//open ssh connection
sshConn, err := PodSSHConnection(projectPodId)
if err != nil {
fmt.Println("error establishing ssh connection to pod: ", err)
fmt.Println("error establishing SSH connection to Pod: ", err)
return "", err
}
//sync remote dev to remote prod
sshConn.RunCommand(fmt.Sprintf("mkdir -p %s", remoteProjectPath))
fmt.Printf("Syncing files to pod %s prod\n", projectPodId)
fmt.Printf("Syncing files to Pod %s prod\n", projectPodId)
cwd, _ := os.Getwd()
sshConn.Rsync(cwd, projectPathUuidProd, false)
//activate venv on remote
venvPath := path.Join(projectPathUuidProd, "venv")
fmt.Printf("Activating Python virtual environment: %s on pod %s\n", venvPath, projectPodId)
fmt.Printf("Activating Python virtual environment: %s on Pod %s\n", venvPath, projectPodId)
sshConn.RunCommands([]string{
fmt.Sprintf("python%s -m venv %s", config.GetPath([]string{"runtime", "python_version"}).(string), venvPath),
fmt.Sprintf(`source %s/bin/activate &&
Expand Down
36 changes: 18 additions & 18 deletions cmd/project/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func selectStarterTemplate() (template string, err error) {
}
templates, err := starterTemplates.ReadDir("starter_examples")
if err != nil {
fmt.Println("Something went wrong trying to fetch the example")
fmt.Println("Something went wrong trying to fetch the starter project.")
fmt.Println(err)
return "", err
}
Expand Down Expand Up @@ -132,8 +132,8 @@ type NetVolOption struct {
var NewProjectCmd = &cobra.Command{
Use: "create",
Args: cobra.ExactArgs(0),
Short: "create a new project",
Long: "create a new RunPod project folder",
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...")

Expand All @@ -153,20 +153,20 @@ var NewProjectCmd = &cobra.Command{
}

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

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

// Project Summary
fmt.Println("\nProject Summary:")
fmt.Println("------------------------------------------------")
fmt.Printf("Project Name : %s\n", projectName)
fmt.Printf("Starter Example : %s\n", modelType)
fmt.Printf("CUDA Version : %s\n", cudaVersion)
fmt.Printf("Python Version : %s\n", pythonVersion)
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("------------------------------------------------")

// Confirm
Expand All @@ -186,16 +186,16 @@ var NewProjectCmd = &cobra.Command{
// Create Project
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 pod.")
fmt.Println("From your project root run `runpodctl project dev` to start a development session.")
},
}

var StartProjectCmd = &cobra.Command{
Use: "dev",
Aliases: []string{"start"},
Args: cobra.ExactArgs(0),
Short: "start current project",
Long: "start a development pod session for the Runpod project in the current folder",
Short: "starts a development session for the current project",
Long: "connects your local environment and the project environment on your Pod.\nChanges propagate to the project environment in real time.",
Run: func(cmd *cobra.Command, args []string) {
config := loadProjectConfig()
projectId := config.GetPath([]string{"project", "uuid"}).(string)
Expand Down Expand Up @@ -225,8 +225,8 @@ var StartProjectCmd = &cobra.Command{
var DeployProjectCmd = &cobra.Command{
Use: "deploy",
Args: cobra.ExactArgs(0),
Short: "deploy current project",
Long: "deploy an endpoint for the Runpod project in the current folder",
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()
Expand All @@ -241,7 +241,7 @@ var DeployProjectCmd = &cobra.Command{
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.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)
Expand All @@ -251,8 +251,8 @@ var DeployProjectCmd = &cobra.Command{
var BuildProjectCmd = &cobra.Command{
Use: "build",
Args: cobra.ExactArgs(0),
Short: "build Dockerfile for current project",
Long: "build a Dockerfile for the RunPod project in the current folder",
Short: "builds Dockerfile for current project",
Long: "builds a local Dockerfile for the project in the current folder.\nYou can use this Dockerfile to build an image and deploy it to any API server.",
Run: func(cmd *cobra.Command, args []string) {
buildProjectDockerfile()
// config := loadProjectConfig()
Expand Down Expand Up @@ -283,7 +283,7 @@ func init() {
NewProjectCmd.Flags().BoolVarP(&initCurrentDir, "init", "i", false, "use the current directory as the project directory")

StartProjectCmd.Flags().BoolVar(&setDefaultNetworkVolume, "select-volume", false, "select a new default network volume for current project")
StartProjectCmd.Flags().BoolVar(&showPrefixInPodLogs, "prefix-pod-logs", true, "prefix logs from development pod with pod id")
StartProjectCmd.Flags().BoolVar(&showPrefixInPodLogs, "prefix-pod-logs", true, "prefix logs from project Pod with Pod ID")
BuildProjectCmd.Flags().BoolVar(&includeEnvInDockerfile, "include-env", false, "include environment variables from runpod.toml in generated Dockerfile")

}
8 changes: 4 additions & 4 deletions cmd/project/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func getPodSSHInfo(podId string) (podIp string, podPort int, err error) {
return port.Ip, port.PublicPort, nil
}
}
return "", 0, errors.New("no SSH port exposed on pod")
return "", 0, errors.New("no SSH port exposed on Pod")
}

type SSHConnection struct {
Expand Down Expand Up @@ -132,7 +132,7 @@ func (sshConn *SSHConnection) SyncDir(localDir string, remoteDir string) {
time.Sleep(100 * time.Millisecond)
hasChanged, firstModifiedFile := hasChanges(localDir, lastSyncTime)
if hasChanged {
fmt.Printf("Detected changes in %s\n", firstModifiedFile)
fmt.Printf("Found changes in %s\n", firstModifiedFile)
syncFiles()
lastSyncTime = time.Now()
}
Expand Down Expand Up @@ -224,7 +224,7 @@ func PodSSHConnection(podId string) (*SSHConnection, error) {
pollIntervalSeconds := 1
maxPollTimeSeconds := 300
startTime := time.Now()
fmt.Print("Waiting for pod to come online... ")
fmt.Print("Waiting for Pod to come online... ")
//look up ip and ssh port for pod id
var podIp string
var podPort int
Expand All @@ -246,7 +246,7 @@ func PodSSHConnection(podId string) (*SSHConnection, error) {
host := fmt.Sprintf("%s:%d", podIp, podPort)
client, err := ssh.Dial("tcp", host, config)
if err != nil {
fmt.Println("Failed to dial for ssh conn: %s", err)
fmt.Println("Failed to dial for SSH conn: %s", err)
return nil, err
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/project/starter_examples/Hello World/.runpodignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Similar to .gitignore
# Matches will not be synced to the development pod or cause the development pod to reload.
# Matches do not sync to the Project Pod or cause the Pod to reload.

Dockerfile
__pycache__/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Required Python packages get listed here, one per line.
# Recommended to lock the version number to avoid unexpected changes.
# Lock the version number to avoid unexpected changes.

# You can also install packages from a git repository, e.g.:
# git+https://github.com/runpod/runpod-python.git
Expand Down
2 changes: 1 addition & 1 deletion cmd/project/starter_examples/LLM/.runpodignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Similar to .gitignore
# Matches will not be synced to the development pod or cause the development pod to reload.
# Matches do not sync to the Project Pod or cause the Pod to reload.

Dockerfile
__pycache__/
Expand Down
2 changes: 1 addition & 1 deletion cmd/project/starter_examples/LLM/builder/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Required Python packages get listed here, one per line.
# Recommended to lock the version number to avoid unexpected changes.
# Lock the version number to avoid unexpected changes.

# You can also install packages from a git repository, e.g.:
# git+https://github.com/runpod/runpod-python.git
Expand Down
2 changes: 1 addition & 1 deletion cmd/project/starter_examples/LLM/src/handler.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
''' A starter example for a handler file using RunPod and a large language model for text generation. '''
''' A starter handler file using RunPod and a large language model for text generation. '''

import io
import base64
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Similar to .gitignore
# Matches will not be synced to the development pod or cause the development pod to reload.
# Matches do not sync to the Project Pod or cause the Pod to reload.

Dockerfile
__pycache__/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Required Python packages get listed here, one per line.
# Recommended to lock the version number to avoid unexpected changes.
# Lock the version number to avoid unexpected changes.

# You can also install packages from a git repository, e.g.:
# git+https://github.com/runpod/runpod-python.git
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
''' A starter example for a handler file using RunPod and diffusers for image generation. '''
''' A starter handler file using RunPod and diffusers for image generation. '''

import io
import base64
Expand Down

0 comments on commit 085d2c3

Please sign in to comment.