Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: actions/checkout@v2
- uses: docker/build-push-action@v1
with:
dockerfile: backend/Dockerfile
context: backend
username: ${{ github.actor }}
password: ${{ github.token }}
registry: docker.pkg.github.com/polycortex/polydodo
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/mobile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ jobs:
with:
java-version: "8.x"
- uses: subosito/flutter-action@v1
- uses: abelfodil/protoc-action@v1
with:
enable-dart: true

- run: protoc --proto_path=protos protos/* --dart_out=grpc:mobile/lib/protos
working-directory: .

- run: flutter pub get

Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: abelfodil/protoc-action@v1
with:
enable-grpc-web: true
- run: protoc protos/* --js_out=import_style=commonjs:web/src --grpc-web_out=import_style=commonjs,mode=grpcwebtext:web/src

- run: yarn --cwd web install
- run: yarn --cwd web build
- uses: actions/upload-artifact@v2
Expand Down
14 changes: 2 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,18 @@ This projects aims to offer a comprehensive guide to **record polysomnographic E

## Dev requirements

### gRPC

- Install `gRPC` package from your distribution's package manager
- Install `protoc` compiler

### Web

- Install Yarn package manager
- `yarn global add protoc-gen-grpc-web`
- Add `$HOME/.yarn/bin` to `PATH`

### Python

- Install Python 3 and pip
- Consider using `venv` to create a virtual environment
- Install gRPC using a package manager or by compiling the [source code](https://github.com/grpc/grpc)
- Create a simlink named `protoc-gen-grpc_python` to `grpc_python_plugin` using `ln -nsf $(which grpc_python_plugin) /some/where/in/your/path/protoc-gen-grpc_python`

### Flutter

- Install the latest stable version of flutter
- Run `flutter pub global activate protoc_plugin`
- Add `$HOME/.pub-cache/bin` to `PATH`

### VS Code

Expand All @@ -36,9 +25,10 @@ This projects aims to offer a comprehensive guide to **record polysomnographic E
## Dev workflow

- Open workspace `polydodo.code-workspace`
- Install Python packages by running `pip install --user -r backend/requirements.txt`
- Install node modules by running `yarn install --cwd web`
- Fetch Flutter dependencies through the `Flutter` extension
- Compile all protos through `proto3` extension
- Start dev server by running `python backend/app.py`

## Running the server locally

Expand Down
19 changes: 3 additions & 16 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
FROM namely/protoc-all as generator
WORKDIR /
COPY protos protos
COPY backend backend
RUN ln $(which grpc_python_plugin) /usr/bin/protoc-gen-grpc_python
RUN protoc protos/* --python_out=backend --grpc_python_out=backend

FROM envoyproxy/envoy:v1.15-latest
RUN apt-get update \
&& apt-get -y install python3-pip \
&& apt-get autoremove -y \
&& apt-get clean \
&& rm -rf /tmp/* /var/tmp/* \
&& rm -rf /var/lib/apt/lists/*
COPY --from=generator /backend /backend
FROM python
COPY . /backend
WORKDIR /backend
RUN pip3 install -r requirements.txt --no-cache-dir
CMD "./start.sh"
CMD ["python", "app.py"]
44 changes: 9 additions & 35 deletions backend/app.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,14 @@
# 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 flask import Flask
from flask_cors import CORS
from waitress import serve

from concurrent import futures
import logging
app = Flask(__name__)
cors = CORS(app)

import grpc

from protos import helloworld_pb2
from protos import helloworld_pb2_grpc
@app.route("/")
def hello():
return "Hello, World!"


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__':
logging.basicConfig()
serve()
serve(app, host='0.0.0.0', port=8080)
40 changes: 0 additions & 40 deletions backend/envoy.yaml

This file was deleted.

2 changes: 0 additions & 2 deletions backend/protos/.gitignore

This file was deleted.

20 changes: 0 additions & 20 deletions backend/readme.md

This file was deleted.

5 changes: 3 additions & 2 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
grpcio==1.32.0
protobuf==3.13.0
Flask==1.1.2
Flask-Cors==1.10.3
waitress==1.4.4
2 changes: 1 addition & 1 deletion backend/setup.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[flake8]
ignore = D203
exclude = __pycache__,old,build,dist,backend/protos
exclude = __pycache__,old,build,dist
max-complexity = 10
5 changes: 0 additions & 5 deletions backend/start.sh

This file was deleted.

19 changes: 0 additions & 19 deletions mobile/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,26 +1,7 @@
import 'package:polydodo/protos/helloworld.pbgrpc.dart';
import 'package:grpc/grpc.dart';
import 'package:flutter/material.dart';

import 'protos/helloworld.pb.dart';
import 'src/app.dart';

void main() async {
// GRPC TEST
final channel = ClientChannel(
const String.fromEnvironment('HOST'),
port: 9090,
options: const ChannelOptions(credentials: ChannelCredentials.insecure()),
);
final stub = GreeterClient(channel);

try {
final response = await stub.sayHello(HelloRequest()..name = 'world');
print('Greeter client received: ${response.message}');
} catch (e) {
print('Caught error: $e');
}
await channel.shutdown();
// END OF TEST
runApp(App());
}
2 changes: 0 additions & 2 deletions mobile/lib/protos/.gitignore

This file was deleted.

Loading