Skip to content

Commit

Permalink
Github action for tests without GPU
Browse files Browse the repository at this point in the history
  • Loading branch information
movchan74 committed Oct 27, 2023
1 parent 4fc12c4 commit 03f5e49
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 22 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/ actions/automating-builds-and-tests/building-and-testing-python

name: Python package

on:
push:
branches:
- '*' # Runs on push to any branch
pull_request:
branches:
- '*' # Runs on pull requests to any branch
workflow_dispatch: # Allows for manual triggering

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10"]

steps:
- name: Checkout code
uses: actions/checkout@v3
with:
token: ${{ secrets.GH_MOBIUS_PIPELINE_TOKEN }}
submodules: recursive
- name: Bootstrap poetry
run: |
curl -sSL https://install.python-poetry.org | python - -y
- name: Update PATH
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Install dependencies
run: poetry install
- name: Test with pytest
run: poetry run pytest
3 changes: 2 additions & 1 deletion aana/tests/deployments/test_vllm_deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from aana.configs.deployments import deployments
from aana.models.pydantic.sampling_params import SamplingParams
from aana.tests.utils import is_gpu_available


def expected_output(name):
Expand All @@ -27,7 +28,7 @@ def ray_setup(deployment):
handle = serve.run(app, port=port)
return handle


@pytest.mark.skipif(not is_gpu_available(), reason="GPU is not available")
@pytest.mark.asyncio
async def test_vllm_deployments():
for name, deployment in deployments.items():
Expand Down
3 changes: 2 additions & 1 deletion aana/tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,5 @@ def test_app(ray_setup):
f"http://localhost:{port}/lowercase", data={"body": json.dumps(data)}
)
assert response.status_code == 200
assert response.json() == {"lowercase_text": ["hello world!", "this is a test."]}
lowercase_text = response.json().get("lowercase_text")
assert lowercase_text == ["hello world!", "this is a test."]
12 changes: 12 additions & 0 deletions aana/tests/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import torch


def is_gpu_available() -> bool:
"""
Check if a GPU is available.
Returns:
bool: True if a GPU is available, False otherwise.
"""

return torch.cuda.is_available()
41 changes: 21 additions & 20 deletions notebooks/demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,45 +12,46 @@
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"data = {\n",
" 'prompt': '[INST] Who is Elon Musk? [/INST]',\n",
" 'sampling_params' : {\n",
" 'temperature': 0.9,\n",
" }\n",
"}\n",
"\n",
"url = 'http://127.0.0.1:8000/llm/generate'"
]
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'vllm_llama2_7b_chat_output': ' Elon Musk is a South African-born entrepreneur, inventor, and business magnate who is best known for being the CEO of SpaceX and Tesla, Inc. He is one of the most successful and influential entrepreneurs of the 21st century, known for his innovative ideas, visionary leadership, and his ability to bring those ideas to life.\\nMusk was born on June 28, 1971, in Pretoria, South Africa. He developed an interest in computing and programming at an early age and taught himself computer programming. He moved to Canada in 1992 to attend college, and later transferred to the University of Pennsylvania, where he graduated with a degree in economics and physics.\\nAfter college, Musk moved to California to pursue a career in technology and entrepreneurship. He co-founded his first company, Zip2, which provided online content publishing software for news organizations. In 1999, he co-founded X.com, which later became PayPal, an online payment system that was acquired by eBay for $1.5 billion in 2002.\\nIn 2',\n",
"{'vllm_llama2_7b_chat_output': ' Elon Musk is a South African-born entrepreneur, inventor, and business magnate. He is best known for his involvement in revolutionizing multiple industries through his companies, including transportation, energy, and space exploration. Here are some key facts about Elon Musk:\\n\\n1. Early Life and Education: Musk was born on June 28, 1971, in Pretoria, South Africa. He developed an interest in computing and programming at an early age and taught himself computer programming. He moved to Canada in 1992 to attend college, and later transferred to the University of Pennsylvania, where he graduated with a degree in economics and physics.\\n2. Entrepreneurial Career: Musk co-founded his first company, Zip2, which provided online content publishing software for news organizations. In 1999, he co-founded X.com, which later became PayPal, an online payment system that was acquired by eBay for $1.5 billion in 2002.\\n3. SpaceX: In 2002, Musk founded SpaceX, a private aerospace manufacturer and',\n",
" 'execution_time': {'prompt': 0,\n",
" 'sampling_params': 0,\n",
" 'vllm_stream_llama2_7b_chat': 0,\n",
" 'vllm_llama2_7b_chat': 4.421537399291992}}"
" 'vllm_llama2_7b_chat': 3.8096983432769775}}"
]
},
"execution_count": 7,
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data = {\n",
" 'prompt': '[INST] Who is Elon Musk? [/INST]',\n",
" 'sampling_params' : {\n",
" 'temperature': 0.9,\n",
" }\n",
"}\n",
"\n",
"url = 'http://127.0.0.1:8000/llm/generate'\n",
"\n",
"# response = requests.post(url, data={'body': json.dumps(data)})\n",
"response = requests.post(url, json=data)\n",
"response.json()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
Expand Down

0 comments on commit 03f5e49

Please sign in to comment.