-
Notifications
You must be signed in to change notification settings - Fork 159
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
fix(BA-19): Broken session CLI commands due to invalid initialization of ComputeSession
#3222
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
80d5bce
fix: broken session rename command
jopemachine 1e125ec
feat: Add session rename test case
jopemachine 2b79591
chore: use variable
jopemachine 4a31197
chore: Change variable name
jopemachine bd852e4
fix: Wrong type declaration
jopemachine 1d74ab0
fix: `commit` session command
jopemachine de51331
fix: `set_priority` command
jopemachine f2b0a4b
fix: Wrong variable name
jopemachine af69563
fix: `events` command
jopemachine f81fe21
fix: Rename wrong variable name
jopemachine bdc8640
fix: uuid -> str
jopemachine 7a93ab2
fix: Add news fragment
jopemachine 8d8e412
fix: Rename `test_rename_session` -> `test_session_command`
jopemachine a31c764
fix: Move test file into proper location
jopemachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fix broken session CLI commands due to invalid initialization of `ComputeSession`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,9 @@ python_tests( | |
"src/ai/backend/client/cli:src", | ||
], | ||
) | ||
|
||
python_test_utils( | ||
sources=[ | ||
"conftest.py", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import pytest | ||
from click.testing import CliRunner | ||
|
||
from ai.backend.cli.loader import load_entry_points | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def runner(): | ||
return CliRunner() | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def cli_entrypoint(): | ||
return load_entry_points(allowlist={"ai.backend.client.cli"}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
python_tests(name="tests") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import pytest | ||
from aioresponses import aioresponses | ||
|
||
from ai.backend.cli.types import ExitCode | ||
from ai.backend.client.config import set_config | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"test_case", | ||
[ | ||
{ | ||
"session_id_or_name": "00000000-0000-0000-0000-000000000000", | ||
"new_session_name": "new-name", | ||
"expected_exit_code": ExitCode.OK, | ||
}, | ||
{ | ||
"session_id_or_name": "mock-session-name", | ||
"new_session_name": "new-name", | ||
"expected_exit_code": ExitCode.OK, | ||
}, | ||
], | ||
ids=["Use session command by uuid", "Use session command by session name"], | ||
) | ||
def test_session_command( | ||
test_case, runner, cli_entrypoint, monkeypatch, example_keypair, unused_tcp_port_factory | ||
): | ||
""" | ||
Test whether the Session CLI commands work correctly when either session_id or session_name is provided as argument. | ||
""" | ||
|
||
api_port = unused_tcp_port_factory() | ||
api_url = "http://127.0.0.1:{}".format(api_port) | ||
|
||
set_config(None) | ||
monkeypatch.setenv("BACKEND_ACCESS_KEY", example_keypair[0]) | ||
monkeypatch.setenv("BACKEND_SECRET_KEY", example_keypair[1]) | ||
monkeypatch.setenv("BACKEND_ENDPOINT", api_url) | ||
monkeypatch.setenv("BACKEND_ENDPOINT_TYPE", "api") | ||
|
||
with aioresponses() as mocked: | ||
session_id_or_name = test_case["session_id_or_name"] | ||
new_session_name = test_case["new_session_name"] | ||
|
||
mocked.post( | ||
f"{api_url}/session/{session_id_or_name}/rename?name={new_session_name}", status=204 | ||
) | ||
|
||
result = runner.invoke( | ||
cli_entrypoint, args=["session", "rename", session_id_or_name, new_session_name] | ||
) | ||
assert result.exit_code == test_case["expected_exit_code"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The intention of the code appears to be to raise a
ValueError
ifsession_name_or_id
is a str that is not aUUID
, and to callfrom_session_id
if it is a session ID. Otherwise, the default constructor is intended to be called.However, when
from_session_id
is called, thename
field is not populated, which causes the code to not function correctly.Additionally, it seems to be a mistake that
owner_access_key
is not set whensession_id
is of UUID type.