Skip to content

Commit

Permalink
Merge 88cdac4 into b2f55be
Browse files Browse the repository at this point in the history
  • Loading branch information
ejhumphrey committed Nov 29, 2016
2 parents b2f55be + 88cdac4 commit bd68d30
Show file tree
Hide file tree
Showing 18 changed files with 923 additions and 129 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ lib/
lib64/
parts/
sdist/
tmp/
var/
*.egg-info/
.installed.cfg
Expand Down
22 changes: 15 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
sudo: false

apt:
packages:
- libgflags-dev
- libgtest-dev

cache:
directories:
- $HOME/env
Expand All @@ -10,16 +15,19 @@ notifications:
email: false

python:
- "2.7"
- "3.4"
- "3.5"
- "2.7"
- "3.4"
- "3.5"

install:
- pip install coveralls
- pip install -t backend_server/lib -r backend_server/requirements/setup/requirements_dev.txt
- pip install --upgrade pip
- pip install --upgrade tox
- pip install --upgrade protobuf
- pip install coveralls
- pip install -U -r backend_server/requirements/setup/requirements_dev.txt

script:
- PYTHONPATH=backend_server/lib:$PYTHONPATH py.test -vs backend_server/test_main.py
- PYTHONPATH=backend_server:$PYTHONPATH py.test -v --cov=pybackend backend_server/tests

after_success:
- coveralls
- coveralls
48 changes: 35 additions & 13 deletions backend_server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,33 @@ This is the source for the backend Flask server, responsible for the following:
- Validating annotation submissions
- Returning user statistics on request


## Annotation State Diagram
![Annotation State Diagram](https://github.com/cosmir/open-mic/raw/master/docs/img/annotation_state_diagram.png "Annotation State Diagram")


## Dependencies

First, install the [App Engine Python SDK](https://developers.google.com/appengine/downloads).

Next, install dependencies in a directory local to this project, e.g. `lib`. App Engine will only be able to import libraries uploaded with the project.

```
$ pip install -r requirements/setup/requirements_dev.txt -t lib
```


## Testing

Having taken care of dependencies, you should be able to run the test suite:

```
$ py.test -v .
```

All tests should pass; halt everything if this is not the case. In all likelihood, failure is the result of a broken / missing dependency, but please create a new issue (with a console log and steps to reproduce) if you believe otherwise.


## Using the CAS machinery

### Running Locally
Expand All @@ -22,11 +46,10 @@ Then, once that's all set, you should be able to do the following from
repository root:

```
$ cd backend_server
$ dev_appserver.py .
```

At this point, the endpoints should be live via localhost:
At this point, the endpoints should be live via localhost (default deployment is to port 8080):

```
$ curl -X GET localhost:8080/annotation/taxonomy
Expand All @@ -35,6 +58,8 @@ $ curl -F "audio=@some_file.mp3" localhost:8080/audio/upload

### Deploying to App Engine

`TODO(ejhumphrey):` Is it possible to have pre-deployment testing hooks? If so, that should be documented here. **Update:** Survey says [yes](https://github.com/GoogleCloudPlatform/continuous-deployment-demo/blob/master/.travis.yml).

For the time being, you will need to create your own App Engine project. To do
so, [follow the directions here](https://console.cloud.google.com/freetrial?redirectPath=/start/appengine).

Expand All @@ -50,26 +75,23 @@ $ appcfg.py -A <PROJECT_ID> -V v1 update .
From here, the app should be deployed to the following URL:

```
http://<PROJECT_ID>.appspot.com
http://<PROJECT_ID>.appspot.com
```

You can then poke the endpoints as one would expect:

```
$ curl -X GET http://<PROJECT_ID>.appspot.com/annotation/taxonomy
$ curl -F "audio=@some_file.mp3" http://<PROJECT_ID>/audio/upload
$ curl -X GET http://<PROJECT_ID>.appspot.com/annotation/taxonomy
$ curl -F "audio=@some_file.mp3" http://<PROJECT_ID>/audio/upload
```

### Shutting Down App Engine

After deploying the application, you may wish to shut it down so as to not
ring up unnecessary charges / usage. Proceed to the following URL and click
all the things that say "Shutdown" for maximum certainty:
## Shutting Down App Engine

After deploying the application, you may wish to shut it down so as to not ring up unnecessary charges / usage. Proceed to the following URL and click all the things that say "Shutdown" for maximum certainty:

```
https://console.cloud.google.com/appengine/instances?project=<PROJECT_ID>
https://console.cloud.google.com/appengine/instances?project=<PROJECT_ID>
```

Be sure to replace <PROJECT_ID> with the appropriate one matching the account
you've configured.

Be sure to replace `<PROJECT_ID>` with the appropriate one matching the account you've configured.
Empty file added backend_server/favicon.ico
Empty file.
7 changes: 7 additions & 0 deletions backend_server/gcloud_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"project_id": "<YOUR_PROJECT_ID>",
"storage": {
"name": "audio-data",
"backend": "gcp"
}
}
13 changes: 13 additions & 0 deletions backend_server/local_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"project_id": "<YOUR_PROJECT_ID>",
"storage": {
"name": "audio-data",
"backend": "local",
"local_dir": "tmp"
},
"database": {
"backend": "local",
"filepath": "tmp/database-file.json",
"mode": "a"
}
}
Loading

0 comments on commit bd68d30

Please sign in to comment.