-
Notifications
You must be signed in to change notification settings - Fork 267
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
[CI] Add AI Runtime test case #197
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d9bbe7e
test: add metrics test case
brosoul 441d115
fix&test: fix assert bucket name path logic
brosoul 19d7af6
add hf repo not exist valid in _valid_config
brosoul 44a8c83
test: add test case about huggingface downloader
brosoul 2121bfd
style format and linter
brosoul b57cc5b
ci: add python test
brosoul 7849bfa
format
brosoul 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
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 |
---|---|---|
|
@@ -70,10 +70,10 @@ def __init__(self, model_uri): | |
|
||
def _valid_config(self): | ||
assert ( | ||
self.bucket_name is not None or self.bucket_name == "" | ||
self.bucket_name is not None and self.bucket_name != "" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's split the feature the CI test in separate PRs in future |
||
), "S3 bucket name is not set." | ||
assert ( | ||
self.bucket_path is not None or self.bucket_path == "" | ||
self.bucket_path is not None and self.bucket_path != "" | ||
), "S3 bucket path is not set." | ||
try: | ||
self.client.head_bucket(Bucket=self.bucket_name) | ||
|
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
Empty file.
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,39 @@ | ||
# Copyright 2024 The Aibrix Team. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import pytest | ||
|
||
from aibrix.downloader.base import get_downloader | ||
from aibrix.downloader.huggingface import HuggingFaceDownloader | ||
|
||
|
||
def test_get_downloader_hf(): | ||
downloader = get_downloader("facebook/opt-125m") | ||
assert isinstance(downloader, HuggingFaceDownloader) | ||
|
||
|
||
def test_get_downloader_hf_not_exist(): | ||
with pytest.raises(AssertionError) as exception: | ||
get_downloader("not_exsit_path/model") | ||
assert "not exist" in str(exception.value) | ||
|
||
|
||
def test_get_downloader_hf_invalid_uri(): | ||
with pytest.raises(AssertionError) as exception: | ||
get_downloader("single_field") | ||
assert "Model uri must be in `repo/name` format." in str(exception.value) | ||
|
||
with pytest.raises(AssertionError) as exception: | ||
get_downloader("multi/filed/repo") | ||
assert "Model uri must be in `repo/name` format." in str(exception.value) |
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,72 @@ | ||
# Copyright 2024 The Aibrix Team. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from unittest import mock | ||
|
||
import pytest | ||
|
||
from aibrix.downloader.base import get_downloader | ||
from aibrix.downloader.s3 import S3Downloader | ||
|
||
S3_BOTO3_MODULE = "aibrix.downloader.s3.boto3" | ||
|
||
|
||
def mock_not_exsit_boto3(mock_boto3): | ||
mock_client = mock.Mock() | ||
mock_boto3.client.return_value = mock_client | ||
mock_client.head_bucket.side_effect = Exception("head bucket error") | ||
|
||
|
||
def mock_exsit_boto3(mock_boto3): | ||
mock_client = mock.Mock() | ||
mock_boto3.client.return_value = mock_client | ||
mock_client.head_bucket.return_value = mock.Mock() | ||
|
||
|
||
@mock.patch(S3_BOTO3_MODULE) | ||
def test_get_downloader_s3(mock_boto3): | ||
mock_exsit_boto3(mock_boto3) | ||
|
||
downloader = get_downloader("s3://bucket/path") | ||
assert isinstance(downloader, S3Downloader) | ||
|
||
|
||
@mock.patch(S3_BOTO3_MODULE) | ||
def test_get_downloader_s3_path_not_exist(mock_boto3): | ||
mock_not_exsit_boto3(mock_boto3) | ||
|
||
with pytest.raises(AssertionError) as exception: | ||
get_downloader("s3://bucket/not_exsit_path") | ||
assert "not exist" in str(exception.value) | ||
|
||
|
||
@mock.patch(S3_BOTO3_MODULE) | ||
def test_get_downloader_s3_path_empty(mock_boto3): | ||
mock_exsit_boto3(mock_boto3) | ||
|
||
# Bucket name and path both are empty, | ||
# will first assert the name | ||
with pytest.raises(AssertionError) as exception: | ||
get_downloader("s3://") | ||
assert "S3 bucket name is not set." in str(exception.value) | ||
|
||
|
||
@mock.patch(S3_BOTO3_MODULE) | ||
def test_get_downloader_s3_path_empty_path(mock_boto3): | ||
mock_exsit_boto3(mock_boto3) | ||
|
||
# bucket path is empty | ||
with pytest.raises(AssertionError) as exception: | ||
get_downloader("s3://bucket/") | ||
assert "S3 bucket path is not set." in str(exception.value) |
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,72 @@ | ||
# Copyright 2024 The Aibrix Team. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from unittest import mock | ||
|
||
import pytest | ||
|
||
from aibrix.downloader.base import get_downloader | ||
from aibrix.downloader.tos import TOSDownloader | ||
|
||
TOS_MODULE = "aibrix.downloader.tos.tos" | ||
|
||
|
||
def mock_not_exsit_tos(mock_tos): | ||
mock_client = mock.Mock() | ||
mock_tos.TosClientV2.return_value = mock_client | ||
mock_client.head_bucket.side_effect = Exception("head bucket error") | ||
|
||
|
||
def mock_exsit_tos(mock_tos): | ||
mock_client = mock.Mock() | ||
mock_tos.TosClientV2.return_value = mock_client | ||
mock_client.head_bucket.return_value = mock.Mock() | ||
|
||
|
||
@mock.patch(TOS_MODULE) | ||
def test_get_downloader_s3(mock_tos): | ||
mock_exsit_tos(mock_tos) | ||
|
||
downloader = get_downloader("tos://bucket/path") | ||
assert isinstance(downloader, TOSDownloader) | ||
|
||
|
||
@mock.patch(TOS_MODULE) | ||
def test_get_downloader_s3_path_not_exist(mock_tos): | ||
mock_not_exsit_tos(mock_tos) | ||
|
||
with pytest.raises(AssertionError) as exception: | ||
get_downloader("tos://bucket/not_exsit_path") | ||
assert "not exist" in str(exception.value) | ||
|
||
|
||
@mock.patch(TOS_MODULE) | ||
def test_get_downloader_s3_path_empty(mock_tos): | ||
mock_exsit_tos(mock_tos) | ||
|
||
# Bucket name and path both are empty, | ||
# will first assert the name | ||
with pytest.raises(AssertionError) as exception: | ||
get_downloader("tos://") | ||
assert "TOS bucket name is not set." in str(exception.value) | ||
|
||
|
||
@mock.patch(TOS_MODULE) | ||
def test_get_downloader_s3_path_empty_path(mock_tos): | ||
mock_exsit_tos(mock_tos) | ||
|
||
# bucket path is empty | ||
with pytest.raises(AssertionError) as exception: | ||
get_downloader("tos://bucket/") | ||
assert "TOS bucket path is not set." in str(exception.value) |
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,35 @@ | ||
# Copyright 2024 The Aibrix Team. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
import pytest | ||
|
||
from aibrix.metrics.engine_rules import get_metric_standard_rules | ||
|
||
|
||
def test_get_metric_standard_rules_ignore_case(): | ||
# Engine str is all lowercase | ||
rules = get_metric_standard_rules("vllm") | ||
assert rules is not None | ||
|
||
# The function get_metric_standard_rules is case-insensitive | ||
rules2 = get_metric_standard_rules("vLLM") | ||
assert rules == rules2 | ||
|
||
|
||
def test_get_metric_standard_rules_not_support(): | ||
# SGLang and TensorRT-LLM are not supported | ||
with pytest.raises(ValueError): | ||
get_metric_standard_rules("SGLang") | ||
|
||
with pytest.raises(ValueError): | ||
get_metric_standard_rules("TensorRT-LLM") |
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.
this is the remote request? if hugging face repo is not accessible from CN machines, does it still work?
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.
I expect this network issue to be bypassed using the
HF_ENDPOINT
env setting