Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
152 commits
Select commit Hold shift + click to select a range
ec91d96
added back imports to app and resolved environment variables loading …
Benjamintdk Mar 27, 2022
f5ca8e3
fixed line too long linting issue
Benjamintdk Mar 28, 2022
7561a77
updated requirements.txt files to fix failing dependencies in Docker …
Benjamintdk May 4, 2022
5884ae3
added dockerignore files for each directory
Benjamintdk May 4, 2022
bf956e2
initial commit for prod compose file
Benjamintdk May 5, 2022
004546d
added requirements.in
Benjamintdk May 7, 2022
ced678a
resolved flaskd dependency issues
Benjamintdk May 7, 2022
4f442e6
refactor test to test getStatistics endpoint first to unlock database…
Benjamintdk May 7, 2022
ad7cda7
tested cypress webpack testing config in docker-compose setup
Benjamintdk May 8, 2022
c33c86c
finished docker compose v1 for test
Benjamintdk May 9, 2022
98c1db4
refactored the docker-compose test file a bit
Benjamintdk May 10, 2022
69e210e
tested ml-endpoint for docker-compose.dev
Benjamintdk May 10, 2022
7a665f8
finished dev and test docker-compose files
Benjamintdk May 11, 2022
3f7f7a4
updated readme for docker compose
Benjamintdk May 11, 2022
a276346
First test of GH Actions with docker compose up
Benjamintdk May 11, 2022
5e20748
Update dockerized-tests.yml
Benjamintdk May 11, 2022
0e0b0f5
made some changes to the docker-compose test file
Benjamintdk May 11, 2022
f17c391
Update dockerized-tests.yml
Benjamintdk May 11, 2022
3b4f4d7
Update dockerized-tests.yml
Benjamintdk May 11, 2022
da3993a
Update docker-compose.dev.yml
Benjamintdk May 11, 2022
f963b3c
Update Dockerfile
Benjamintdk May 14, 2022
4c7eb0a
Update train.py
Benjamintdk May 14, 2022
6248721
Update train.py
Benjamintdk May 14, 2022
be033ba
Update dockerized-tests.yml
Benjamintdk May 14, 2022
7087a0e
Update train.py
Benjamintdk May 14, 2022
7e5c5e7
Update train.py
Benjamintdk May 14, 2022
c0f6d5c
Update train.py
Benjamintdk May 14, 2022
9872b30
Update train.py
Benjamintdk May 14, 2022
397e4c4
Update docker-compose.dev.yml
Benjamintdk May 14, 2022
c806414
Update docker-compose.dev.yml
Benjamintdk May 14, 2022
0611c5d
Update train.py
Benjamintdk May 14, 2022
6903a58
Update docker-compose.test.yml
Benjamintdk May 14, 2022
5e42e71
Update dockerized-tests.yml
Benjamintdk May 14, 2022
53ba30e
Update docker-compose.dev.yml
Benjamintdk May 14, 2022
3468fa0
Update dockerized-tests.yml
Benjamintdk May 14, 2022
45d9d7d
Update docker-compose.dev.yml
Benjamintdk May 14, 2022
1ac7187
Update docker-compose.test.yml
Benjamintdk May 14, 2022
c961b63
Update docker-compose.test.yml
Benjamintdk May 14, 2022
086a4e0
Update dockerized-tests.yml
Benjamintdk May 14, 2022
51261a7
Update docker-compose.dev.yml
Benjamintdk May 14, 2022
3f5894c
Update docker-compose.test.yml
Benjamintdk May 14, 2022
d9d6278
Update dockerized-tests.yml
Benjamintdk May 14, 2022
b8da529
Update docker-compose.test.yml
Benjamintdk May 14, 2022
1624eb2
Update dockerized-tests.yml
Benjamintdk May 14, 2022
2c86eb5
Update docker-compose.test.yml
Benjamintdk May 14, 2022
2643a18
Update Dockerfile
Benjamintdk May 14, 2022
4950e1d
Update Dockerfile
Benjamintdk May 14, 2022
8e8186d
Update Dockerfile
Benjamintdk May 14, 2022
92a7bf2
Update Dockerfile
Benjamintdk May 14, 2022
c6e9e3f
Update docker-compose.test.yml
Benjamintdk May 14, 2022
ff44164
Update docker-compose.test.yml
Benjamintdk May 14, 2022
d3f1793
Update docker-compose.test.yml
Benjamintdk May 14, 2022
be170c6
Update Dockerfile
Benjamintdk May 14, 2022
6724473
Update docker-compose.test.yml
Benjamintdk May 14, 2022
36fc065
Update Dockerfile
Benjamintdk May 14, 2022
ac6d3bd
Update Dockerfile
Benjamintdk May 14, 2022
f5541ae
Update docker-compose.test.yml
Benjamintdk May 14, 2022
367636d
Update Dockerfile
Benjamintdk May 14, 2022
ff3eb93
Update Dockerfile
Benjamintdk May 14, 2022
04a2861
Update docker-compose.test.yml
Benjamintdk May 14, 2022
0849f9d
Update Dockerfile
Benjamintdk May 14, 2022
716f201
Update Dockerfile
Benjamintdk May 14, 2022
e04a889
Update Dockerfile
Benjamintdk May 14, 2022
8db7283
Update dockerized-tests.yml
Benjamintdk May 14, 2022
d6cc1e1
Update docker-compose.test.yml
Benjamintdk May 14, 2022
3e99b00
Update __init__.py
Benjamintdk May 15, 2022
ebbbbfb
trying out secrets and running pytest container last
Benjamintdk May 16, 2022
cdb9269
Merge branch 'docker-compose-for-dev' of https://github.com/Benjamint…
Benjamintdk May 16, 2022
5f92ddc
further refactoring to generate production dependencies
Benjamintdk May 16, 2022
5c140c9
refactored dev docker compose to use secrets
Benjamintdk May 16, 2022
4a0fad7
updated requirements.txt files to fix failing dependencies in Docker …
Benjamintdk May 4, 2022
d8dfb68
added dockerignore files for each directory
Benjamintdk May 4, 2022
5bd099f
initial commit for prod compose file
Benjamintdk May 5, 2022
156bbb8
refactor test to test getStatistics endpoint first to unlock database…
Benjamintdk May 7, 2022
ff22a2a
tested cypress webpack testing config in docker-compose setup
Benjamintdk May 8, 2022
83699f0
finished docker compose v1 for test
Benjamintdk May 9, 2022
3b47624
refactored the docker-compose test file a bit
Benjamintdk May 10, 2022
53cfd68
resolved dependency conflicts in requirements.txt
Benjamintdk May 16, 2022
d2b0d2c
removed extra restart variable in docker-compose test
Benjamintdk May 16, 2022
cfb6b14
tested ml-endpoint for docker-compose.dev
Benjamintdk May 10, 2022
5b7a80f
finished dev and test docker-compose files
Benjamintdk May 11, 2022
ab3579e
updated readme for docker compose
Benjamintdk May 11, 2022
6e0fbc9
First test of GH Actions with docker compose up
Benjamintdk May 11, 2022
9da7c80
Update dockerized-tests.yml
Benjamintdk May 11, 2022
0b63523
made some changes to the docker-compose test file
Benjamintdk May 11, 2022
bd8d6d3
Update dockerized-tests.yml
Benjamintdk May 11, 2022
32d05aa
Update dockerized-tests.yml
Benjamintdk May 11, 2022
ec96d1d
Update docker-compose.dev.yml
Benjamintdk May 11, 2022
59d3524
Update Dockerfile
Benjamintdk May 14, 2022
2d105b4
Update train.py
Benjamintdk May 14, 2022
37e3b3d
Update train.py
Benjamintdk May 14, 2022
041c94c
Update dockerized-tests.yml
Benjamintdk May 14, 2022
80f34d2
Update train.py
Benjamintdk May 14, 2022
b31e9f7
Update train.py
Benjamintdk May 14, 2022
92ecfc9
Update train.py
Benjamintdk May 14, 2022
e786551
Update train.py
Benjamintdk May 14, 2022
6aa9968
Update docker-compose.dev.yml
Benjamintdk May 14, 2022
2db0773
Update docker-compose.dev.yml
Benjamintdk May 14, 2022
3c6a83d
Update train.py
Benjamintdk May 14, 2022
a15409a
Update docker-compose.test.yml
Benjamintdk May 14, 2022
bf50515
Update dockerized-tests.yml
Benjamintdk May 14, 2022
0eac65e
Update docker-compose.dev.yml
Benjamintdk May 14, 2022
aebd430
Update dockerized-tests.yml
Benjamintdk May 14, 2022
39b46c3
Update docker-compose.dev.yml
Benjamintdk May 14, 2022
aa7fffc
Update docker-compose.test.yml
Benjamintdk May 14, 2022
d79cf2b
Update docker-compose.test.yml
Benjamintdk May 14, 2022
4b94f67
Update dockerized-tests.yml
Benjamintdk May 14, 2022
a4b6532
Update docker-compose.dev.yml
Benjamintdk May 14, 2022
6477f1c
Update docker-compose.test.yml
Benjamintdk May 14, 2022
11f9214
Update dockerized-tests.yml
Benjamintdk May 14, 2022
0c6bb1d
Update docker-compose.test.yml
Benjamintdk May 14, 2022
7d4a7e9
Update dockerized-tests.yml
Benjamintdk May 14, 2022
0dbb6b7
Update docker-compose.test.yml
Benjamintdk May 14, 2022
d12c2c4
Update Dockerfile
Benjamintdk May 14, 2022
2072397
Update Dockerfile
Benjamintdk May 14, 2022
5e2788a
Update Dockerfile
Benjamintdk May 14, 2022
6a9b7b9
Update Dockerfile
Benjamintdk May 14, 2022
7f23be4
Update docker-compose.test.yml
Benjamintdk May 14, 2022
cc5f826
Update docker-compose.test.yml
Benjamintdk May 14, 2022
322f15e
Update docker-compose.test.yml
Benjamintdk May 14, 2022
adb1449
Update Dockerfile
Benjamintdk May 14, 2022
5500573
Update docker-compose.test.yml
Benjamintdk May 14, 2022
6bac8cd
Update Dockerfile
Benjamintdk May 14, 2022
609d287
Update Dockerfile
Benjamintdk May 14, 2022
332cad1
Update docker-compose.test.yml
Benjamintdk May 14, 2022
2226fcc
Update Dockerfile
Benjamintdk May 14, 2022
1b22089
Update Dockerfile
Benjamintdk May 14, 2022
559d97c
Update docker-compose.test.yml
Benjamintdk May 14, 2022
95b85c8
Update Dockerfile
Benjamintdk May 14, 2022
9f4462d
Update Dockerfile
Benjamintdk May 14, 2022
1cd3218
Update Dockerfile
Benjamintdk May 14, 2022
f81fd77
Update dockerized-tests.yml
Benjamintdk May 14, 2022
c8d86c7
Update docker-compose.test.yml
Benjamintdk May 14, 2022
9ed2ba4
trying out secrets and running pytest container last
Benjamintdk May 16, 2022
905c4d0
Update __init__.py
Benjamintdk May 15, 2022
b9774a7
refactored dev docker compose to use secrets
Benjamintdk May 16, 2022
e9915cd
resolved merge conflicts
Benjamintdk May 16, 2022
264cf0f
refactored docker files to account for changes in requirements.txt an…
Benjamintdk May 16, 2022
677bf4c
adding preliminary pre-commit-config and setup cfg files for python
Benjamintdk May 25, 2022
6010425
linting and formatting done for python side
Benjamintdk May 25, 2022
26b8e44
rerun formatting and changed testing workflow to run as well
Benjamintdk May 25, 2022
cf17eff
add cypress linting
Benjamintdk May 27, 2022
201852f
cleaned up pre commit config yaml file
Benjamintdk Jun 19, 2022
a2df3aa
cleaned up some unnecessary files and changes
Benjamintdk Jun 19, 2022
6a3da98
Merge branch 'dockerized-tests' into docker-compose-for-dev
Benjamintdk Jun 19, 2022
d9a2d62
Merge branch 'docker-compose-for-dev' into lint-and-format
Benjamintdk Jun 19, 2022
671a26b
refactored linting and testing under one GH Action
Benjamintdk Jun 19, 2022
770b589
refactored linting and testing under one GH Action
Benjamintdk Jun 19, 2022
839f167
refactored GH Actions further by changing run conditions
Benjamintdk Jun 19, 2022
6772039
removed AWS secrets from docker compose test file
Benjamintdk Jun 25, 2022
345900b
Merge branch 'docker-compose-for-dev' into lint-and-format
Benjamintdk Jun 25, 2022
823c37c
resolved merge conflicts with master branch
Benjamintdk Jun 30, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions webapp/.eslintrc.json → .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,46 @@
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
"plugin:@typescript-eslint/recommended",
"plugin:cypress/recommended"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"plugins": ["@typescript-eslint"],
"plugins": [
"@typescript-eslint"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 11,
"sourceType": "module"
},
"rules": {
"@typescript-eslint/no-explicit-any": ["off"],
"@typescript-eslint/no-this-alias": [
"error",
{
"allowDestructuring": true, // Allow `const { props, state } = this`; false by default
"allowedNames": ["self"] // Allow `const vm= this`; `[]` by default
"allowDestructuring": true, // Allow `const { props, state } = this`; false by default
"allowedNames": [
"self"
] // Allow `const vm= this`; `[]` by default
}
],
"@typescript-eslint/ban-types": [
"error",
{
"extendDefaults": true,
"types": {
"{}": false
}
"extendDefaults": true,
"types": {
"{}": false
}
}
],
"@typescript-eslint/no-unused-vars": [
"error",
{ "argsIgnorePattern": "^_" }
{
"argsIgnorePattern": "^_"
}
]
}
}
48 changes: 48 additions & 0 deletions .github/workflows/code_quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Code quality

on:
push:
pull_request:
branches: [master]
types: [opened, synchronize]

env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: eu-west-1

jobs:
linting:
name: Linting
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
tool:
[
"isort",
"black",
"pyupgrade",
"flake8",
"trailing-whitespace",
"end-of-file-fixer",
"fix-byte-order-marker",
"eslint",
]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- name: Install pre-commit
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade pre-commit
pre-commit install
- name: Run ${{ matrix.tool }}
run: |
pre-commit run ${{ matrix.tool }} --all-files
testing:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: run docker compose
run: docker-compose -f docker-compose.test.yml up --build --exit-code-from pytest --abort-on-container-exit
36 changes: 3 additions & 33 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ on:
push:
branches:
- master
pull_request:
branches: [master]
types: [opened, synchronize]

env:
ML_IMAGE_TAG: activelearning_ml:test
Expand All @@ -16,39 +13,12 @@ env:
WEBAPP: webapp/

jobs:
linting:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: flake8 Lint
uses: py-actions/flake8@v2
with:
ignore: "E402"
max-line-length: "88"
path: .
- uses: actions/setup-node@v2
with:
node-version: '14.x'
- name: eslint lint
working-directory: ${{ env.WEBAPP }}
run: |
npm install eslint
npm install @typescript-eslint/eslint-plugin@latest --save-dev
npm install @typescript-eslint/parser --save-dev
npm run lint


deployment:
runs-on: ubuntu-20.04
needs: [linting]
if: ${{ github.event_name == 'push' }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: '50'
fetch-depth: "50"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
Expand All @@ -72,7 +42,7 @@ jobs:
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.API_IMAGE_TAG }}
- uses: actions/setup-node@v2
with:
node-version: '14.x'
node-version: "14.x"
- name: Build web app
working-directory: ${{ env.WEBAPP }}
run: |
Expand All @@ -83,7 +53,7 @@ jobs:
uses: JamesIves/github-pages-deploy-action@v4.2.5
with:
branch: gh-pages
folder: ${{ env.WEBAPP }}/dist
folder: ${{ env.WEBAPP }}/dist
- name: Bump version and push tag
uses: anothrNick/github-tag-action@1.36.0
if: ${{ !contains(join(github.event.commits.*.message, ' '), '#skip') }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ unlabeled*/
node_modules/
dist/
.DS_Store
webapp/cypress/videos/

#api
app.db
Expand Down
43 changes: 43 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
repos:
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
args: ["--profile", "black"]

- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black

- repo: https://github.com/asottile/pyupgrade
rev: v2.31.0
hooks:
- id: pyupgrade
args: ["--py39-plus"]

- repo: https://github.com/pycqa/flake8
rev: 4.0.1
hooks:
- id: flake8
additional_dependencies: [pep8-naming]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: fix-byte-order-marker

- repo: https://github.com/pre-commit/mirrors-eslint
rev: "v8.16.0"
hooks:
- id: eslint
files: \.[jt]s?$
types: [file]
exclude: live\S*\.ts
additional_dependencies:
- eslint@latest
- "@typescript-eslint/eslint-plugin@latest"
- "@typescript-eslint/parser@latest"
- "eslint-plugin-cypress@latest"
21 changes: 16 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,30 @@ The tool has been divided into different modules:
- **Preprocessing of unlabeled data:** it contains a Python script that generates mp3 files and spectrograms, given a directory containing audio data.
- **A Machine Learning Endpoint:** which is a small flask app that -- given an h5 file, a labeled dataset and an unlabeled dataset -- trains an ML model on the labeled data and predicts on the unlabeled data.

Go into each directory to learn how to get started with it. You will want to visit the directories in this order: preprocess --> train_and_predict --> api --> webapp.
## Installation and local setup:

**Flowchart of how the tool works:**
We highly recommend that you use [Docker](https://docs.docker.com/engine/install/) and [Docker Compose](https://docs.docker.com/compose/install/) to setup the environment, as it will save you a lot of trouble with resolving dependency conflicts and updates.

To run the services in development mode:

`docker-compose -f docker-compose.dev.yml up --build`

To run testing for the services:

`docker-compose -f docker-compose.test.yml up --build --exit-code-from pytest --abort-on-container-exit`

If you still wish to setup each individual service locally, you can find more instructions by going into each directory to learn how to get started. You will want to visit the directories in this order: preprocess --> train_and_predict --> api --> webapp. Do note that some of the instructions might also be outdated so you'll likely need to fix them yourself.

**Flowchart of how the tool works:**
![flowchart](api/assets/flowchart.jpg)

**Architecture of the tool:**
![architecture](api/assets/architecture.png)

## Blog posts about the project and GSoC

[My Journey as a Google Summer of Code participant with Orcasound](http://www.orcasound.net/2020/08/26/my-journey-as-a-google-summer-of-code-participant-with-orcasound/)
[Two months listening and learning about orca sounds](http://www.orcasound.net/2020/08/02/two-months-as-a-gsoc-participant-with-orcasound/)
[My Journey as a Google Summer of Code participant with Orcasound](http://www.orcasound.net/2020/08/26/my-journey-as-a-google-summer-of-code-participant-with-orcasound/)
[Two months listening and learning about orca sounds](http://www.orcasound.net/2020/08/02/two-months-as-a-gsoc-participant-with-orcasound/)
[GSoC’s active learning tool: progress after 1 month](http://www.orcasound.net/2020/07/01/gsocs-active-learning-tool-progress-after-1-month/)

## Questions?
Expand All @@ -49,4 +61,3 @@ More questions about being a GSoC mentor or student? Check out the [GSoC mentor
* [Docker](https://github.com/topics/docker)
* [PostgreSQL](https://www.postgresql.org)
* [Flask](https://flask.palletsprojects.com/en/1.1.x/)

19 changes: 19 additions & 0 deletions api/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#common
.vscode/
__pycache__/
.gitignore
.dockerignore
Dockerfile

#environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

#api related
.pytest_cache/
assets/
2 changes: 1 addition & 1 deletion api/.flake8
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[flake8]
ignore = E402, F401, W292, E501
ignore = E402, F401, W292, E501
2 changes: 1 addition & 1 deletion api/.flaskenv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
FLASK_APP=app
FLASK_ENV=development
FLASK_ENV=development
38 changes: 25 additions & 13 deletions api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
FROM python:3.8
FROM python:3.8 as base
WORKDIR /orcagsoc
COPY Pipfile Pipfile
COPY Pipfile.lock Pipfile.lock
RUN pip install pipenv
RUN pipenv install --deploy --ignore-pipfile
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
RUN apt install unzip
RUN unzip awscliv2.zip
RUN ./aws/install
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
COPY requirements.txt .
RUN pip install -r requirements.txt

FROM python:3.8 as base_dependencies
WORKDIR /orcagsoc
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && \
unzip awscliv2.zip && ./aws/install && \
rm -rf awscliv2.zip aws/
COPY --from=base /opt/venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
COPY app app
COPY migrations migrations
COPY boot.sh ./

ENV FLASK_APP app

EXPOSE 5000
ENTRYPOINT ["./boot.sh"]

FROM base_dependencies as dev
CMD ["sh", "-c", "flask db upgrade && flask run --host 0.0.0.0"]

FROM base_dependencies as prod
COPY boot.sh ./
RUN pip install gunicorn
ENTRYPOINT ["./boot.sh"]

FROM base_dependencies as test
COPY tests/ tests/
RUN pip install pytest
CMD ["python", "-m", "pytest"]
2 changes: 1 addition & 1 deletion api/Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: flask db upgrade; gunicorn app:app
web: flask db upgrade; gunicorn app:app
Loading