From 5370eda2893ceab58e28cfd75db385fa6a99379c Mon Sep 17 00:00:00 2001 From: Jono Gray Date: Wed, 1 May 2019 11:04:05 +0100 Subject: [PATCH 01/29] Sketching out dockerised examples --- .dockerignore | 29 +++++++++++++++++++++++++++++ Dockerfile | 9 +++++++++ docker-compose.yml | 23 +++++++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..f03d1db99c --- /dev/null +++ b/.dockerignore @@ -0,0 +1,29 @@ +# This .dockerignore file follows the "whitelisting" approach described here: +# https://youknowfordevs.com/2018/12/07/getting-control-of-your-dockerignore-files.html + +# +# First, exclude everything by default: +# + +* + +# +# Now un-exclude only those folders and files that are needed for building the image: +# +!docs/source/worked_examples/*.ipynb + +!flowmachine/flowmachine +!flowmachine/Pipfile* +!flowmachine/setup.cfg +!flowmachine/setup.py +!flowmachine/README.md +!flowmachine/versioneer.py +!flowmachine/MANIFEST.in + +!flowclient/flowclient +!flowclient/Pipfile* +!flowclient/setup.cfg +!flowclient/setup.py +!flowclient/README.md +!flowclient/versioneer.py +!flowclient/MANIFEST.in \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..9ea1c51d19 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM jupyter/datascience-notebook +RUN rm -rf /home/$NB_USER/work +COPY docs/source/worked_examples/*.ipynb /home/$NB_USER/ +COPY flowmachine /flowmachine +COPY flowclient /flowclient +RUN pip install folium /flowclient /flowmachine && \ + fix-permissions $CONDA_DIR && \ + fix-permissions /home/$NB_USER && \ + cd /home/$NB_USER/ && jupyter trust -y * \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 5d85cc9cd2..b250485f51 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -113,6 +113,29 @@ services: - db - redis + worked_examples: + container_name: worked_examples + image: flowminder/flowkit_worked_examples:latest + build: + context: . + dockerfile: Dockerfile + ports: + - 8888 + tty: true + stdin_open: true + environment: + - FLOWDB_PORT=5432 + - FLOWDB_HOST=${DOCKER_FLOWDB_HOST:?Must set DOCKER_FLOWDB_HOST env var} + - FLOWMACHINE_FLOWDB_USER=${FLOWMACHINE_FLOWDB_USER:?Must set FLOWMACHINE_FLOWDB_USER env var} + - FLOWMACHINE_FLOWDB_PASSWORD=${FLOWMACHINE_FLOWDB_PASSWORD:?Must set FLOWMACHINE_FLOWDB_PASSWORD env var} + - REDIS_HOST=query_locker + - REDIS_PORT=6379 + - REDIS_PASSWORD=${REDIS_PASSWORD:?Must set REDIS_PASSWORD env var} + restart: always + networks: + - db + - redis + flowapi: container_name: flowapi image: flowminder/flowapi:${CONTAINER_TAG:-latest} From 4e1cae873328d775ddeff9d0d8c72ea4c583ff27 Mon Sep 17 00:00:00 2001 From: Jono Gray Date: Wed, 1 May 2019 12:29:06 +0100 Subject: [PATCH 02/29] Try building the examples on circle --- .circleci/config.yml | 13 ++++++++++--- .dockerignore | 3 +++ Dockerfile | 5 +++++ docker-compose.yml | 2 +- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 962252b743..a43237659b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -461,7 +461,10 @@ jobs: parameters: component: type: enum - enum: ["flowmachine", "flowauth", "flowapi"] + enum: ["flowmachine", "flowauth", "flowapi", "flowkit-examples"] + component_path: + type: string + default: <> docker: - image: circleci/python:3.7 working_directory: /home/circleci/project/ @@ -478,7 +481,7 @@ jobs: name: Build <> image command: | echo "Tagging as $CIRCLE_SHA1" - docker build -t flowminder/<>:$CIRCLE_SHA1 ./<> + docker build -t flowminder/<>:$CIRCLE_SHA1 ./<> - run: name: Push images to Docker cloud command: | @@ -630,7 +633,7 @@ jobs: command: | export DOCKER_USER=$DOCKER_CLOUD_USER export DOCKER_PASS=$DOCKER_CLOUD_PASSWORD - for IMAGE in flowapi flowmachine flowdb flowdb-synthetic-data flowdb-testdata flowauth; do + for IMAGE in flowapi flowmachine flowdb flowdb-synthetic-data flowdb-testdata flowauth flowkit-examples; do docker-retag flowminder/$IMAGE:$CIRCLE_SHA1 ${<< parameters.tag >>:-latest} done @@ -678,6 +681,10 @@ workflows: requires: - build_flowdb <<: *run_always_org_context + - build_docker_image: + name: build_examples + component: flowkit-examples + <<: *run_always_org_context - build_docker_image: name: build_flowmachine component: flowmachine diff --git a/.dockerignore b/.dockerignore index f03d1db99c..91244e8c51 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,6 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. # This .dockerignore file follows the "whitelisting" approach described here: # https://youknowfordevs.com/2018/12/07/getting-control-of-your-dockerignore-files.html diff --git a/Dockerfile b/Dockerfile index 9ea1c51d19..148e02c9d7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,10 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. FROM jupyter/datascience-notebook + RUN rm -rf /home/$NB_USER/work + COPY docs/source/worked_examples/*.ipynb /home/$NB_USER/ COPY flowmachine /flowmachine COPY flowclient /flowclient diff --git a/docker-compose.yml b/docker-compose.yml index b250485f51..9b71ef9015 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -115,7 +115,7 @@ services: worked_examples: container_name: worked_examples - image: flowminder/flowkit_worked_examples:latest + image: flowminder/flowkit-examples:latest build: context: . dockerfile: Dockerfile From 8f0080c0daf2196aa1901a094ba84e854a15cc13 Mon Sep 17 00:00:00 2001 From: Jono Gray Date: Wed, 1 May 2019 13:47:35 +0100 Subject: [PATCH 03/29] Add to makefile, split into build and pull --- Makefile | 10 ++++++++++ docker-compose-build.yml | 7 +++++++ docker-compose.yml | 5 +---- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index e98d4d4831..c1550952ab 100644 --- a/Makefile +++ b/Makefile @@ -108,6 +108,16 @@ flowauth-build: docker-compose -f $(DOCKER_COMPOSE_FILE) -f $(DOCKER_COMPOSE_FILE_BUILD) build flowauth +worked-examples-up: worked-examples-build + docker-compose -f $(DOCKER_COMPOSE_FILE) -f $(DOCKER_COMPOSE_FILE_BUILD) up -d --build worked_examples + +worked-examples-down: + docker-compose -f $(DOCKER_COMPOSE_FILE) rm -f -s -v worked_examples + +worked-examples-build: + docker-compose -f $(DOCKER_COMPOSE_FILE) -f $(DOCKER_COMPOSE_FILE_BUILD) build worked_examples + + flowmachine_query_locker-up: docker-compose -f $(DOCKER_COMPOSE_FILE) up -d flowmachine_query_locker diff --git a/docker-compose-build.yml b/docker-compose-build.yml index 3a7646ab85..b5d2654d56 100644 --- a/docker-compose-build.yml +++ b/docker-compose-build.yml @@ -33,6 +33,13 @@ services: context: ./flowmachine dockerfile: Dockerfile + worked_examples: + container_name: worked_examples + image: flowminder/flowkit-examples:${CONTAINER_TAG:-latest} + build: + context: . + dockerfile: Dockerfile + flowapi: image: flowminder/flowapi:${CONTAINER_TAG:-latest} build: diff --git a/docker-compose.yml b/docker-compose.yml index 9b71ef9015..94babce03a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -115,10 +115,7 @@ services: worked_examples: container_name: worked_examples - image: flowminder/flowkit-examples:latest - build: - context: . - dockerfile: Dockerfile + image: flowminder/flowkit-examples:${CONTAINER_TAG:-latest} ports: - 8888 tty: true From 8f1b949dc7d212792e22cc88df9011396d35fe86 Mon Sep 17 00:00:00 2001 From: Jono Gray Date: Wed, 1 May 2019 14:26:18 +0100 Subject: [PATCH 04/29] Don't tag the worked examples as eveyrthing --- .circleci/config.yml | 8 ++++---- docker-compose.yml | 2 ++ quick_start.sh | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a43237659b..8a58153d51 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -462,9 +462,6 @@ jobs: component: type: enum enum: ["flowmachine", "flowauth", "flowapi", "flowkit-examples"] - component_path: - type: string - default: <> docker: - image: circleci/python:3.7 working_directory: /home/circleci/project/ @@ -481,7 +478,10 @@ jobs: name: Build <> image command: | echo "Tagging as $CIRCLE_SHA1" - docker build -t flowminder/<>:$CIRCLE_SHA1 ./<> + if [[ <> != "flowkit-examples ]]; then + cd <> + fi + docker build -t flowminder/<>:$CIRCLE_SHA1 . - run: name: Push images to Docker cloud command: | diff --git a/docker-compose.yml b/docker-compose.yml index 94babce03a..2fb4ebf13c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -132,6 +132,8 @@ services: networks: - db - redis + command: + ["start-notebook.sh", "c.NotebookApp.token = 'b2a960c88d617bde49e592da8b60d09b3527873cb5a50db2'"] flowapi: container_name: flowapi diff --git a/quick_start.sh b/quick_start.sh index 2473ecc02d..197d3174e5 100755 --- a/quick_start.sh +++ b/quick_start.sh @@ -65,11 +65,11 @@ then else source /dev/stdin <<< "$(curl -s https://raw.githubusercontent.com/Flowminder/FlowKit/${BRANCH:-master}/development_environment)" echo "Starting containers" - RUNNING=`curl -s https://raw.githubusercontent.com/Flowminder/FlowKit/${BRANCH:-master}/docker-compose.yml | docker-compose -f - ps -q $DOCKER_FLOWDB_HOST flowapi flowmachine flowauth flowmachine_query_locker` + RUNNING=`curl -s https://raw.githubusercontent.com/Flowminder/FlowKit/${BRANCH:-master}/docker-compose.yml | docker-compose -f - ps -q $DOCKER_FLOWDB_HOST flowapi flowmachine flowauth flowmachine_query_locker worked_examples` if [[ "$RUNNING" != "" ]]; then confirm "Existing containers are running and will be replaced. Are you sure?" || exit 1 fi - curl -s https://raw.githubusercontent.com/Flowminder/FlowKit/${BRANCH:-master}/docker-compose.yml | docker-compose -f - up -d $DOCKER_FLOWDB_HOST flowapi flowmachine flowauth flowmachine_query_locker + curl -s https://raw.githubusercontent.com/Flowminder/FlowKit/${BRANCH:-master}/docker-compose.yml | docker-compose -f - up -d $DOCKER_FLOWDB_HOST flowapi flowmachine flowauth flowmachine_query_locker worked_examples echo "Waiting for containers to be ready.." docker exec ${DOCKER_FLOWDB_HOST} bash -c 'i=0; until [ $i -ge 24 ] || (pg_isready -h 127.0.0.1 -p 5432); do let i=i+1; echo Waiting 10s; sleep 10; done' || (>&2 echo "FlowDB failed to start :( Please open an issue at https://github.com/Flowminder/FlowKit/issues/new?template=bug_report.md&labels=FlowDB,bug including the output of running 'docker logs flowdb'" && exit 1) echo "FlowDB ready." From 6fcd8f080d9d3c152f6af279e820b59515385d41 Mon Sep 17 00:00:00 2001 From: Jono Gray Date: Wed, 1 May 2019 14:27:19 +0100 Subject: [PATCH 05/29] SYntax --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8a58153d51..7e865f5f92 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -478,7 +478,7 @@ jobs: name: Build <> image command: | echo "Tagging as $CIRCLE_SHA1" - if [[ <> != "flowkit-examples ]]; then + if [[ "<>" != "flowkit-examples" ]]; then cd <> fi docker build -t flowminder/<>:$CIRCLE_SHA1 . From 38e2595895dfbbdf2744fbfcf73bb21b7606e898 Mon Sep 17 00:00:00 2001 From: Jono Gray Date: Wed, 1 May 2019 14:32:37 +0100 Subject: [PATCH 06/29] Less hacky --- .circleci/config.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7e865f5f92..b98930bc05 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -462,6 +462,8 @@ jobs: component: type: enum enum: ["flowmachine", "flowauth", "flowapi", "flowkit-examples"] + component_path: + type: string docker: - image: circleci/python:3.7 working_directory: /home/circleci/project/ @@ -478,10 +480,7 @@ jobs: name: Build <> image command: | echo "Tagging as $CIRCLE_SHA1" - if [[ "<>" != "flowkit-examples" ]]; then - cd <> - fi - docker build -t flowminder/<>:$CIRCLE_SHA1 . + docker build -t flowminder/<>:$CIRCLE_SHA1 <> - run: name: Push images to Docker cloud command: | @@ -684,10 +683,12 @@ workflows: - build_docker_image: name: build_examples component: flowkit-examples + component_path: . <<: *run_always_org_context - build_docker_image: name: build_flowmachine component: flowmachine + component_path: flowmachine requires: - run_flowmachine_tests <<: *run_always_org_context @@ -700,6 +701,7 @@ workflows: - build_docker_image: name: build_flowauth component: flowauth + component_path: flowauth requires: - run_flowauth_backend_tests - run_flowauth_frontend_tests @@ -707,6 +709,7 @@ workflows: - build_docker_image: name: build_flowapi component: flowapi + component_path: flowapi requires: - run_flowkit_api_tests <<: *run_always_org_context From 29fd05dd45b59b55b7b6ab3fe1bf5811af234478 Mon Sep 17 00:00:00 2001 From: Jono Gray Date: Wed, 1 May 2019 14:57:51 +0100 Subject: [PATCH 07/29] Correct token option --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 2fb4ebf13c..97f14dc67b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -133,7 +133,7 @@ services: - db - redis command: - ["start-notebook.sh", "c.NotebookApp.token = 'b2a960c88d617bde49e592da8b60d09b3527873cb5a50db2'"] + ["start-notebook.sh", "--NotebookApp.token = 'b2a960c88d617bde49e592da8b60d09b3527873cb5a50db2'"] flowapi: container_name: flowapi From 260d67813af9c6e6e41c2e5335eee7d146857715 Mon Sep 17 00:00:00 2001 From: Jono Gray Date: Wed, 1 May 2019 15:04:49 +0100 Subject: [PATCH 08/29] Fix worked examples to a port, check they came up in quickstart --- development_environment | 4 ++++ docker-compose.yml | 2 +- quick_start.sh | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/development_environment b/development_environment index 4c09fadf05..0d3199561a 100644 --- a/development_environment +++ b/development_environment @@ -116,3 +116,7 @@ OUTPUT_ROOT_DIR=/docker-entrypoint-initdb.d # Integration tests FLOWKIT_INTEGRATION_TESTS_DISABLE_AUTOSTART_SERVERS=FALSE + +# Worked examples + +WORKED_EXAMPLES_PORT=8888 \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 97f14dc67b..6951b06af9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -117,7 +117,7 @@ services: container_name: worked_examples image: flowminder/flowkit-examples:${CONTAINER_TAG:-latest} ports: - - 8888 + - ${WORKED_EXAMPLES_PORT:?Must set WORKED_EXAMPLES_PORT env var}:8888 tty: true stdin_open: true environment: diff --git a/quick_start.sh b/quick_start.sh index 197d3174e5..5d1e5575d3 100755 --- a/quick_start.sh +++ b/quick_start.sh @@ -79,9 +79,12 @@ else echo "FlowAPI ready." i=0; until [ $i -ge 24 ] || (curl -s http://localhost:$FLOWAUTH_PORT > /dev/null) ; do let i=i+1; echo Waiting 10s; sleep 10; done || (>&2 echo "FlowAuth failed to start :( Please open an issue at https://github.com/Flowminder/FlowKit/issues/new?template=bug_report.md&labels=FlowAuth,bug including the output of running 'docker logs flowauth'" && exit 1) echo "FlowAuth ready." + i=0; until [ $i -ge 24 ] || (curl -s http://localhost:$WORKED_EXAMPLES_PORT > /dev/null) ; do let i=i+1; echo Waiting 10s; sleep 10; done || (>&2 echo "Worked examples failed to start :( Please open an issue at https://github.com/Flowminder/FlowKit/issues/new?template=bug_report.md&labels=docs,bug including the output of running 'docker logs worked_examples'" && exit 1) + echo "Worked examples ready." echo "All containers ready!" echo "Access FlowDB using 'PGHOST=$FLOWDB_HOST PGPORT=$FLOWDB_PORT PGDATABASE=flowdb PGUSER=$FLOWMACHINE_FLOWDB_USER PGPASSWORD=$FLOWMACHINE_FLOWDB_PASSWORD psql'" echo "Access FlowAPI using FlowClient at http://localhost:$FLOWAPI_PORT" echo "View the FlowAPI spec at http://localhost:$FLOWAPI_PORT/api/0/spec/redoc" echo "Generate FlowAPI access tokens using FlowAuth with user TEST_USER and password DUMMY_PASSWORD at http://localhost:$FLOWAUTH_PORT" + echo "Try out the interactive examples at http://localhost:$FLOWAUTH_PORT/?token=b2a960c88d617bde49e592da8b60d09b3527873cb5a50db2" fi \ No newline at end of file From c9ceb2ad3662fd6c177a88163b6009eb8c5a29ed Mon Sep 17 00:00:00 2001 From: Jono Gray Date: Wed, 1 May 2019 15:30:45 +0100 Subject: [PATCH 09/29] Rejig CI order again --- .circleci/config.yml | 22 +++++++--------------- docker-compose.yml | 2 +- quick_start.sh | 2 +- 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b98930bc05..53bddf6822 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -689,8 +689,6 @@ workflows: name: build_flowmachine component: flowmachine component_path: flowmachine - requires: - - run_flowmachine_tests <<: *run_always_org_context - build_docs: name: build_docs @@ -702,30 +700,23 @@ workflows: name: build_flowauth component: flowauth component_path: flowauth - requires: - - run_flowauth_backend_tests - - run_flowauth_frontend_tests <<: *run_always_org_context - build_docker_image: name: build_flowapi component: flowapi component_path: flowapi - requires: - - run_flowkit_api_tests <<: *run_always_org_context - build_python_wheel: name: build_flowclient_wheel project_name: flowclient requires: - - run_flowclient_tests - - integration_tests + - install_flowmachine_deps <<: *run_always_org_context - build_python_wheel: name: build_flowmachine_wheel project_name: flowmachine requires: - - run_flowmachine_tests - - integration_tests + - install_flowmachine_deps <<: *run_always_org_context - test_quickstart: requires: @@ -733,6 +724,7 @@ workflows: - build_flowapi - build_flowmachine - build_flowauth + - build_examples <<: *run_always_org_context - integration_tests: requires: @@ -743,12 +735,14 @@ workflows: name: retag_master_branch requires: - test_quickstart + - integration_tests - build_docs <<: *master_only_org_context - retag_images: name: retag_tagged_build requires: - test_quickstart + - integration_tests - build_docs tag: CIRCLE_TAG <<: *tag_only_org_context @@ -756,19 +750,17 @@ workflows: name: push_flowclient_wheel project_name: flowclient requires: - - build_flowclient_wheel + - retag_tagged_build <<: *tag_only_org_context - push_wheel: name: push_flowmachine_wheel project_name: flowmachine requires: - - build_flowmachine_wheel + - retag_tagged_build <<: *tag_only_org_context - build_docs: name: Deploy docs deploy: true requires: - - build_docs - retag_tagged_build - - push_flowclient_wheel <<: *tag_only_org_context diff --git a/docker-compose.yml b/docker-compose.yml index 6951b06af9..36b65d60b8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -133,7 +133,7 @@ services: - db - redis command: - ["start-notebook.sh", "--NotebookApp.token = 'b2a960c88d617bde49e592da8b60d09b3527873cb5a50db2'"] + ["start.sh", "jupyter", "lab", "--LabApp.token=''"] flowapi: container_name: flowapi diff --git a/quick_start.sh b/quick_start.sh index 5d1e5575d3..a800a3d509 100755 --- a/quick_start.sh +++ b/quick_start.sh @@ -86,5 +86,5 @@ else echo "Access FlowAPI using FlowClient at http://localhost:$FLOWAPI_PORT" echo "View the FlowAPI spec at http://localhost:$FLOWAPI_PORT/api/0/spec/redoc" echo "Generate FlowAPI access tokens using FlowAuth with user TEST_USER and password DUMMY_PASSWORD at http://localhost:$FLOWAUTH_PORT" - echo "Try out the interactive examples at http://localhost:$FLOWAUTH_PORT/?token=b2a960c88d617bde49e592da8b60d09b3527873cb5a50db2" + echo "Try out the interactive examples at http://localhost:$FLOWAUTH_PORT" fi \ No newline at end of file From bc10d890fdb351a20af9cf0e2589bb5cf0dc795a Mon Sep 17 00:00:00 2001 From: Jono Gray Date: Wed, 1 May 2019 15:33:21 +0100 Subject: [PATCH 10/29] Connect tests back in --- .circleci/config.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 53bddf6822..1eeb1616e0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -737,6 +737,10 @@ workflows: - test_quickstart - integration_tests - build_docs + - run_flowkit_api_tests + - run_flowauth_backend_tests + - run_flowauth_frontend_tests + - run_flowclient_tests <<: *master_only_org_context - retag_images: name: retag_tagged_build @@ -744,6 +748,10 @@ workflows: - test_quickstart - integration_tests - build_docs + - run_flowkit_api_tests + - run_flowauth_backend_tests + - run_flowauth_frontend_tests + - run_flowclient_tests tag: CIRCLE_TAG <<: *tag_only_org_context - push_wheel: From 6cc93a0ff5e461fbb8748503bff36abce86d804a Mon Sep 17 00:00:00 2001 From: Jono Gray Date: Wed, 1 May 2019 15:49:35 +0100 Subject: [PATCH 11/29] Switch to a smaller baseimage --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 148e02c9d7..c9766e90ac 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -FROM jupyter/datascience-notebook +FROM jupyter/scipy-notebook RUN rm -rf /home/$NB_USER/work From 26593b780e3ec175b27a3f3a52e94f0f2eef5bb5 Mon Sep 17 00:00:00 2001 From: Jono Gray Date: Wed, 1 May 2019 15:58:35 +0100 Subject: [PATCH 12/29] Squash build steps a little more --- .circleci/config.yml | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1eeb1616e0..e85d7b79fb 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -128,18 +128,6 @@ executors: REDIS_PASSWORD: "fm_redis" jobs: - set_docker_tag_for_ci_images: - docker: *base_docker - steps: - - run: - name: Set a common docker tag - command: | - echo "export SAFE_TAG=${CIRCLE_TAG:-$(echo -n $CIRCLE_BRANCH | md5sum | cut -d" " -f1)}"| tee -a $BASH_ENV /home/circleci/.env - - persist_to_workspace: - root: /home/circleci/ - paths: - - .env - build_flowdb: machine: image: circleci/classic:201808-01 @@ -147,6 +135,10 @@ jobs: environment: *flowdb_env steps: - checkout + - run: + name: Set a common docker tag + command: | + echo "export SAFE_TAG=${CIRCLE_TAG:-$(echo -n $CIRCLE_BRANCH | md5sum | cut -d" " -f1)}"| tee -a $BASH_ENV /home/circleci/.env - attach_workspace: at: /home/circleci/ - restore_cache: @@ -643,11 +635,7 @@ jobs: workflows: run_build_pipeline: jobs: - - set_docker_tag_for_ci_images: - <<: *run_always_org_context - build_flowdb: - requires: - - set_docker_tag_for_ci_images <<: *run_always_org_context - install_flowmachine_deps: <<: *run_always_org_context From aa77aebbff6041b7212f82ea0eca3da4fd1bddf1 Mon Sep 17 00:00:00 2001 From: Jono Gray Date: Wed, 1 May 2019 16:58:40 +0100 Subject: [PATCH 13/29] Correct port --- quick_start.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quick_start.sh b/quick_start.sh index a800a3d509..630500612a 100755 --- a/quick_start.sh +++ b/quick_start.sh @@ -86,5 +86,5 @@ else echo "Access FlowAPI using FlowClient at http://localhost:$FLOWAPI_PORT" echo "View the FlowAPI spec at http://localhost:$FLOWAPI_PORT/api/0/spec/redoc" echo "Generate FlowAPI access tokens using FlowAuth with user TEST_USER and password DUMMY_PASSWORD at http://localhost:$FLOWAUTH_PORT" - echo "Try out the interactive examples at http://localhost:$FLOWAUTH_PORT" + echo "Try out the interactive examples at http://localhost:$WORKED_EXAMPLES_PORT" fi \ No newline at end of file From 5cd60a84acb9f11014838f027f3cc4a2db355337 Mon Sep 17 00:00:00 2001 From: Jono Gray Date: Thu, 2 May 2019 09:28:33 +0100 Subject: [PATCH 14/29] Make worked examples spin up synth data, make worked examples optional --- .circleci/config.yml | 12 ++++++++++++ quick_start.sh | 22 ++++++++++++++++++---- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e85d7b79fb..0b0882fe64 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -511,6 +511,18 @@ jobs: path: /home/circleci/project/ - run: ./quick_start.sh - run: ./quick_start.sh stop + - run: ./quick_start.sh examples + - run: ./quick_start.sh stop + - run: ./quick_start.sh synth + - run: ./quick_start.sh stop + - run: + name: Check all containers are down + command: + RUNNING=`docker-compose -q` + if [[ "$RUNNING" != "" ]] + then + exit 1 + fi build_docs: parameters: diff --git a/quick_start.sh b/quick_start.sh index 630500612a..2b76f47496 100755 --- a/quick_start.sh +++ b/quick_start.sh @@ -56,6 +56,14 @@ else export DOCKER_FLOWDB_HOST=flowdb_testdata fi +if [ $# -gt 0 ] && [ "$1" = "examples" ] +then + export WORKED_EXAMPLES=worked_examples + export DOCKER_FLOWDB_HOST=flowdb_synthetic_data +else + export WORKED_EXAMPLES= +fi + if [ $# -gt 0 ] && [ "$1" = "stop" ] then export DOCKER_FLOWDB_HOST=flowdb_testdata @@ -65,11 +73,11 @@ then else source /dev/stdin <<< "$(curl -s https://raw.githubusercontent.com/Flowminder/FlowKit/${BRANCH:-master}/development_environment)" echo "Starting containers" - RUNNING=`curl -s https://raw.githubusercontent.com/Flowminder/FlowKit/${BRANCH:-master}/docker-compose.yml | docker-compose -f - ps -q $DOCKER_FLOWDB_HOST flowapi flowmachine flowauth flowmachine_query_locker worked_examples` + RUNNING=`curl -s https://raw.githubusercontent.com/Flowminder/FlowKit/${BRANCH:-master}/docker-compose.yml | docker-compose -f - ps -q $DOCKER_FLOWDB_HOST flowapi flowmachine flowauth flowmachine_query_locker $WORKED_EXAMPLES` if [[ "$RUNNING" != "" ]]; then confirm "Existing containers are running and will be replaced. Are you sure?" || exit 1 fi - curl -s https://raw.githubusercontent.com/Flowminder/FlowKit/${BRANCH:-master}/docker-compose.yml | docker-compose -f - up -d $DOCKER_FLOWDB_HOST flowapi flowmachine flowauth flowmachine_query_locker worked_examples + curl -s https://raw.githubusercontent.com/Flowminder/FlowKit/${BRANCH:-master}/docker-compose.yml | docker-compose -f - up -d $DOCKER_FLOWDB_HOST flowapi flowmachine flowauth flowmachine_query_locker $WORKED_EXAMPLES echo "Waiting for containers to be ready.." docker exec ${DOCKER_FLOWDB_HOST} bash -c 'i=0; until [ $i -ge 24 ] || (pg_isready -h 127.0.0.1 -p 5432); do let i=i+1; echo Waiting 10s; sleep 10; done' || (>&2 echo "FlowDB failed to start :( Please open an issue at https://github.com/Flowminder/FlowKit/issues/new?template=bug_report.md&labels=FlowDB,bug including the output of running 'docker logs flowdb'" && exit 1) echo "FlowDB ready." @@ -79,12 +87,18 @@ else echo "FlowAPI ready." i=0; until [ $i -ge 24 ] || (curl -s http://localhost:$FLOWAUTH_PORT > /dev/null) ; do let i=i+1; echo Waiting 10s; sleep 10; done || (>&2 echo "FlowAuth failed to start :( Please open an issue at https://github.com/Flowminder/FlowKit/issues/new?template=bug_report.md&labels=FlowAuth,bug including the output of running 'docker logs flowauth'" && exit 1) echo "FlowAuth ready." - i=0; until [ $i -ge 24 ] || (curl -s http://localhost:$WORKED_EXAMPLES_PORT > /dev/null) ; do let i=i+1; echo Waiting 10s; sleep 10; done || (>&2 echo "Worked examples failed to start :( Please open an issue at https://github.com/Flowminder/FlowKit/issues/new?template=bug_report.md&labels=docs,bug including the output of running 'docker logs worked_examples'" && exit 1) + if [[ "$WORKED_EXAMPLES" = "worked_examples" ]] + then + i=0; until [ $i -ge 24 ] || (curl -s http://localhost:$WORKED_EXAMPLES_PORT > /dev/null) ; do let i=i+1; echo Waiting 10s; sleep 10; done || (>&2 echo "Worked examples failed to start :( Please open an issue at https://github.com/Flowminder/FlowKit/issues/new?template=bug_report.md&labels=docs,bug including the output of running 'docker logs worked_examples'" && exit 1) + fi echo "Worked examples ready." echo "All containers ready!" echo "Access FlowDB using 'PGHOST=$FLOWDB_HOST PGPORT=$FLOWDB_PORT PGDATABASE=flowdb PGUSER=$FLOWMACHINE_FLOWDB_USER PGPASSWORD=$FLOWMACHINE_FLOWDB_PASSWORD psql'" echo "Access FlowAPI using FlowClient at http://localhost:$FLOWAPI_PORT" echo "View the FlowAPI spec at http://localhost:$FLOWAPI_PORT/api/0/spec/redoc" echo "Generate FlowAPI access tokens using FlowAuth with user TEST_USER and password DUMMY_PASSWORD at http://localhost:$FLOWAUTH_PORT" - echo "Try out the interactive examples at http://localhost:$WORKED_EXAMPLES_PORT" + if [[ "$WORKED_EXAMPLES" = "worked_examples" ]] + then + echo "Try out the interactive examples at http://localhost:$WORKED_EXAMPLES_PORT" + fi fi \ No newline at end of file From d636015276a02cb122f0e1f77d72e07333e0d070 Mon Sep 17 00:00:00 2001 From: Jono Gray Date: Thu, 2 May 2019 09:53:47 +0100 Subject: [PATCH 15/29] Make examples use regular data size by default, but allow combining with larger data, rename synth flag larger_data --- .circleci/config.yml | 4 ++-- docs/source/install.md | 19 ++++++++++++++++++- quick_start.sh | 5 ++--- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 0b0882fe64..e4a59a00ae 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -513,8 +513,8 @@ jobs: - run: ./quick_start.sh stop - run: ./quick_start.sh examples - run: ./quick_start.sh stop - - run: ./quick_start.sh synth - - run: ./quick_start.sh stop + #- run: ./quick_start.sh synth # Synth data spinup with this data volume is very slow so not testing it right now on CI + #- run: ./quick_start.sh stop - run: name: Check all containers are down command: diff --git a/docs/source/install.md b/docs/source/install.md index 2146cd8dd0..914c8b9970 100644 --- a/docs/source/install.md +++ b/docs/source/install.md @@ -34,9 +34,26 @@ This will pull any necessary docker containers, and start the system in the back The default system includes a small amount of test data. For a test system with considerably more data you can run ```bash -bash <(curl -s https://raw.githubusercontent.com/Flowminder/FlowKit/master/quick_start.sh) synth +bash <(curl -s https://raw.githubusercontent.com/Flowminder/FlowKit/master/quick_start.sh) larger_data ``` +!!! warning + The larger data container will take considerably longer to start up, as it generates data when first run. + +The [worked examples](worked_examples) are also available as part of the demo system. To install these run + +```bash +bash <(curl -s https://raw.githubusercontent.com/Flowminder/FlowKit/master/quick_start.sh) examples +``` + +for the examples with a small dataset, or + +```bash +bash <(curl -s https://raw.githubusercontent.com/Flowminder/FlowKit/master/quick_start.sh) examples larger_data +``` + +to get the examples with the larger dataset (the one used when producing this documentation). + In order to use the test system, now install FlowClient, and generate a token using FlowAuth. #### FlowAuth Quickstart diff --git a/quick_start.sh b/quick_start.sh index 2b76f47496..3bb08e60ca 100755 --- a/quick_start.sh +++ b/quick_start.sh @@ -49,17 +49,16 @@ if [ "$CI" = "true" ]; then export BRANCH=$CIRCLE_SHA1 fi -if [ $# -gt 0 ] && [ "$1" = "synth" ] +if [ $# -gt 0 ] && [ "$1" = "larger_data" ] || [ "$2" = "larger_data" ] then export DOCKER_FLOWDB_HOST=flowdb_synthetic_data else export DOCKER_FLOWDB_HOST=flowdb_testdata fi -if [ $# -gt 0 ] && [ "$1" = "examples" ] +if [ $# -gt 0 ] && [ "$1" = "examples" ] || [ "$2" = "examples" ] then export WORKED_EXAMPLES=worked_examples - export DOCKER_FLOWDB_HOST=flowdb_synthetic_data else export WORKED_EXAMPLES= fi From 5daac7f9e7ab9d1ea81db7c87f30b717600dbf99 Mon Sep 17 00:00:00 2001 From: Jono Gray Date: Thu, 2 May 2019 10:05:12 +0100 Subject: [PATCH 16/29] Update changelog, tweak docs to point out worked examples available in quickstart, fix all down check on CI --- .circleci/config.yml | 2 +- CHANGELOG.md | 1 + docs/source/install.md | 5 +---- docs/source/worked_examples/index.md | 2 ++ 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e4a59a00ae..c9af77edec 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -518,7 +518,7 @@ jobs: - run: name: Check all containers are down command: - RUNNING=`docker-compose -q` + RUNNING=`docker ps -q` if [[ "$RUNNING" != "" ]] then exit 1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 969ee4fc13..4c0cd31180 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Error is displayed in the add user form of Flowauth if username is alredy exists. [#690](https://github.com/Flowminder/FlowKit/issues/690) ### Added +- FlowKit's worked examples are now available as part of the quick setup script ### Changed diff --git a/docs/source/install.md b/docs/source/install.md index 914c8b9970..38ed01b8c6 100644 --- a/docs/source/install.md +++ b/docs/source/install.md @@ -18,10 +18,7 @@ The bulk of the installation process consists of downloading [Docker](https://do These instructions assume use of [Pyenv](https://github.com/pyenv/pyenv) and [Pipenv](https://github.com/pypa/pipenv). [Anaconda](https://www.anaconda.com/what-is-anaconda/) stack based installation commands may be different. - -### Server and Authentication Installation - -Docker containers for FlowAPI, FlowMachine and FlowDB are provided in the [DockerCloud](https://cloud.docker.com/) repositories `flowminder/flowapi`, `flowminder/flowmachine` and `flowminder/flowdb`, respectively. You will need [Docker](https://docs.docker.com/install/) and [Docker Compose](https://docs.docker.com/compose/install/). +Docker containers for [FlowAPI](http://https://hub.docker.com/r/flowminder/flowapi), [FlowMachine](http://https://hub.docker.com/r/flowminder/flowmachine), [FlowDB](http://https://hub.docker.com/r/flowminder/flowdb), [FlowAuth](http://https://hub.docker.com/r/flowminder/flowauth) and the [worked examples](http://https://hub.docker.com/r/flowminder/flowkit-examples) are provided in the [DockerCloud](https://hub.docker.com/) repositories `flowminder/flowapi`, `flowminder/flowmachine`, `flowminder/flowdb`, `flowminder/flowauth`, and `flowminder/flowkit-examples` respectively. You will need [Docker](https://docs.docker.com/install/) and [Docker Compose](https://docs.docker.com/compose/install/). Start the FlowKit test system by running diff --git a/docs/source/worked_examples/index.md b/docs/source/worked_examples/index.md index 5e897a4c57..7c84ccd13b 100644 --- a/docs/source/worked_examples/index.md +++ b/docs/source/worked_examples/index.md @@ -9,3 +9,5 @@ We have three worked examples of using FlowKit for CDR analysis: - [Mobile Data Usage](./mobile-data-usage/) (using FlowMachine). The Jupyter notebooks for these worked examples can be found [here](https://github.com/Flowminder/FlowKit/tree/master/docs/source/worked_examples/). + +Alternatively you can run the worked examples using the [quick start setup](../install.md#quickinstall) which includes JupyterLab. From 5d3ea8a6fb7068bf98b2caaad0abf920114dadea Mon Sep 17 00:00:00 2001 From: Jono Gray Date: Thu, 2 May 2019 10:09:00 +0100 Subject: [PATCH 17/29] Dockerfile docstring, add worked examples to makefile services --- Dockerfile | 5 +++++ Makefile | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index c9766e90ac..8190cbe55c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,11 @@ # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# Worked examples docker container +# Provides all worked examples from the FlowKit docs in a ready-to-go JupyterLab install +# + FROM jupyter/scipy-notebook RUN rm -rf /home/$NB_USER/work diff --git a/Makefile b/Makefile index c1550952ab..548d36d17e 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ DOCKER_COMPOSE_FILE ?= docker-compose.yml DOCKER_COMPOSE_FILE_BUILD ?= docker-compose-build.yml FLOWDB_SERVICES ?= flowdb_testdata -DOCKER_SERVICES ?= $(FLOWDB_SERVICES) flowapi flowmachine flowauth flowmachine_query_locker +DOCKER_SERVICES ?= $(FLOWDB_SERVICES) flowapi flowmachine flowauth flowmachine_query_locker worked_examples export DOCKER_FLOWDB_HOST=$(word 1, $(FLOWDB_SERVICES)) From 2be944bfafdf2484d147a397d0ef00e6398f9ffd Mon Sep 17 00:00:00 2001 From: Jono Gray Date: Thu, 2 May 2019 10:10:39 +0100 Subject: [PATCH 18/29] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c0cd31180..4af527f76d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Error is displayed in the add user form of Flowauth if username is alredy exists. [#690](https://github.com/Flowminder/FlowKit/issues/690) ### Added -- FlowKit's worked examples are now available as part of the quick setup script +- FlowKit's worked examples are now Dockerized, and available as part of the quick setup script [#614](https://github.com/Flowminder/FlowKit/issues/614) ### Changed From 689a59e2138b56cb8274bc39925eac317a527d9a Mon Sep 17 00:00:00 2001 From: Jono Gray Date: Thu, 2 May 2019 10:40:32 +0100 Subject: [PATCH 19/29] Fix syntax --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c9af77edec..2bb3fdc961 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -517,7 +517,7 @@ jobs: #- run: ./quick_start.sh stop - run: name: Check all containers are down - command: + command: | RUNNING=`docker ps -q` if [[ "$RUNNING" != "" ]] then From a04f7b7b3d506c4b12989487962cf7d57f104da9 Mon Sep 17 00:00:00 2001 From: Jono Gray Date: Thu, 2 May 2019 13:53:48 +0100 Subject: [PATCH 20/29] Add docker version check to quick start script --- docker-compose-build.yml | 2 +- docker-compose.yml | 2 +- quick_start.sh | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/docker-compose-build.yml b/docker-compose-build.yml index b5d2654d56..cf764f9646 100644 --- a/docker-compose-build.yml +++ b/docker-compose-build.yml @@ -5,7 +5,7 @@ # DOCKER COMPOSE BUILDER FOR FLOWKIT # -version: '3.7' +version: '3.5' services: diff --git a/docker-compose.yml b/docker-compose.yml index 36b65d60b8..f95beb24f2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,7 +5,7 @@ # DOCKER COMPOSE FOR FLOWKIT # -version: '3.7' +version: '3.5' networks: db: diff --git a/quick_start.sh b/quick_start.sh index 3bb08e60ca..8381441691 100755 --- a/quick_start.sh +++ b/quick_start.sh @@ -5,6 +5,8 @@ set -e set -a + + # Read a single char from /dev/tty, prompting with "$*" # Note: pressing enter will return a null string. Perhaps a version terminated with X and then remove it in caller? # See https://unix.stackexchange.com/a/367880/143394 for dealing with multi-byte, etc. @@ -63,6 +65,22 @@ else export WORKED_EXAMPLES= fi +DOCKER_ENGINE_VERSION=`docker version --format '{{.Server.Version}}'` +DOCKER_COMPOSE_VERSION=`docker-compose version --short` +if [[ "$DOCKER_ENGINE_VERSION" < "17.12.0" ]] +then + echo "Docker version not supported. Please upgrade docker to at least v17.12.0" + exit 1 +fi + +if [[ "$DOCKER_COMPOSE_VERSION" < "1.21.0" ]] +then + echo "docker-compose version not supported. Please upgrade docker to at least v1.21.0 (e.g. by running 'pip install --upgrade docker-compose'" + echo "or installing a newer version of Docker desktop." + exit 1 +fi + + if [ $# -gt 0 ] && [ "$1" = "stop" ] then export DOCKER_FLOWDB_HOST=flowdb_testdata From 9f2ccda3d7e688cd86393d1e3cd6a62b6a3e5b40 Mon Sep 17 00:00:00 2001 From: Jono Gray Date: Tue, 7 May 2019 09:26:14 +0100 Subject: [PATCH 21/29] Make large data default for examples --- .circleci/config.yml | 4 ++-- docs/source/install.md | 10 ++++++++-- quick_start.sh | 6 ++++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2bb3fdc961..9dd1f1886d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -511,9 +511,9 @@ jobs: path: /home/circleci/project/ - run: ./quick_start.sh - run: ./quick_start.sh stop - - run: ./quick_start.sh examples + - run: ./quick_start.sh examples smaller_data - run: ./quick_start.sh stop - #- run: ./quick_start.sh synth # Synth data spinup with this data volume is very slow so not testing it right now on CI + #- run: ./quick_start.sh larger_data # Synth data spinup with this data volume is very slow so not testing it right now on CI #- run: ./quick_start.sh stop - run: name: Check all containers are down diff --git a/docs/source/install.md b/docs/source/install.md index 38ed01b8c6..59372e903f 100644 --- a/docs/source/install.md +++ b/docs/source/install.md @@ -40,17 +40,23 @@ bash <(curl -s https://raw.githubusercontent.com/Flowminder/FlowKit/master/quick The [worked examples](worked_examples) are also available as part of the demo system. To install these run ```bash -bash <(curl -s https://raw.githubusercontent.com/Flowminder/FlowKit/master/quick_start.sh) examples +bash <(curl -s https://raw.githubusercontent.com/Flowminder/FlowKit/master/quick_start.sh) examples smaller_data ``` for the examples with a small dataset, or ```bash -bash <(curl -s https://raw.githubusercontent.com/Flowminder/FlowKit/master/quick_start.sh) examples larger_data +bash <(curl -s https://raw.githubusercontent.com/Flowminder/FlowKit/master/quick_start.sh) examples ``` to get the examples with the larger dataset (the one used when producing this documentation). +To shut down the system, you can either stop all the docker containers directly, or run + +```bash +bash <(curl -s https://raw.githubusercontent.com/Flowminder/FlowKit/master/quick_start.sh) stop +``` + In order to use the test system, now install FlowClient, and generate a token using FlowAuth. #### FlowAuth Quickstart diff --git a/quick_start.sh b/quick_start.sh index 8381441691..ab1316cbbf 100755 --- a/quick_start.sh +++ b/quick_start.sh @@ -61,6 +61,12 @@ fi if [ $# -gt 0 ] && [ "$1" = "examples" ] || [ "$2" = "examples" ] then export WORKED_EXAMPLES=worked_examples + if [ $# -gt 0 ] && [ "$1" = "smaller_data" ] || [ "$2" = "smaller_data" ] + then + export DOCKER_FLOWDB_HOST=flowdb_testdata + else + export DOCKER_FLOWDB_HOST=flowdb_testdata + fi else export WORKED_EXAMPLES= fi From 0facddba20ca7a65b360695de914cfbad4131040 Mon Sep 17 00:00:00 2001 From: Jono Gray Date: Tue, 7 May 2019 09:38:19 +0100 Subject: [PATCH 22/29] Use env var for flowapi url --- docker-compose.yml | 2 ++ docs/source/worked_examples/Flows.ipynb | 4 ++-- docs/source/worked_examples/commuting-patterns.ipynb | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index f95beb24f2..e0cd6812de 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -128,6 +128,7 @@ services: - REDIS_HOST=query_locker - REDIS_PORT=6379 - REDIS_PASSWORD=${REDIS_PASSWORD:?Must set REDIS_PASSWORD env var} + - restart: always networks: - db @@ -149,6 +150,7 @@ services: - FLOWDB_PORT=5432 - JWT_SECRET_KEY=${JWT_SECRET_KEY:?Must set JWT_SECRET_KEY env var} - FLOWAPI_LOG_LEVEL=${FLOWAPI_LOG_LEVEL:?Must set FLOWAPI_LOG_LEVEL env var} + - FLOWAPI_URL="http://flowapi:9090" tty: true stdin_open: true restart: always diff --git a/docs/source/worked_examples/Flows.ipynb b/docs/source/worked_examples/Flows.ipynb index 630dcfa944..b3af776cbf 100644 --- a/docs/source/worked_examples/Flows.ipynb +++ b/docs/source/worked_examples/Flows.ipynb @@ -21,7 +21,7 @@ "metadata": {}, "outputs": [], "source": [ - "import flowclient, folium" + "import flowclient, folium, os" ] }, { @@ -37,7 +37,7 @@ "metadata": {}, "outputs": [], "source": [ - "conn = flowclient.connect(\"http://localhost:9090\", TOKEN)" + "conn = flowclient.connect(os.getenv(\"FLOWAPI_URL\", \"http://localhost:9090\"), TOKEN)" ] }, { diff --git a/docs/source/worked_examples/commuting-patterns.ipynb b/docs/source/worked_examples/commuting-patterns.ipynb index aabfda212c..ee4d9be547 100644 --- a/docs/source/worked_examples/commuting-patterns.ipynb +++ b/docs/source/worked_examples/commuting-patterns.ipynb @@ -19,7 +19,7 @@ "metadata": {}, "outputs": [], "source": [ - "import flowclient, folium" + "import flowclient, folium, os" ] }, { @@ -35,7 +35,7 @@ "metadata": {}, "outputs": [], "source": [ - "conn = flowclient.connect(\"http://localhost:9090\", TOKEN)" + "conn = flowclient.connect(os.getenv(\"FLOWAPI_URL\", \"http://localhost:9090\"), TOKEN)" ] }, { From c488df7f6eb7a39cea056c317833ee847aebe963 Mon Sep 17 00:00:00 2001 From: Jono Gray Date: Tue, 7 May 2019 09:38:57 +0100 Subject: [PATCH 23/29] Consistent makefile targets --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 548d36d17e..ee2252e4f5 100644 --- a/Makefile +++ b/Makefile @@ -108,13 +108,13 @@ flowauth-build: docker-compose -f $(DOCKER_COMPOSE_FILE) -f $(DOCKER_COMPOSE_FILE_BUILD) build flowauth -worked-examples-up: worked-examples-build +worked_examples-up: worked_examples-build docker-compose -f $(DOCKER_COMPOSE_FILE) -f $(DOCKER_COMPOSE_FILE_BUILD) up -d --build worked_examples -worked-examples-down: +worked_examples-down: docker-compose -f $(DOCKER_COMPOSE_FILE) rm -f -s -v worked_examples -worked-examples-build: +worked_examples-build: docker-compose -f $(DOCKER_COMPOSE_FILE) -f $(DOCKER_COMPOSE_FILE_BUILD) build worked_examples From c82a8422d851da4df8cbe6a88f2bd3afee73df8b Mon Sep 17 00:00:00 2001 From: Jono Gray Date: Tue, 7 May 2019 09:40:56 +0100 Subject: [PATCH 24/29] Laxer test token --- flowauth/backend/flowauth/models.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/flowauth/backend/flowauth/models.py b/flowauth/backend/flowauth/models.py index 12acf3a210..4ddbf7f8f3 100644 --- a/flowauth/backend/flowauth/models.py +++ b/flowauth/backend/flowauth/models.py @@ -556,12 +556,9 @@ def make_demodata(): # pragma: no cover gsp = GroupServerPermission( group=groups[0], server_capability=sc, get_result=True, run=True, poll=True ) - gsp.spatial_aggregation.append( - agg_units[0] - ) # Give Bob access to admin0 agg units - gsp.spatial_aggregation.append( - agg_units[1] - ) # Give Bob access to admin1 agg units + for agg_units in agg_units[:4]: # Give Bob access to adminX agg units + gsp.spatial_aggregation.append(agg_units[0]) + db.session.add(gsp) db.session.add( GroupServerTokenLimits( From 8b48858623c00b8521de40cec6f126a03a875a0b Mon Sep 17 00:00:00 2001 From: Jono Gray Date: Tue, 7 May 2019 09:55:13 +0100 Subject: [PATCH 25/29] Syntax --- docs/source/install.md | 2 +- flowauth/backend/flowauth/models.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/source/install.md b/docs/source/install.md index 59372e903f..6bb23bffe4 100644 --- a/docs/source/install.md +++ b/docs/source/install.md @@ -1,6 +1,6 @@ Title: Installation -#How to Install FlowKit +# How to Install FlowKit There are three main ways to install FlowKit. diff --git a/flowauth/backend/flowauth/models.py b/flowauth/backend/flowauth/models.py index 4ddbf7f8f3..c85720e3ec 100644 --- a/flowauth/backend/flowauth/models.py +++ b/flowauth/backend/flowauth/models.py @@ -556,8 +556,8 @@ def make_demodata(): # pragma: no cover gsp = GroupServerPermission( group=groups[0], server_capability=sc, get_result=True, run=True, poll=True ) - for agg_units in agg_units[:4]: # Give Bob access to adminX agg units - gsp.spatial_aggregation.append(agg_units[0]) + for agg_unit in agg_units[:4]: # Give Bob access to adminX agg units + gsp.spatial_aggregation.append(agg_unit) db.session.add(gsp) db.session.add( From 1fb1129922f7bae0eda8d41ff79a00c9952a13d5 Mon Sep 17 00:00:00 2001 From: Jono Gray Date: Tue, 7 May 2019 10:20:28 +0100 Subject: [PATCH 26/29] Put env var in right service --- docker-compose.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index e0cd6812de..3fb1e2b808 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -128,7 +128,7 @@ services: - REDIS_HOST=query_locker - REDIS_PORT=6379 - REDIS_PASSWORD=${REDIS_PASSWORD:?Must set REDIS_PASSWORD env var} - - + - FLOWAPI_URL="http://flowapi:9090" restart: always networks: - db @@ -150,7 +150,6 @@ services: - FLOWDB_PORT=5432 - JWT_SECRET_KEY=${JWT_SECRET_KEY:?Must set JWT_SECRET_KEY env var} - FLOWAPI_LOG_LEVEL=${FLOWAPI_LOG_LEVEL:?Must set FLOWAPI_LOG_LEVEL env var} - - FLOWAPI_URL="http://flowapi:9090" tty: true stdin_open: true restart: always From 21fc0dbb7f3d79391bf736e30e38ea5c80710a25 Mon Sep 17 00:00:00 2001 From: Jono Gray Date: Tue, 7 May 2019 11:13:42 +0100 Subject: [PATCH 27/29] Pull before starting --- quick_start.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/quick_start.sh b/quick_start.sh index ab1316cbbf..5350177b0d 100755 --- a/quick_start.sh +++ b/quick_start.sh @@ -100,6 +100,7 @@ else if [[ "$RUNNING" != "" ]]; then confirm "Existing containers are running and will be replaced. Are you sure?" || exit 1 fi + curl -s https://raw.githubusercontent.com/Flowminder/FlowKit/${BRANCH:-master}/docker-compose.yml | docker-compose -f - pull curl -s https://raw.githubusercontent.com/Flowminder/FlowKit/${BRANCH:-master}/docker-compose.yml | docker-compose -f - up -d $DOCKER_FLOWDB_HOST flowapi flowmachine flowauth flowmachine_query_locker $WORKED_EXAMPLES echo "Waiting for containers to be ready.." docker exec ${DOCKER_FLOWDB_HOST} bash -c 'i=0; until [ $i -ge 24 ] || (pg_isready -h 127.0.0.1 -p 5432); do let i=i+1; echo Waiting 10s; sleep 10; done' || (>&2 echo "FlowDB failed to start :( Please open an issue at https://github.com/Flowminder/FlowKit/issues/new?template=bug_report.md&labels=FlowDB,bug including the output of running 'docker logs flowdb'" && exit 1) From 8e8f06f35655895f9109db431862d0fd3a0e7186 Mon Sep 17 00:00:00 2001 From: maxalbert Date: Wed, 8 May 2019 10:51:34 +0100 Subject: [PATCH 28/29] Update docker-compose.yml Co-Authored-By: greenape --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 3fb1e2b808..837d54a7fc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -128,7 +128,7 @@ services: - REDIS_HOST=query_locker - REDIS_PORT=6379 - REDIS_PASSWORD=${REDIS_PASSWORD:?Must set REDIS_PASSWORD env var} - - FLOWAPI_URL="http://flowapi:9090" + - FLOWAPI_URL=http://flowapi:9090 restart: always networks: - db From 7033cf4dd8ca8c999ea09edbf8a4b2507b1cf2a9 Mon Sep 17 00:00:00 2001 From: maxalbert Date: Wed, 8 May 2019 11:11:01 +0100 Subject: [PATCH 29/29] Update quick_start.sh Co-Authored-By: greenape --- quick_start.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/quick_start.sh b/quick_start.sh index 5350177b0d..4c275a854f 100755 --- a/quick_start.sh +++ b/quick_start.sh @@ -95,7 +95,7 @@ then curl -s https://raw.githubusercontent.com/Flowminder/FlowKit/${BRANCH:-master}/docker-compose.yml | docker-compose -f - down else source /dev/stdin <<< "$(curl -s https://raw.githubusercontent.com/Flowminder/FlowKit/${BRANCH:-master}/development_environment)" - echo "Starting containers" + echo "Starting containers (this may take a few minutes)" RUNNING=`curl -s https://raw.githubusercontent.com/Flowminder/FlowKit/${BRANCH:-master}/docker-compose.yml | docker-compose -f - ps -q $DOCKER_FLOWDB_HOST flowapi flowmachine flowauth flowmachine_query_locker $WORKED_EXAMPLES` if [[ "$RUNNING" != "" ]]; then confirm "Existing containers are running and will be replaced. Are you sure?" || exit 1 @@ -125,4 +125,4 @@ else then echo "Try out the interactive examples at http://localhost:$WORKED_EXAMPLES_PORT" fi -fi \ No newline at end of file +fi