Skip to content

Commit b1307e3

Browse files
fixed ci and test_main.py
1 parent 08fbe10 commit b1307e3

File tree

2 files changed

+25
-32
lines changed

2 files changed

+25
-32
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
branches: [ main ]
1010

1111
jobs:
12-
build:
12+
build-and-test:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- name: Checkout Code
@@ -18,10 +18,10 @@ jobs:
1818
- name: Cache pip
1919
uses: actions/cache@v3
2020
with:
21-
path: ~/.cache/pip
22-
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
23-
restore-keys: |
24-
${{ runner.os }}-pip-
21+
path: ~/.cache/pip
22+
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
23+
restore-keys: |
24+
${{ runner.os }}-pip-
2525
2626
- name: Clean up disk space
2727
run: |
@@ -33,12 +33,5 @@ jobs:
3333
- name: Build Docker Image
3434
run: docker build -t classifier .
3535

36-
test:
37-
needs: build
38-
runs-on: ubuntu-latest
39-
steps:
40-
- name: Checkout Code
41-
uses: actions/checkout@v3
42-
4336
- name: Run Tests in Docker Container
4437
run: docker run --rm classifier make test

test_main.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,26 @@ def test_missing_input_image(self):
1414
with self.assertRaises(FileNotFoundError):
1515
main().preprocess_image('/nonexistent/image.jpg')
1616

17-
# def test_tensor_size(self):
18-
# image, img_shape, img_type = main().preprocess_image('/input/resized_image.jpg')
19-
# print(img_shape, img_type)
20-
# self.assertEqual(img_shape, (1,2,3), 'Not Equal Shape')
21-
#
22-
# def test_image_type(self):
23-
# image, img_shape, img_type = main().preprocess_image('/input/resized_image.jpg')
24-
# print(img_shape, img_type)
25-
# self.assertEqual(img_type, int, 'Not Equal Image Type')
26-
#
27-
# def test_image_class(self):
28-
# model = MobileNetV2()
29-
# model.load_state_dict(torch.load("./model/weights/mobilenetv2.pt", weights_only=True)) # weights ported from torchvision
30-
# model.float()
31-
#
32-
# predicted_label = main().inference(model, '/input/resized_image.jpg',
33-
# '/output_raw/output_prediction.txt')
34-
#
35-
# print('Label in output:',predicted_label)
36-
# self.assertEqual(predicted_label, 'Aar', 'Wrong classification')
17+
def test_tensor_size(self):
18+
image, img_shape, img_type = main().preprocess_image('/input/resized_image.jpg')
19+
print(img_shape, img_type)
20+
self.assertEqual(img_shape, (1,2,3), 'Not Equal Shape')
21+
22+
def test_image_type(self):
23+
image, img_shape, img_type = main().preprocess_image('/input/resized_image.jpg')
24+
print(img_shape, img_type)
25+
self.assertEqual(img_type, int, 'Not Equal Image Type')
26+
27+
def test_image_class(self):
28+
model = MobileNetV2()
29+
model.load_state_dict(torch.load("./model/weights/mobilenetv2.pt", weights_only=True)) # weights ported from torchvision
30+
model.float()
31+
32+
predicted_label = main().inference(model, '/input/resized_image.jpg',
33+
'/output_raw/output_prediction.txt')
34+
35+
print('Label in output:',predicted_label)
36+
self.assertEqual(predicted_label, 'Aar', 'Wrong classification')
3737

3838
if __name__ == '__main__':
3939
unittest.main()

0 commit comments

Comments
 (0)