From 275aa0ae90ba4b055478dd70462a7e9dd864461e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=BA=C3=B1ez?= Date: Thu, 7 Feb 2019 00:15:12 +0100 Subject: [PATCH 1/9] Trying to speed up CI: removed some task dependencies, increased parallelism --- .circleci/config.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1ce25e34f..a7bb93e56 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -86,15 +86,15 @@ workflows: only: /.*/ requires: - blockchain - - contracts + # - contracts (Removed dependency to speed up overall workflow execution) - actors: context: "NuCypher Tests" filters: tags: only: /.*/ requires: - - blockchain - - contracts + # - blockchain (Removed dependency to speed up overall workflow execution) + # - contracts (Removed dependency to speed up overall workflow execution) - deployers: context: "NuCypher Tests" filters: @@ -102,7 +102,7 @@ workflows: only: /.*/ requires: - blockchain - - contracts + # - contracts (Removed dependency to speed up overall workflow execution) - config: context: "NuCypher Tests" filters: @@ -339,7 +339,7 @@ jobs: agents: <<: *python_36_base - parallelism: 2 + parallelism: 4 steps: - prepare_environment - run: @@ -445,7 +445,7 @@ jobs: cli: <<: *python_36_base - parallelism: 4 + parallelism: 6 steps: - prepare_environment - run: From 7191132759d565b9825fac64206f3a2152b55fa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=BA=C3=B1ez?= Date: Thu, 7 Feb 2019 00:40:42 +0100 Subject: [PATCH 2/9] Use previously built workspace for building the docs --- .circleci/config.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a7bb93e56..5ecfdbcee 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -500,7 +500,8 @@ jobs: <<: *python_36_base steps: - checkout - - pip_install + - attach_workspace: + at: ~/.local/share/virtualenvs/ - run: name: Install Documentation Build Dependencies command: pip3 install --user sphinx recommonmark sphinx-rtd-theme From eb88b37f75ce219150cf5863fbd2106d36400074 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=BA=C3=B1ez?= Date: Thu, 7 Feb 2019 00:46:25 +0100 Subject: [PATCH 3/9] Prioritizing the actors task in CircleCI since it's slow af --- .circleci/config.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5ecfdbcee..83a82bfd7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -92,9 +92,13 @@ workflows: filters: tags: only: /.*/ - requires: - # - blockchain (Removed dependency to speed up overall workflow execution) - # - contracts (Removed dependency to speed up overall workflow execution) + requires: # (Prioritizing this task given that it's awfully slow) + - pip_install_36 + - pipenv_install_36 + - pip_install_37 + - pipenv_install_37 + # - blockchain + # - contracts - deployers: context: "NuCypher Tests" filters: From ea7cbfba4968f313cfc8c5e6db690c01d78a4f94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=BA=C3=B1ez?= Date: Thu, 7 Feb 2019 10:16:14 +0100 Subject: [PATCH 4/9] Naive approach for a CircleCI workflow to test the heartbeat demo --- .circleci/config.yml | 24 ++++++++++++++++++++++++ examples/heartbeat_demo/alicia.py | 3 ++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 83a82bfd7..bece3d5bc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -20,6 +20,16 @@ workflows: filters: tags: only: /.*/ + - heartbeat_demo: + context: "NuCypher Tests" + filters: + tags: + only: /.*/ + requires: + - pip_install_36 + - pipenv_install_36 + - pip_install_37 + - pipenv_install_37 - contracts: context: "NuCypher Tests" filters: @@ -447,6 +457,20 @@ jobs: command: pipenv run pytest tests/learning - capture_test_results + heartbeat_demo: + <<: *python_36_base + steps: + - prepare_environment + - run: + name: Run demo Ursula fleet, Alicia and the Doctor + command: | + pipenv run python examples/run_lonely_demo_ursula.py > /dev/null 2>&1 & + sleep 25 + pipenv run python examples/run_demo_ursula_fleet.py > /dev/null 2>&1 & + sleep 60 + pipenv run python examples/heartbeat_demo/alicia.py + pipenv run python examples/heartbeat_demo/doctor.py + cli: <<: *python_36_base parallelism: 6 diff --git a/examples/heartbeat_demo/alicia.py b/examples/heartbeat_demo/alicia.py index f4e9369fb..4160ce29c 100644 --- a/examples/heartbeat_demo/alicia.py +++ b/examples/heartbeat_demo/alicia.py @@ -99,6 +99,7 @@ print("The policy public key for " import heart_monitor heart_monitor.generate_heart_rate_samples(policy_pubkey, label=label, + samples=50, save_as_file=True) @@ -122,7 +123,7 @@ doctor_strange = Bob.from_public_keys(powers_and_material=powers_and_material, policy_end_datetime = maya.now() + datetime.timedelta(days=5) # - m-out-of-n: This means Alicia splits the re-encryption key in 5 pieces and # she requires Bob to seek collaboration of at least 3 Ursulas -m, n = 3, 5 +m, n = 2, 3 # With this information, Alicia creates a policy granting access to Bob. From ff33ef155a12a95f25c0dbdd263cf8db38008cbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=BA=C3=B1ez?= Date: Thu, 7 Feb 2019 11:14:54 +0100 Subject: [PATCH 5/9] Store fleet logs as artifacts to debug the heartbeat demo CI task --- .circleci/config.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index bece3d5bc..e12bd6d9b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -464,12 +464,15 @@ jobs: - run: name: Run demo Ursula fleet, Alicia and the Doctor command: | - pipenv run python examples/run_lonely_demo_ursula.py > /dev/null 2>&1 & + mkdir /tmp/ursulas-logs + pipenv run python examples/run_lonely_demo_ursula.py > /tmp/ursulas-logs/lonely.log.txt 2>&1 & sleep 25 - pipenv run python examples/run_demo_ursula_fleet.py > /dev/null 2>&1 & + pipenv run python examples/run_demo_ursula_fleet.py > /tmp/ursulas-logs/fleet.log.txt 2>&1 & sleep 60 pipenv run python examples/heartbeat_demo/alicia.py pipenv run python examples/heartbeat_demo/doctor.py + - store_artifacts: + path: /tmp/ursulas-logs cli: <<: *python_36_base From 9a5d6011c12e5537ec525974e4eeb4873c605319 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=BA=C3=B1ez?= Date: Thu, 7 Feb 2019 11:33:44 +0100 Subject: [PATCH 6/9] Use pip environment instead of pipenv for heartbeat demo CI task --- .circleci/config.yml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e12bd6d9b..763c56587 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -25,11 +25,6 @@ workflows: filters: tags: only: /.*/ - requires: - - pip_install_36 - - pipenv_install_36 - - pip_install_37 - - pipenv_install_37 - contracts: context: "NuCypher Tests" filters: @@ -460,17 +455,20 @@ jobs: heartbeat_demo: <<: *python_36_base steps: - - prepare_environment + - checkout + - pip_install - run: name: Run demo Ursula fleet, Alicia and the Doctor command: | mkdir /tmp/ursulas-logs - pipenv run python examples/run_lonely_demo_ursula.py > /tmp/ursulas-logs/lonely.log.txt 2>&1 & + export PATH=~/.local/bin:$PATH + source ~/.bashrc + python3 examples/run_lonely_demo_ursula.py > /tmp/ursulas-logs/lonely.log.txt 2>&1 & sleep 25 - pipenv run python examples/run_demo_ursula_fleet.py > /tmp/ursulas-logs/fleet.log.txt 2>&1 & + python3 examples/run_demo_ursula_fleet.py > /tmp/ursulas-logs/fleet.log.txt 2>&1 & sleep 60 - pipenv run python examples/heartbeat_demo/alicia.py - pipenv run python examples/heartbeat_demo/doctor.py + python3 examples/heartbeat_demo/alicia.py + python3 examples/heartbeat_demo/doctor.py - store_artifacts: path: /tmp/ursulas-logs From a4f72a95a8605edfef4b63f6d3d599a405883eaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=BA=C3=B1ez?= Date: Thu, 7 Feb 2019 11:53:45 +0100 Subject: [PATCH 7/9] Use dev Ursulas directly instead the demo fleet script. --- .circleci/config.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 763c56587..03f5cc90e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -463,10 +463,14 @@ jobs: mkdir /tmp/ursulas-logs export PATH=~/.local/bin:$PATH source ~/.bashrc - python3 examples/run_lonely_demo_ursula.py > /tmp/ursulas-logs/lonely.log.txt 2>&1 & - sleep 25 - python3 examples/run_demo_ursula_fleet.py > /tmp/ursulas-logs/fleet.log.txt 2>&1 & - sleep 60 + export NUCYPHER_SENTRY_LOGS=0 + export NUCYPHER_FILE_LOGS=0 + python3 examples/run_lonely_demo_ursula.py > /tmp/ursulas-logs/ursula-11500.txt 2>&1 & + sleep 15 + nucypher ursula run --dev --debug --federated-only --teacher-uri localhost:11500 --rest-port 11501 > /tmp/ursulas-logs/ursula-11501.txt 2>&1 & + sleep 15 + nucypher ursula run --dev --debug --federated-only --teacher-uri localhost:11500 --rest-port 11502 > /tmp/ursulas-logs/ursula-11502.txt 2>&1 & + sleep 15 python3 examples/heartbeat_demo/alicia.py python3 examples/heartbeat_demo/doctor.py - store_artifacts: From e666cfc067083dbff1a91d6c69d6321364c93859 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=BA=C3=B1ez?= Date: Thu, 7 Feb 2019 12:08:41 +0100 Subject: [PATCH 8/9] A reasonable place for the heartbeat task in the CI worklfow --- .circleci/config.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 03f5cc90e..a7d175c93 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -20,11 +20,6 @@ workflows: filters: tags: only: /.*/ - - heartbeat_demo: - context: "NuCypher Tests" - filters: - tags: - only: /.*/ - contracts: context: "NuCypher Tests" filters: @@ -144,6 +139,14 @@ workflows: - deployers - config - character + - heartbeat_demo: + context: "NuCypher Tests" + filters: + tags: + only: /.*/ + requires: + - cli + - ursula_command - mypy: context: "NuCypher Tests" filters: From 428d80e73a28f4b631549e0a66dc285df5c7ab67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=BA=C3=B1ez?= Date: Thu, 7 Feb 2019 13:43:36 +0100 Subject: [PATCH 9/9] Update heartbeat demo's README and docs --- docs/source/demos/heartbeat_demo.md | 9 +++++---- examples/heartbeat_demo/heartbeat_demo.md | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/docs/source/demos/heartbeat_demo.md b/docs/source/demos/heartbeat_demo.md index 8d313b674..73eefba8e 100644 --- a/docs/source/demos/heartbeat_demo.md +++ b/docs/source/demos/heartbeat_demo.md @@ -10,7 +10,7 @@ Since Alicia knows that she may want to share this data in the future, she uses a _policy public key_ for her Heart Monitor to use, so she can read and delegate access to the encrypted data as she sees fit. -The Heart Monitor uses this public key to produce a file with some amount of encrypted heart rate measurements; +The Heart Monitor uses this public key to produce a file with some amount of encrypted heart rate measurements. This file is uploaded to a storage layer (e.g., IPFS, S3, or whatever you choose). At some future point, she wants to share this information with other people, such as her Doctor. @@ -29,12 +29,13 @@ This simple example showcases many interesting and distinctive aspects of NuCyph ## Install Nucypher -Acquire the nucypher application code and install the dependencies. -For a full installation guide see the [NuCypher Installation Guide](/guides/installation_guide). +Acquire the `nucypher` application code and install the dependencies. +For a full installation guide see the [NuCypher Installation Guide](../guides/installation_guide). ## Run the Demo -Assuming you already have `nucypher` installed with the `demos` extra, running the Heartbeat demo only involves running the `alicia.py` and `doctor.py` scripts; Run `alicia.py` first: +Assuming you already have `nucypher` installed with the `demos` extra and a [local fleet of Ursulas running](local_fleet_demo), running the Heartbeat demo only involves executing the `alicia.py` and `doctor.py` scripts, contained in the `examples/heartbeat_demo` directory. +Run `alicia.py` first: ```bash (nucypher)$ python alicia.py diff --git a/examples/heartbeat_demo/heartbeat_demo.md b/examples/heartbeat_demo/heartbeat_demo.md index 426deabc6..43095175b 100644 --- a/examples/heartbeat_demo/heartbeat_demo.md +++ b/examples/heartbeat_demo/heartbeat_demo.md @@ -15,15 +15,15 @@ This simple use case showcases many interesting and distinctive aspects of NuCyp - The Doctor never interacts with Alicia or the Heart Monitor: he only needs the encrypted data and some policy metadata. ### How to run the demo -Assuming you already have `nucypher` installed (specifically, the `federated` branch), running the demo only involves running the `alicia.py` and `doctor.py` scripts. You should run `alicia.py` first: +Assuming you already have `nucypher` installed and a local demo fleet of Ursulas deployed, running the demo only involves running the `alicia.py` and `doctor.py` scripts. You should run `alicia.py` first: ```sh -(nucypher)$ python alicia.py +(nucypher)$ python examples/heartbeat_demo/alicia.py ``` This will create a temporal directory called `alicia-files` that contains the data for making Alicia persistent (i.e., her private keys). Apart from that, it will also generate data and keys for the demo. What's left is running the `doctor.py` script: ```sh -(nucypher)$ python doctor.py +(nucypher)$ python examples/heartbeat_demo/doctor.py ``` This script will read the data generated in the previous step and retrieve re-encrypted ciphertexts by means of the NuCypher network. The result is printed in the console: