Skip to content

Commit e58188d

Browse files
authored
Merge pull request #2 from BlazBert/main
Updated with the CI pipeline for testing model deployments.
2 parents b1a2629 + 7a644c4 commit e58188d

4 files changed

Lines changed: 76 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Test FastAPI NVG Endpoint
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test-nvg-api:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v3
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v4
19+
with:
20+
python-version: '3.10'
21+
22+
- name: Install test tools
23+
run: pip install requests pytest numpy
24+
25+
- name: Build Docker image
26+
run: docker build -t sl-nvg ./nvg-endpoint
27+
28+
- name: Run container
29+
run: docker run -d -p 8000:8000 --name sl-nvg sl-nvg
30+
31+
- name: Wait for API to be Ready
32+
run: |
33+
for i in {1..10}; do
34+
if curl -s http://localhost:8000/docs; then
35+
echo "API is up!"
36+
break
37+
fi
38+
echo "Waiting for API..."
39+
sleep 3
40+
done
41+
42+
- name: Run API test
43+
run: pytest tests/
44+
45+
- name: Cleanup
46+
run: |
47+
docker stop sl-nvg
48+
docker rm sl-nvg

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,7 @@ This setup enables scalable deployment of your model API endpoint with built-in
113113

114114
## License
115115
GNU General Public License v3.0 see [LICENSE](LICENSE) file for details.
116+
117+
## Acknowledgment
118+
119+
This work was supported by funding from the European Union's Horizon Europe Framework Programme [NANCY](https://nancy-project.eu/) project under Grant Agreement No. 101096456.

loadtesting.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import pickle
55
import numpy as np
66

7+
#added a commet to test something
78

89
# Functions
910
def make_request(url: str, data: List) -> Tuple[float, any]:

tests/test_api.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import requests
2+
from typing import List, Tuple
3+
import requests
4+
import pickle
5+
import numpy as np
6+
7+
# Data
8+
data_url = 'nvg_inference_data.pkl'
9+
# labels = ["Normal", "SlowD", "SuddenD", "SuddenR", "InstaD"]
10+
11+
with open(data_url, 'rb') as f:
12+
data_all = pickle.load(f)
13+
14+
data_t = np.expand_dims(data_all[0], axis=0)
15+
16+
import time
17+
18+
def test_nvg_endpoint():
19+
# Wait for the container to be ready
20+
time.sleep(3)
21+
22+
response = requests.post("http://localhost:8000/NVG", json=data_t.tolist())
23+
assert response.status_code == 200

0 commit comments

Comments
 (0)