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

Feature/local development #7

Merged
merged 4 commits into from
Sep 8, 2021
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
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ DOCKER_OWNER = helxplatform
DOCKER_APP = tranql
DOCKER_TAG = ${VERSION}
DOCKER_IMAGE = ${DOCKER_OWNER}/${DOCKER_APP}:$(DOCKER_TAG)
TEST_REDIS_DUMP_FILE = "https://stars.renci.org/var/kgx_data/v3.0/roger-mini.rdb"


.DEFAULT_GOAL = help

Expand Down Expand Up @@ -58,3 +60,15 @@ build:
publish:
docker tag ${DOCKER_IMAGE} ${DOCKER_REPO}/${DOCKER_IMAGE}
docker push ${DOCKER_REPO}/${DOCKER_IMAGE}

#download: Downloads example dataset for redis
download:
mkdir -p redis_data/
if [ ! -f "./redis_data/dump.rdb" ] ; then \
wget ${TEST_REDIS_DUMP_FILE} -O redis_data/dump.rdb; \
fi

#run.local: seeds redis with data, builds web page and runs tranql docker container
run.local: download
docker-compose up -d
cd src/tranql/web; npm start;
22 changes: 16 additions & 6 deletions QUICKSTART.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
## Setting up server

## Setting up the Frontend
Note: For building react app nodejs and npm are required.

1. cd web
1. npm install
1. node --max-old-space-size=4000 ./node_modules/react-scripts/scripts/build.js
1. cd ..
1. cp -r web/build/static/ src/tranql/static
1. Install node js dependencies.
```shell
make install.npm
```
2. Runs Tranql in a docker container, with reload enabled for the web server. UI is not reloaded on change but one can start
cd
```shell
make run.local
```

3. Browse to
1. [Tranql UI](http://localhost:8001)
2. [Openapi Swagger UI](http://localhost:8001/apidocs)
3. [Tranql UI served from Nodejs](http://localhost:3000)
16 changes: 16 additions & 0 deletions dev-schema.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
doc : |
The Translator schema aggregates reasoner schemas. Reasoner schemas
describe transitions between biolink-model types. These transitions are
expressed as predicates, also from the biolink-model.
schema:
redis:
doc: |
Roger is a knowledge graph built by aggregeting several kgx formatted knowledge graphs from several sources.
url: "redis:test"
redis: true
redis_connection_params:
host: redis_graph
port: 6379
# SET USERNAME and PASSWORD
# via ROGER_USERNAME , ROGER_PASSWORD Env vars (i.e capitialize service name)
28 changes: 14 additions & 14 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
version: "3"
services:
backplane:
image: cschreep/tranql:0.2.dev0
# build:
# dockerfile: Dockerfile
# context: .
ports:
- "${BACKPLANE_PORT}:${BACKPLANE_PORT}"
command: gunicorn --workers=2 --bind=0.0.0.0:$BACKPLANE_PORT --name=backplane --timeout=600 tranql.backplane.server:app
tranql:
image: cschreep/tranql:0.2.dev0
# build:
# dockerfile: Dockerfile
# context: .
build:
dockerfile: Dockerfile
context: .
ports:
- "${APP_PORT}:${APP_PORT}"
command: gunicorn --workers=2 --bind=0.0.0.0:$APP_PORT --name=tranql --timeout=600 tranql.api:app
- "8001:8001"
command: gunicorn --workers=1 --bind=0.0.0.0:8001 --name=tranql --timeout=600 --reload tranql.api:app
environment:
- SCHEMA_CONFIG_PATH=/home/tranql/dev-schema.yaml
volumes:
- ./src:/home/tranql/tranql/src
- ./dev-schema.yaml:/home/tranql/dev-schema.yaml
redis_graph:
image: redislabs/redisgraph
volumes:
- ./redis_data:/data
4 changes: 2 additions & 2 deletions src/tranql/conf/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ schema:
url: "redis:test"
redis: true
redis_connection_params:
host: localhost
port: 6380
host: redis_graph
port: 6379
# SET USERNAME and PASSWORD
# via ROGER_USERNAME , ROGER_PASSWORD Env vars (i.e capitialize service name)
4 changes: 3 additions & 1 deletion src/tranql/tranql_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,9 @@ def __init__(self, backplane, use_registry, tranql_config, skip_redis=False):

""" Load the schema, a map of reasoner systems to maps of their schemas. """
self.config = None
config_file = os.path.join(os.path.dirname(__file__), "conf", "schema.yaml")
config_file = os.environ.get("SCHEMA_CONFIG_PATH",
os.path.join(os.path.dirname(__file__), "conf", "schema.yaml")
)
with open(config_file) as stream:
self.config = yaml.safe_load(stream)

Expand Down