-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from datalab-mi/develop
v1.1 Develop
- Loading branch information
Showing
59 changed files
with
6,868 additions
and
9,416 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: CI for pr | ||
on: | ||
pull_request: | ||
types: [opened, reopened, synchronize] | ||
|
||
jobs: | ||
tag-pr: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v2 | ||
- name: Tag PR | ||
uses: release-drafter/release-drafter@v5 | ||
with: | ||
name: PR ${{ github.ref }} | ||
prerelease: true | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
check-files-modified: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
changed_files: ${{ steps.changed-files.outputs.all_modified_files }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Verify Changed files | ||
uses: tj-actions/[email protected] | ||
id: changed-files | ||
with: | ||
base_sha: ${{ github.event.pull_request.base.sha }} | ||
|
||
build-backend-and-test: | ||
runs-on: ubuntu-latest | ||
needs: check-files-modified | ||
if: ( contains(needs.check-files-modified.outputs.changed_files, 'backend') ) | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Build docker image for tests | ||
run: docker build --target test -t basegun-back:tests backend/ | ||
- name: Start container | ||
run: docker run --rm --name basegun_back_test -d basegun-back:tests | ||
- name: Run tests | ||
run: docker exec basegun_back_test python -m unittest discover -v |
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 |
---|---|---|
|
@@ -6,4 +6,4 @@ env/ | |
__pycache__ | ||
weights/ | ||
temp/ | ||
openrc.sh | ||
openrc.sh |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,42 @@ | ||
import sys | ||
import unittest | ||
import os | ||
import requests | ||
from PIL import Image, ImageChops | ||
from src.main import PATH_IMGS | ||
|
||
class TestModel(unittest.TestCase): | ||
def __init__(self, *args, **kwargs): | ||
super(TestModel, self).__init__(*args, **kwargs) | ||
self.url = "http://localhost:5000" | ||
self.assertTrue(os.path.exists(PATH_IMGS)) | ||
|
||
def test_home(self): | ||
"""Checks that the route / is alive""" | ||
r = requests.get(self.url) | ||
self.assertEqual(r.text, "Basegun backend") | ||
|
||
def test_upload(self): | ||
"""Checks that the file upload works properly""" | ||
path = os.path.join( | ||
os.path.dirname(os.path.abspath(__file__)), | ||
"revolver.jpg") | ||
with open(path, 'rb') as f: | ||
r = requests.post(self.url + "/upload", files={"image": f}) | ||
res = r.json() | ||
|
||
# checks that the input file has been written | ||
self.assertTrue("file_name" in res.keys()) | ||
output_path = os.path.join(PATH_IMGS, res["file_name"]) | ||
self.assertTrue(os.path.exists(output_path)) | ||
# checks that written file is exactly the same as input file | ||
with Image.open(path) as image_one: | ||
with Image.open(output_path) as image_two: | ||
self.assertEqual(image_one.size, image_two.size) | ||
diff = ImageChops.difference(image_one, image_two) | ||
self.assertFalse(diff.getbbox()) | ||
# checks that the json result is as expected | ||
self.assertTrue("label" in res.keys()) | ||
self.assertEqual(res["label"], "revolver") | ||
self.assertTrue("confidence" in res.keys()) | ||
self.assertAlmostEqual(res["confidence"], 99.05, places=1) |
Oops, something went wrong.