Skip to content

Commit

Permalink
update overview and instructions in README
Browse files Browse the repository at this point in the history
  • Loading branch information
jaeddy committed Jun 28, 2019
1 parent 85cfef7 commit 2b6d9c4
Showing 1 changed file with 35 additions and 24 deletions.
59 changes: 35 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,55 @@ Lightweight implementation of the Synapse Activity services, based on the PROV s

## Overview

This is an OpenAPI-enabled (and documented) Flask server. This example uses the [Connexion](https://github.com/zalando/connexion) library on top of Flask. The [MongoEngine](https://github.com/MongoEngine/mongoengine) ODM library for Python is used to manage operations between RESTful API requests/responses and a MongoDB database. Additionally, the [Graphene-Mongo](https://github.com/graphql-python/graphene-mongo) library enables integration of MongoEngine with [Graphene](https://github.com/graphql-python/graphene) to provide a GraphQL endpoint.
This is an OpenAPI-enabled (and documented) Flask server. This example uses the [Connexion](https://github.com/zalando/connexion) library on top of Flask. The [py2neo]() driver library for Python is used to manage operations between RESTful API requests/responses and a Neo4j database.

## Requirements

Python 3.5.2+

You should have a local installation of MongoDB (tested with 4.0.8) with a connection to a database named `provDB`. See [this tutorial](https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/) for getting set up with MongoDB on MacOS using `brew`.
You should have access to a local installation of Neo4j, serving at `bolt://localhost/7687`.

You'll also need to set two environment variables based on your Neo4j configuration (the Flask app uses these to connect to the database):

```shell
export NEO4J_USERNAME=<username>
export NEO4J_PASSWORD=<password>
```

## Usage

To run the server, please execute the following from the root directory:

```
pip install -r requirements.txt
pip install .
pip install -r requirements.txt .
```

and open your browser to here:

To start the app, you can use this command:
```shell
synprov
```
http://localhost:8080/rest/ui/

### Neo4j browser

If you have the **Neo4j Desktop** application installed, you should be able to view and explore the graph database using Cypher queries. For example, to view all nodes and relationships:

```cypher
MATCH (n) RETURN n
```

Your OpenAPI definition lives here:

### Swagger UI

You can also interact with the graph database through RESTful API queries. The service provides a Swagger UI endpoint to test requests through the browser:

```
http://localhost:8080/rest/openapi.json
http://localhost:8080/rest/ui/
```

You can reach the GraphQL interface here:
The OpenAPI definition lives here:

http://localhost:8080/graphql/

To launch the integration tests, use tox:
```
sudo pip install tox
tox
http://localhost:8080/rest/openapi.json
```

## Running with Docker
Expand All @@ -57,18 +69,17 @@ After running this command, the URLs in the previous section should work.

## Development

This server was originally generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI-Spec](https://openapis.org) from a remote server, you can easily generate a server stub.

Starting with the Synapse Activity API specification in a `swagger.yaml`, the contents of this repo were generated with the following command:

To add changes locally, install the package in developer mode:
```
npx openapi-generator generate -i swagger.yaml -g python-flask -DpackageName=synprov -o prov-service/
pip install -r requirements.txt -e .
```

After editing the OpenAPI YAML spec, controller and model code were iteratively regenerated with the following command:
## OpenAPI Generator

This server was originally generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI-Spec](https://openapis.org) from a remote server, you can easily generate a server stub.

Starting with the Synapse Activity API specification in a `swagger.yaml`, the contents of this repo were generated with the following command:

```
npx openapi-generator generate -i synprov/openapi/openapi.yaml -g python-flask -c .openapi-generator-config
npx openapi-generator generate -i swagger.yaml -g python-flask -DpackageName=synprov -o prov-service/
```

> **Note:** with the API spec now relatively stable, this process has been deprecated in favor of manually keeping the code and documentation in sync — `openapi-generator` will overwrite all controller code, in addition to updating models, which isn't as helpful with working methods in place.

0 comments on commit 2b6d9c4

Please sign in to comment.