diff --git a/Makefile b/Makefile index 790fb57..2423815 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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; \ No newline at end of file diff --git a/QUICKSTART.md b/QUICKSTART.md index 0a8d480..21caa59 100644 --- a/QUICKSTART.md +++ b/QUICKSTART.md @@ -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) diff --git a/dev-schema.yaml b/dev-schema.yaml new file mode 100644 index 0000000..b31e6da --- /dev/null +++ b/dev-schema.yaml @@ -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) diff --git a/docker-compose.yml b/docker-compose.yml index ee4afab..3e12c40 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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 \ No newline at end of file + - "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 \ No newline at end of file diff --git a/src/tranql/conf/schema.yaml b/src/tranql/conf/schema.yaml index 6d21344..b1f74a3 100644 --- a/src/tranql/conf/schema.yaml +++ b/src/tranql/conf/schema.yaml @@ -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) diff --git a/src/tranql/tranql_schema.py b/src/tranql/tranql_schema.py index 25f55c3..dfae8ea 100644 --- a/src/tranql/tranql_schema.py +++ b/src/tranql/tranql_schema.py @@ -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)