-
Notifications
You must be signed in to change notification settings - Fork 3
GRPC and Dev environment Configuration #24
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
Merged
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
5ca81fc
Clean backend folder && create protobuf script to compile and install…
d84ee34
structure backend folder and implement GreeterService
e5fd953
Add grpc-web to web/
01f06d3
Front-end uses envoy as a proxy
daca785
move envoy proxy to backend
f64efc8
Add computer loopback interface as grpc client ip address
70f5a5e
remove false comment aboute proxy port
610d1a4
add instructions for grpc installation in readme
af1e663
test
abelfodil 15e2504
Merge branch 'master' of https://github.com/PolyCortex/polydodo into …
5771002
Remove useless install script && fix package name
db5fc68
Merge branch 'grpc' of https://github.com/PolyCortex/polydodo into mo…
1cdb13f
Apply suggestions from code review
909cc16
fix conflict
abelfodil 055ca94
Enhance vscode xp
abelfodil 75bbc98
Fix python app
abelfodil 353196b
add host environment variable for grpc
1c9efab
Merge branch 'mock-python-back-end' of https://github.com/PolyCortex/…
dc53aa0
Add envoy to docker
abelfodil 8f523ae
Fix prettier format
abelfodil 2298cb7
Verbose logs
abelfodil 4ff6391
Downgrade java
abelfodil 413f3a2
update readme
abelfodil 207c7c0
Fix web pipeline
abelfodil 8afe68c
rename folders
abelfodil 4ba3a74
Merge branch 'mock-python-back-end' of https://github.com/PolyCortex/…
d10f5ff
Attempt to fix web
abelfodil a1c2355
Remove verbose
abelfodil 7053f03
Change ignorePatterns for evrything in protos/ folder
27d3211
Merge branch 'mock-python-back-end' of https://github.com/PolyCortex/…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
File renamed without changes.
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| trailingComma: 'all' | ||
| trailingComma: "all" | ||
| tabWidth: 2 | ||
| semi: true | ||
| singleQuote: true | ||
|
|
||
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1 +1,3 @@ | ||
| .venv/ | ||
| .venv/ | ||
| .vscode/ | ||
| __pycache__/ |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,46 +1,40 @@ | ||
| from flask import Flask, render_template, url_for, request, redirect | ||
| import os | ||
| from resampling import convert_csv_to_raw | ||
| from werkzeug.utils import secure_filename | ||
|
|
||
| ALLOWED_EXTENSIONS = {'csv'} | ||
|
|
||
| def allowed_filename(filename): | ||
| if not '.' in filename: | ||
| print('No extension in filename') | ||
| return False | ||
|
|
||
| ext = filename.rsplit('.', 1)[1] | ||
| if ext.lower() in ALLOWED_EXTENSIONS: | ||
| return True | ||
| else: | ||
| print('That file extension is not allowed') | ||
| return False | ||
|
|
||
|
|
||
| app = Flask(__name__) | ||
|
|
||
| @app.route('/') | ||
| def index(): | ||
| return render_template('index.html') | ||
|
|
||
| @app.route('/upload-csv', methods =['GET','POST']) | ||
| def upload_csv(): | ||
| if request.method == 'POST': | ||
| if request.files: | ||
| csv = request.files['csv'] | ||
|
|
||
| if csv.filename =='': | ||
| print('No filename or no selected file') | ||
| return redirect(request.url) | ||
|
|
||
| if allowed_filename(csv.filename): | ||
| filename = secure_filename(csv.filename) #useless si on save pas le fichier je crois | ||
| print(csv) | ||
| convert_csv_to_raw(csv) | ||
| return redirect(request.url) | ||
|
|
||
| return render_template('upload_csv.html') | ||
| # Copyright 2015 gRPC authors. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| """The Python implementation of the GRPC helloworld.Greeter server.""" | ||
|
|
||
| from concurrent import futures | ||
| import logging | ||
|
|
||
| import grpc | ||
|
|
||
| from protos import helloworld_pb2 | ||
| from protos import helloworld_pb2_grpc | ||
|
|
||
|
|
||
| class Greeter(helloworld_pb2_grpc.GreeterServicer): | ||
| def SayHello(self, request, context): | ||
| return helloworld_pb2.HelloReply(message='Hello, %s!' % request.name) | ||
|
|
||
|
|
||
| def serve(): | ||
| server = grpc.server(futures.ThreadPoolExecutor(max_workers=10)) | ||
| helloworld_pb2_grpc.add_GreeterServicer_to_server(Greeter(), server) | ||
| server.add_insecure_port('[::]:9090') | ||
| server.start() | ||
| server.wait_for_termination() | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| app.run(host='0.0.0.0', debug=True) | ||
| logging.basicConfig() | ||
| serve() |
This file contains hidden or 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,40 @@ | ||
| # Taken from https://github.com/grpc/grpc-web/tree/master/net/grpc/gateway/examples/helloworld | ||
| static_resources: | ||
| listeners: | ||
| - name: listener_0 | ||
| address: | ||
| socket_address: { address: 0.0.0.0, port_value: 8080 } | ||
| filter_chains: | ||
| - filters: | ||
| - name: envoy.http_connection_manager | ||
| config: | ||
| codec_type: auto | ||
| stat_prefix: ingress_http | ||
| route_config: | ||
| name: local_route | ||
| virtual_hosts: | ||
| - name: local_service | ||
| domains: ["*"] | ||
| routes: | ||
| - match: { prefix: "/" } | ||
| route: | ||
| cluster: greeter_service | ||
| max_grpc_timeout: 0s | ||
| cors: | ||
| allow_origin_string_match: | ||
| - prefix: "*" | ||
| allow_methods: GET, PUT, DELETE, POST, OPTIONS | ||
| allow_headers: keep-alive,user-agent,cache-control,content-type,content-transfer-encoding,custom-header-1,x-accept-content-transfer-encoding,x-accept-response-streaming,x-user-agent,x-grpc-web,grpc-timeout | ||
| max_age: "1728000" | ||
| expose_headers: custom-header-1,grpc-status,grpc-message | ||
| http_filters: | ||
| - name: envoy.grpc_web | ||
| - name: envoy.cors | ||
| - name: envoy.router | ||
| clusters: | ||
| - name: greeter_service | ||
| connect_timeout: 0.25s | ||
| type: logical_dns | ||
| http2_protocol_options: {} | ||
| lb_policy: round_robin | ||
| hosts: [{ socket_address: { address: 0.0.0.0, port_value: 9090 } }] |
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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,20 @@ | ||
| # Backend | ||
|
|
||
| This backend holds a GRPC server that classify OpenBCI raw EEG data into sleep stages. | ||
|
|
||
| ## How to run | ||
|
|
||
| I you are running the front-end, you'll need to build the dockerfile to get the Envoy proxy. | ||
|
|
||
| > docker build -t polydodo-web . | ||
|
|
||
| > docker run -d -p 8080:8080 -p 9090:9090 --network=host polydodo-web | ||
|
|
||
| To start the server: | ||
|
|
||
| > python backend/app.py | ||
|
|
||
| ## Get requirements: | ||
|
|
||
| > python -m venv .venv | ||
| > python -m pip install -r requirements.txt |
This file contains hidden or 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 |
|---|---|---|
| @@ -1,17 +1,2 @@ | ||
| click==7.1.1 | ||
| Flask==1.1.1 | ||
| Flask-SQLAlchemy==2.4.1 | ||
| itsdangerous==1.1.0 | ||
| Jinja2==2.11.1 | ||
| MarkupSafe==1.1.1 | ||
| mne==0.19.2 | ||
| numpy==1.18.2 | ||
| pandas==1.0.3 | ||
| pandas-schema==0.3.5 | ||
| python-dateutil==2.8.1 | ||
| pytz==2019.3 | ||
| scipy==1.4.1 | ||
| six==1.14.0 | ||
| SQLAlchemy==1.3.15 | ||
| Werkzeug==1.0.0 | ||
| grpcio==1.32.0 | ||
| protobuf==3.13.0 | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.