Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Containerized the Interface and Visualization And Setup Github Actions #63

Merged
merged 48 commits into from
Dec 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
a19eab1
Interface & Visualization
im-prakher Jun 25, 2020
db5e430
Delete client.json
im-prakher Jun 25, 2020
397fa29
Delete package-lock.json
im-prakher Jun 26, 2020
cc00650
Update README.md
im-prakher Jun 26, 2020
920545f
Update interface/src/components/upload1.js
im-prakher Jul 1, 2020
f24f0a4
alt text
dlebauer Jul 10, 2020
9674578
Final Changes
im-prakher Jul 18, 2020
3294574
Update upload1.js
im-prakher Jul 19, 2020
0c7da86
Fixed redirects and error page functionality
im-prakher Jul 20, 2020
61297e3
Update app/Meta.py
im-prakher Jul 20, 2020
f11d149
Update app/Meta.py
im-prakher Jul 20, 2020
323291d
Replace "some text" with "" in Meta.py
im-prakher Jul 20, 2020
fde6a05
Written some tests
im-prakher Jul 20, 2020
9ac0073
Completed writing tests
im-prakher Jul 24, 2020
6037b55
Containerized the Interface and Visualiztion
im-prakher Jul 26, 2020
bd5142f
Interface & Visualization
im-prakher Jun 25, 2020
7cb3e19
Update README.md
im-prakher Jun 26, 2020
ee06571
Update interface/src/components/upload1.js
im-prakher Jul 1, 2020
2882ad2
Final Changes
im-prakher Jul 18, 2020
d671211
Containerized the Interface and Visualiztion
im-prakher Jul 26, 2020
1f69728
Merge branch 'master' into containerize
im-prakher Jul 26, 2020
5ad6cae
Merge branch 'containerize' of https://github.com/im-prakher/BETYdb-Y…
im-prakher Jul 26, 2020
30f387a
Merge branch 'containerize' of https://github.com/im-prakher/BETYdb-Y…
im-prakher Jul 26, 2020
c218817
Few changes
im-prakher Jul 26, 2020
4741e29
Merge branch 'master' into containerize
dlebauer Aug 7, 2020
676e63d
Update .gitignore
im-prakher Aug 11, 2020
5affff9
Test not needed
im-prakher Aug 13, 2020
d85a0bf
Set-up Github Actions
im-prakher Aug 13, 2020
d00082f
Fixed typo
im-prakher Aug 13, 2020
d37192c
Fixed typos
im-prakher Aug 13, 2020
ab8668b
Written tests actions in a single file
im-prakher Aug 17, 2020
1564e3d
Pylint fixes
im-prakher Aug 17, 2020
fc73814
Pylint fixes
im-prakher Aug 17, 2020
5e2ec2b
input_files path fixes
im-prakher Aug 17, 2020
4990405
tests fixes
im-prakher Aug 17, 2020
e57ad79
Generated .pylintrc for pylint
im-prakher Aug 21, 2020
db46978
Added env variable for pylint
im-prakher Aug 21, 2020
6b4d33d
setup directory for .pylintrc
im-prakher Aug 21, 2020
7124a27
Implemented python tests using matrix and linter messages_control
im-prakher Aug 23, 2020
da9c3fd
Remove bety sync and typo fixes
im-prakher Aug 23, 2020
3b8166d
Remove unused-import
im-prakher Aug 23, 2020
04e1f6c
Invetigating cause of failing py_tests.yml
im-prakher Aug 25, 2020
8b0b327
Typo fix
im-prakher Aug 25, 2020
d9fc245
Change the ports for visualization
im-prakher Aug 29, 2020
6973dfd
Updated pandas version to 0.24.2
im-prakher Aug 31, 2020
ff4ea61
Removed the containerize branch
im-prakher Sep 3, 2020
9ea8e98
Run actions on pushing commits to any branch
im-prakher Sep 3, 2020
9ec9697
typo fix
im-prakher Sep 3, 2020
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
572 changes: 572 additions & 0 deletions .github/linters/.pylintrc

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions .github/workflows/interface_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: YABA interface tests

on:
push:
pull_request:
branches: [ master ]

jobs:
interface_test:

runs-on: ubuntu-latest
defaults:
run:
working-directory: interface

strategy:
matrix:
node-version: [12.x, 14.x]
dlebauer marked this conversation as resolved.
Show resolved Hide resolved

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies
run: npm install

- name: Run the tests and generate coverage report
run: npm test -- --coverage

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
25 changes: 25 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: YABA Code Linter

on:
push:
pull_request:
branches: [ master ]

jobs:
lint:

runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Lint Code Base
uses: docker://github/super-linter:v3
env:
PYTHON_PYLINT_CONFIG_FILE: .pylintrc
VALIDATE_ALL_CODEBASE: false
VALIDATE_PYTHON_PYLINT: true
VALIDATE_JAVASCRIPT_ES: true
DEFAULT_BRANCH: master
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54 changes: 54 additions & 0 deletions .github/workflows/py_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: YABA app and client tests

on:
push:
pull_request:
branches: [ master ]

jobs:
py_test:

runs-on: ubuntu-latest
strategy:
matrix:
dlebauer marked this conversation as resolved.
Show resolved Hide resolved
code: [ app, client]
include:
- code: app
path: ./yaba_test/test_yaba.py
- code: client
path: ./yaba_client_test/test_yaba_client.py

steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Set up Python 3.7
uses: actions/setup-python@v2
with:
python-version: 3.7

- name: Install dependencies
run: |
pip install --upgrade pip
pip install pytest
pip install pytest-cov
pip install docker-compose

- name: Set-up the project
run: |
docker-compose up -d postgres
docker-compose run --rm bety initialize
docker-compose up -d
docker ps -a
docker logs betydb-yaba_yaba_api_1

- name: Test with pytest and generate coverage report
run: |
sleep 20
pytest --cov= ${{ matrix.path }} --cov-report=xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,4 @@ venv.bak/
.mypy_cache/

# node modules
node_modules/
node_modules/
12 changes: 4 additions & 8 deletions app/Meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
import traceback
import logging
import pandas as pd

from flask import make_response,Response,jsonify
from flask import json
from flask import make_response,jsonify
from db import *
from werkzeug import secure_filename,FileStorage
from sqlalchemy.exc import IntegrityError
Expand Down Expand Up @@ -329,7 +327,7 @@ def insert_citations(username,fileName):
insert_table(table='citations',data=data)
msg = {'Message' : 'Successfully inserted',
'Table Affected' : 'Citations',
'Lines Inserted': data.shape[0]}
'Lines Inserted': data.shape[0]}

return make_response(jsonify(msg), 201)

Expand Down Expand Up @@ -379,7 +377,7 @@ def insert_experimentSites(fileName):
insert_table(table='experiments_sites',data=new_data)
msg = {'Message' : 'Successfully inserted',
'Table Affected' : 'Experiments_sites',
'Lines Inserted': data.shape[0]}
'Lines Inserted': data.shape[0]}

return make_response(jsonify(msg), 201)

Expand Down Expand Up @@ -431,7 +429,7 @@ def insert_experimentTreatments(fileName):
insert_table(table='experiments_treatments',data=new_data)
msg = {'Message' : 'Successfully inserted',
'Table Affected' : 'Experiments_treatments',
'Lines Inserted': data.shape[0]}
'Lines Inserted': data.shape[0]}

return make_response(jsonify(msg), 201)

Expand Down Expand Up @@ -535,14 +533,12 @@ def insert_citationsSites(fileName):
insert_table(table='citations_sites',data=new_data)
msg = {'Message' : 'Successfully inserted',
'Table Affected' : 'Citations_sites',
'col' : columns,
'Lines Inserted': data.shape[0]}

return make_response(jsonify(msg), 201)

else:
msg = {'Message' : 'File not acceptable and Check the format of file or columns',
'col' : columns,
'Table':'citations_sites'}
return make_response(jsonify(msg), 400)

Expand Down
2 changes: 1 addition & 1 deletion app/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ requests==2.20.0
psycopg2-binary
WSGIserver
gevent
pandas
pandas==0.24.2
connexion==2.2.0
Flask==1.0
Werkzeug==0.15.3
Expand Down
1 change: 1 addition & 0 deletions app/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import connexion
import json
from time import sleep
from flask import Response

# Create the application instance
app = connexion.App(__name__, specification_dir="./")
Expand Down
11 changes: 5 additions & 6 deletions client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,21 @@
#################

import requests
from flask import Flask, g, render_template,request,redirect,Response,flash,jsonify, make_response
from flask import request
from flask import Flask, render_template,request,redirect,Response,flash

import logging
import json
from time import sleep
import sys
from flask_cors import CORS, cross_origin

from flask_cors import CORS

# Create app
app = Flask(__name__)
app.secret_key = 'my unobvious secret key'

# The maximum allowed payload to 16 megabytes.
app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024
cors = CORS(app, resources={r'/*': {'origins': '*'}})
cors = CORS(app, resources={r'/*': {'origins': 'http://localhost:3001'}})
im-prakher marked this conversation as resolved.
Show resolved Hide resolved

logging.getLogger('flask_cors').level = logging.DEBUG

ALLOWED_EXTENSIONS = set(['csv', 'xls','xlsx'])
Expand Down
1 change: 1 addition & 0 deletions client/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
Flask==1.0
requests==2.20.0
flask-cors
29 changes: 29 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,35 @@ services:
- 6001:6000
depends_on:
- yaba_api

yaba_visualization:
build: ./visualization
networks:
- bety
volumes:
- './visualization:/code'
- '/code/node_modules'
ports:
- 8008:8075
depends_on:
- postgres

yaba_interface:
build: ./interface
networks:
- bety
volumes:
- './interface:/code'
- '/code/node_modules'
ports:
- 3001:3000
environment:
- CHOKIDAR_USEPOLLING=true
depends_on:
- yaba_client
- yaba_visualization
stdin_open: true

volumes:
postgres:

Expand Down
1 change: 1 addition & 0 deletions interface/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
16 changes: 16 additions & 0 deletions interface/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM node:12.18.2-alpine

COPY . /code

WORKDIR /code

ENV PATH /code/node_modules/.bin:$PATH
im-prakher marked this conversation as resolved.
Show resolved Hide resolved

RUN npm install --silent

RUN npm install [email protected] -g --silent

EXPOSE 3000

# start app
CMD ["npm", "start"]
8 changes: 4 additions & 4 deletions interface/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<link rel="icon" href="%PUBLIC_URL%/bety.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
content="BETYdb-YABA Interface for Metadata Upload"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/bety.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
Expand All @@ -26,7 +26,7 @@
-->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ==" crossorigin="" />
<title>React App</title>
<title>BETYdb-YABA Interface</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
9 changes: 0 additions & 9 deletions interface/src/App.test.js

This file was deleted.

4 changes: 2 additions & 2 deletions interface/src/components/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class Grid extends Component{
if(!label.includes(data[i][type])){
label.push(data[i][type])
}
}

}
color= getRandomColors(label.length)
let plots = new Array();
let xpos = 1; //starting xpos and ypos at 1 so the stroke will show when we make the grid below
Expand Down
6 changes: 3 additions & 3 deletions interface/src/components/requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function getVisualData(files, type, username){
params= 'getTreatmentSites'
}

let res= fetch(`http://localhost:3001/${params}`, {
let res= fetch(`http://localhost:8008/${params}`, {
method: 'POST',
body: formData,
redirect: 'follow'
Expand All @@ -48,7 +48,7 @@ export function getGeoJSON(file){

formData.append("shp_file", file);

let res= fetch("http://localhost:3001/getGeoJSON", {
let res= fetch("http://localhost:8008/getGeoJSON", {
method: 'POST',
body: formData,
redirect: 'follow'
Expand Down Expand Up @@ -98,7 +98,7 @@ function getGeoFile(zip_file, file_type){
redirect: 'follow'
};

const res = fetch("http://localhost:3001/getGeoFile", requestOptions)
const res = fetch("http://localhost:8008/getGeoFile", requestOptions)
.then(response => new File([response.blob()], `${file_type}_file.${file_type}`))
.catch(error => {
throw Error(error)
Expand Down
2 changes: 1 addition & 1 deletion interface/src/setupTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
import '@testing-library/jest-dom/extend-expect';
import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
configure({ adapter: new Adapter() });
configure({ adapter: new Adapter() });
1 change: 1 addition & 0 deletions visualization/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
14 changes: 14 additions & 0 deletions visualization/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM node:12.18.2-alpine

COPY . /code

WORKDIR /code

ENV PATH /code/node_modules/.bin:$PATH
im-prakher marked this conversation as resolved.
Show resolved Hide resolved

RUN npm install --silent

EXPOSE 8075

# start app
CMD ["npm", "start"]
Loading