Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.3.1 prep #194

Merged
merged 30 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
219f225
feat: dropdown of user's network volumes
DireLines Oct 30, 2023
de11899
Update generated VHS GIF
actions-user Oct 30, 2023
ccaa761
linter doesn't like lambdas
DireLines Oct 30, 2023
4cc56a1
Merge branch 'networkVolumeDropdown' of github.com:DireLines/runpod-p…
DireLines Oct 30, 2023
dcc8d57
Update generated VHS GIF
actions-user Oct 30, 2023
896a8e3
no qmark
DireLines Oct 30, 2023
81243cc
Merge branch 'networkVolumeDropdown' of github.com:DireLines/runpod-p…
DireLines Oct 30, 2023
53dab14
Update generated VHS GIF
actions-user Oct 30, 2023
e0e5843
Merge pull request #192 from DireLines/networkVolumeDropdown
justinmerrell Oct 30, 2023
e0f4b83
Update generated VHS GIF
actions-user Oct 30, 2023
3d47053
fix: resulting amark
justinmerrell Oct 30, 2023
94c6a10
Merge branch '1.3.1-prep' of https://github.com/runpod/runpod-python …
justinmerrell Oct 30, 2023
73ffb41
Update generated VHS GIF
actions-user Oct 30, 2023
3133926
Update vhs.yml
justinmerrell Oct 30, 2023
3fb7fc3
Merge branch '1.3.1-prep' of https://github.com/runpod/runpod-python …
justinmerrell Oct 30, 2023
0bc655f
Update CHANGELOG.md
justinmerrell Oct 30, 2023
7aba34f
fix: handle user has no volumes
DireLines Oct 30, 2023
cfba8aa
Merge branch 'runpod:main' into networkVolumeDropdown
DireLines Oct 30, 2023
6503413
Merge branch '1.3.1-prep' into networkVolumeDropdown
DireLines Oct 30, 2023
91eae84
Merge pull request #193 from DireLines/networkVolumeDropdown
justinmerrell Oct 30, 2023
c5c17b3
Update functions.py
justinmerrell Oct 30, 2023
89d04a6
fix: no network
justinmerrell Oct 31, 2023
ddd39cc
Update test_project_commands.py
justinmerrell Oct 31, 2023
1cfd85b
Update test_project_commands.py
justinmerrell Oct 31, 2023
b267fa2
Update test_project_commands.py
justinmerrell Oct 31, 2023
9d3aeb5
fix: tests
justinmerrell Oct 31, 2023
faf0a29
Update test_project_commands.py
justinmerrell Oct 31, 2023
9adc817
Update test_project_commands.py
justinmerrell Oct 31, 2023
ef8d888
Update test_project_commands.py
justinmerrell Oct 31, 2023
5bc87c2
fix: missing test
justinmerrell Oct 31, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/vhs.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: vhs
on:
push:
branches-ignore:
- main
# push:
# branches-ignore:
# - main

workflow_dispatch:

Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Change Log

## Release 1.3.1 (10/29/23)
## Release 1.3.1 (10/30/23)

### Added

Expand Down
Binary file modified docs/cli/demos/config.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/cli/demos/help.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/cli/demos/ssh.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pillow >= 9.5.0
prettytable >= 3.8.0
py-cpuinfo >= 9.0.0
python-dotenv >= 1.0.0
inquirerpy == 0.3.4
requests >= 2.31.0
tomli >= 2.0.1
tomlkit >= 0.12.1
Expand Down
29 changes: 27 additions & 2 deletions runpod/cli/groups/project/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
'''

import os
import sys
import click
from InquirerPy import prompt as cli_select

from runpod import get_user
from .functions import (
create_new_project, launch_project, start_project_api, create_project_endpoint
)
Expand All @@ -24,6 +27,12 @@ def project_cli():
@click.option('--init', '-i', 'init_current_dir', is_flag=True, default=False)
def new_project_wizard(project_name, model_type, model_name, init_current_dir):
""" Create a new project. """
network_volumes = get_user()['networkVolumes']
if len(network_volumes) == 0:
click.echo("You do not have any network volumes.")
click.echo("Please create a network volume (https://runpod.io/console/user/storage) and try again.") # pylint: disable=line-too-long
sys.exit(1)

click.echo("Creating a new project...")

if init_current_dir:
Expand All @@ -34,8 +43,24 @@ def new_project_wizard(project_name, model_type, model_name, init_current_dir):

validate_project_name(project_name)

runpod_volume_id = click.prompt(
" > Enter a network storage ID (https://runpod.io/console/user/storage)", type=str)
def print_net_vol(vol):
return {
'name':f"{vol['id']}: {vol['name']} ({vol['size']} GB, {vol['dataCenterId']})",
'value':vol['id']
}

network_volumes = list(map(print_net_vol,network_volumes))
questions = [
{
'type': 'rawlist',
'name': 'volume-id',
'qmark': '',
'amark': '',
'message': ' > Select a Network Volume:',
'choices': network_volumes
}
]
runpod_volume_id = cli_select(questions)['volume-id']

python_version = click.prompt(
" > Select a Python version, or press enter to use the default",
Expand Down
2 changes: 1 addition & 1 deletion runpod/cli/groups/project/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def create_new_project(project_name, runpod_volume_id, python_version, # pylint:
project_table = table()
project_table.add("uuid", project_uuid)
project_table.add("name", project_name)
project_table.add("base_image", "runpod/base:0.1.0")
project_table.add("base_image", "runpod/base:0.2.1")
project_table.add("gpu_types", [
"NVIDIA RTX A4000", "NVIDIA RTX A4500", "NVIDIA RTX A5000",
"NVIDIA GeForce RTX 3090", "NVIDIA RTX A6000"])
Expand Down
30 changes: 25 additions & 5 deletions tests/test_cli/test_cli_groups/test_project_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,30 @@ class TestProjectCLI(unittest.TestCase):
def setUp(self):
self.runner = CliRunner()

def test_new_project_wizard_no_network_volumes(self):
'''
Tests the new_project_wizard command with no network volumes.
'''
with patch('runpod.cli.groups.project.commands.get_user') as mock_get_user:
mock_get_user.return_value = {'networkVolumes':[]}

result = self.runner.invoke(new_project_wizard)

self.assertEqual(result.exit_code, 1)
self.assertIn("You do not have any network volumes.", result.output)

def test_new_project_wizard_success(self):
'''
Tests the new_project_wizard command.
'''
with patch('click.prompt') as mock_prompt, \
patch('click.confirm', return_value=True) as mock_confirm, \
patch('runpod.cli.groups.project.commands.create_new_project') as mock_create:

mock_prompt.side_effect = ['TestProject', 'XYZ_VOLUME', '3.10']
patch('runpod.cli.groups.project.commands.create_new_project') as mock_create, \
patch('runpod.cli.groups.project.commands.get_user') as mock_get_user, \
patch('runpod.cli.groups.project.commands.cli_select') as mock_select:
mock_get_user.return_value = {'networkVolumes':[{ 'id': 'XYZ_VOLUME', 'name': 'XYZ_VOLUME', 'size': 100, 'dataCenterId': 'XYZ' }]} # pylint: disable=line-too-long
mock_prompt.side_effect = ['TestProject', '3.10']
mock_select.return_value = {'volume-id': 'XYZ_VOLUME'}

result = self.runner.invoke(new_project_wizard, ['--type', 'llama2', '--model', 'meta-llama/Llama-2-7b']) # pylint: disable=line-too-long

Expand All @@ -43,8 +57,11 @@ def test_new_project_wizard_success_init_current_dir(self):
with patch('click.prompt') as mock_prompt, \
patch('click.confirm', return_value=True) as mock_confirm, \
patch('runpod.cli.groups.project.commands.create_new_project') as mock_create, \
patch('runpod.cli.groups.project.commands.get_user') as mock_get_user, \
patch('runpod.cli.groups.project.commands.cli_select') as mock_select, \
patch('os.getcwd') as mock_getcwd:

mock_get_user.return_value = {'networkVolumes':[{ 'id': 'XYZ_VOLUME', 'name': 'XYZ_VOLUME', 'size': 100, 'dataCenterId': 'XYZ' }]} # pylint: disable=line-too-long
mock_select.return_value = {'volume-id': 'XYZ_VOLUME'}
mock_prompt.side_effect = ['XYZ_VOLUME', '3.10']

self.runner.invoke(new_project_wizard, ['--init'])
Expand All @@ -56,7 +73,10 @@ def test_new_project_wizard_invalid_name(self):
'''
Tests the new_project_wizard command with an invalid project name.
'''
result = self.runner.invoke(new_project_wizard, ['--name', 'Invalid/Name'])
with patch('runpod.cli.groups.project.commands.get_user') as mock_get_user:
mock_get_user.return_value = {'networkVolumes':["XYZ_VOLUME"]}

result = self.runner.invoke(new_project_wizard, ['--name', 'Invalid/Name'])

self.assertEqual(result.exit_code, 2)
self.assertIn("Project name contains an invalid character", result.output)
Expand Down