Skip to content

Cli update #301

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

Open
wants to merge 47 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
9050740
CLI Layout and Create RayCluster function (#227)
carsonmh Jul 26, 2023
380f4d3
CLI Authentication (#252)
carsonmh Jul 31, 2023
5107aed
change: use updated auth on get_cluster
carsonmh Jul 31, 2023
2c7f0c7
Cli submit delete raycluster (#257)
carsonmh Aug 2, 2023
3bc9120
add: design doc
carsonmh Aug 3, 2023
a6753d3
add: cli status function
carsonmh Jul 31, 2023
47fda05
add: details cli function
carsonmh Jul 31, 2023
ae451c1
create: function to list rayclusters in all namespaces
carsonmh Jul 27, 2023
9372d4c
add: list raycluster function cli
carsonmh Jul 31, 2023
c213393
test: add unit test for list_clusters_all_namespaces
carsonmh Jul 31, 2023
e41dfab
test: add unit tests for status, details, and list CLI commands
carsonmh Jul 31, 2023
819cf57
cleanup
carsonmh Jul 31, 2023
f548525
fix: unit tests
carsonmh Jul 31, 2023
5937034
change: make namespace required for functions
carsonmh Aug 2, 2023
7ccb625
add: error handling for cluster not found
carsonmh Aug 2, 2023
f190786
add: plural alias to list raycluster
carsonmh Aug 3, 2023
7ee83fd
change: use current namespace when not specified
carsonmh Aug 3, 2023
ec3059e
refactor: make _get_all_rayclusters which handles namespaced and all …
carsonmh Aug 3, 2023
1a94b26
cleanup
carsonmh Aug 3, 2023
61e6723
create: CLI job define command
carsonmh Aug 3, 2023
26d00a1
create: submit job command cli
carsonmh Aug 3, 2023
6e4bcac
fix: login help message no longer has ellipsis
carsonmh Aug 3, 2023
7ad8127
test: unit tests for submit define job
carsonmh Aug 3, 2023
bc8113f
fix: typo
carsonmh Aug 4, 2023
245dde1
change: make submit job use current namespace
carsonmh Aug 4, 2023
25104f2
change: make load_auth only happen on login command
carsonmh Aug 4, 2023
0c28afd
add: raycluster not found error handling
carsonmh Aug 7, 2023
f4aff67
make define params required and refactor job submit
carsonmh Aug 9, 2023
64a8e45
create: list_jobs and get_job functions
carsonmh Aug 3, 2023
2e4fdca
create: list jobs CLI command
carsonmh Aug 3, 2023
2c8f81a
create: job status command
carsonmh Aug 3, 2023
a611267
create: cancel job function
carsonmh Aug 8, 2023
979aaa4
create: jobs logs command
carsonmh Aug 8, 2023
1e81b8f
change: slightly change messages and namespace options for job status…
carsonmh Aug 8, 2023
216d255
add: error handling and refactor to main CLI
carsonmh Aug 8, 2023
4f652fd
test: change tests for job functions, refactor tests and add tests fo…
carsonmh Aug 8, 2023
8f72ab4
cleanup
carsonmh Aug 8, 2023
f256b45
make list command list all resources by default
carsonmh Aug 9, 2023
65925d3
fix unit tests
carsonmh Aug 9, 2023
df432c5
fix description of list jobs/rayclusters and change --no-ray flag
carsonmh Aug 9, 2023
83e8367
fix unit tests and list function
carsonmh Aug 10, 2023
c8206e5
add and implement option to not generate appwrapper in a Cluster
carsonmh Aug 8, 2023
4208ef8
Change create_app_wrapper description
carsonmh Aug 10, 2023
fb502f6
fix down function if no name available and changed up to create an ap…
carsonmh Aug 10, 2023
de3af4f
refactor and cleanup cli unit tests
carsonmh Aug 11, 2023
a03ec9c
fix CLI tests
carsonmh Aug 11, 2023
27c24a6
refactor unit tests
carsonmh Aug 11, 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
Prev Previous commit
Next Next commit
test: add unit tests for status, details, and list CLI commands
  • Loading branch information
carsonmh committed Aug 11, 2023
commit e41dfabd2ae08dbb5d9ebab98c27e8faacee38e9
129 changes: 129 additions & 0 deletions tests/unit_test.py
Original file line number Diff line number Diff line change
@@ -236,6 +236,135 @@ def test_list_clusters_all_namespaces(mocker, capsys):
)


def test_raycluster_details_cli(mocker):
runner = CliRunner()
mocker.patch(
"kubernetes.client.CustomObjectsApi.list_namespaced_custom_object",
side_effect=get_ray_obj,
)
mocker.patch(
"codeflare_sdk.cluster.cluster.get_current_namespace",
return_value="ns",
)
mocker.patch(
"codeflare_sdk.cluster.cluster.Cluster.status",
return_value=(False, CodeFlareClusterStatus.UNKNOWN),
)
mocker.patch(
"codeflare_sdk.cluster.cluster.Cluster.cluster_dashboard_uri",
return_value="",
)
mocker.patch.object(client, "ApiClient")
raycluster_details_command = """
details raycluster quicktest
"""
result = runner.invoke(cli, raycluster_details_command)
quicktest_details = (
" ╭──────────────────────────────────────────────────────────────╮ \n"
+ " │ Name │ \n"
+ " │ quicktest Inactive ❌ │ \n"
+ " │ │ \n"
+ " │ URI: ray://quicktest-head-svc.ns.svc:10001 │ \n"
+ " │ │ \n"
+ " │ Dashboard🔗 │ \n"
+ " │ │ \n"
+ " │ Cluster Resources │ \n"
+ " │ ╭─ Workers ──╮ ╭───────── Worker specs(each) ─────────╮ │ \n"
+ " │ │ Min Max │ │ Memory CPU GPU │ │ \n"
+ " │ │ │ │ │ │ \n"
+ " │ │ 1 1 │ │ 2~2 1 0 │ │ \n"
+ " │ │ │ │ │ │ \n"
+ " │ ╰────────────╯ ╰──────────────────────────────────────╯ │ \n"
+ " ╰──────────────────────────────────────────────────────────────╯ "
)
assert quicktest_details in result.output


def test_raycluster_status_cli(mocker):
runner = CliRunner()
test_raycluster = RayCluster(
"quicktest",
RayClusterStatus.READY,
1,
1,
"1",
"1",
1,
1,
"default",
"dashboard-url",
)
mocker.patch(
"kubernetes.client.CustomObjectsApi.list_namespaced_custom_object",
side_effect=get_ray_obj,
)
mocker.patch(
"codeflare_sdk.cluster.cluster.get_current_namespace",
return_value="ns",
)
mocker.patch(
"codeflare_sdk.cluster.cluster.Cluster.cluster_dashboard_uri",
return_value="",
)
mocker.patch(
"codeflare_sdk.cluster.cluster._app_wrapper_status",
return_value=test_raycluster,
)
mocker.patch(
"codeflare_sdk.cluster.cluster._ray_cluster_status",
return_value=test_raycluster,
)
mocker.patch.object(client, "ApiClient")
raycluster_status_command = """
status raycluster quicktest
"""
result = runner.invoke(cli, raycluster_status_command)
assert "Active" in result.output


def test_raycluster_list_cli(mocker):
runner = CliRunner()
mocker.patch(
"kubernetes.client.CustomObjectsApi.list_namespaced_custom_object",
side_effect=get_ray_obj,
)
mocker.patch(
"codeflare_sdk.cluster.cluster.get_current_namespace",
return_value="ns",
)
mocker.patch(
"codeflare_sdk.cluster.cluster.Cluster.status",
return_value=(False, CodeFlareClusterStatus.UNKNOWN),
)
mocker.patch(
"codeflare_sdk.cluster.cluster.Cluster.cluster_dashboard_uri",
return_value="",
)
mocker.patch.object(client, "ApiClient")
list_rayclusters_command = """
list rayclusters --namespace=ns
"""
result = runner.invoke(cli, list_rayclusters_command)
assert (
" ╭──────────────────────────────────────────────────────────────╮ \n"
+ " │ Name │ \n"
+ " │ quicktest Active ✅ │ \n"
+ " │ │ \n"
+ " │ URI: ray://quicktest-head-svc.ns.svc:10001 │ \n"
+ " │ │ \n"
+ " │ Dashboard🔗 │ \n"
+ " │ │ \n"
+ " │ Cluster Resources │ \n"
+ " │ ╭─ Workers ──╮ ╭───────── Worker specs(each) ─────────╮ │ \n"
+ " │ │ Min Max │ │ Memory CPU GPU │ │ \n"
+ " │ │ │ │ │ │ \n"
+ " │ │ 1 1 │ │ 2G~2G 1 0 │ │ \n"
+ " │ │ │ │ │ │ \n"
+ " │ ╰────────────╯ ╰──────────────────────────────────────╯ │ \n"
+ " ╰──────────────────────────────────────────────────────────────╯ "
) in result.output


# For mocking openshift client results
fake_res = openshift.Result("fake")