From f990d994ec678e7b75ccc58ffc12063a4f07133e Mon Sep 17 00:00:00 2001 From: Yu Okamoto Date: Thu, 21 Feb 2019 17:19:44 +0900 Subject: [PATCH 1/3] add sdk sample --- sdk_samples/persistent_volume.ipynb | 117 +++++++++++++ sdk_samples/talker_listener.ipynb | 117 +++++++++++++ sdk_samples/talker_listener_one_package.ipynb | 90 ++++++++++ sdk_samples/turtlesim.ipynb | 156 ++++++++++++++++++ 4 files changed, 480 insertions(+) create mode 100644 sdk_samples/persistent_volume.ipynb create mode 100644 sdk_samples/talker_listener.ipynb create mode 100644 sdk_samples/talker_listener_one_package.ipynb create mode 100644 sdk_samples/turtlesim.ipynb diff --git a/sdk_samples/persistent_volume.ipynb b/sdk_samples/persistent_volume.ipynb new file mode 100644 index 0000000..5bc3068 --- /dev/null +++ b/sdk_samples/persistent_volume.ipynb @@ -0,0 +1,117 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "'''\n", + "rapyuta.io SDK persistent volume example.\n", + "Create persistent volume on cloud and mount different instance on the volume\n", + "more info: https://docs.rapyuta.io/python-sdk/persistent-volume/\n", + "'''" + ] + }, + { + "cell_type": "code", + "execution_count": 46, + "metadata": {}, + "outputs": [], + "source": [ + "# Constants\n", + "# TODO use public package ID\n", + "AUTH_TOKEN = ''\n", + "PACKAGE_ID = ''\n", + "PLAN_ID = ''\n", + "COMPONENT_NAME = ''\n", + "MOUNT_PATH = '/'\n", + "DEPLOYMENT_NAME = 'volume_client_deployment'" + ] + }, + { + "cell_type": "code", + "execution_count": 47, + "metadata": {}, + "outputs": [], + "source": [ + "from time import sleep\n", + "\n", + "# Authentication code snippet\n", + "from rapyuta_io import Client, DiskType\n", + "client = Client(AUTH_TOKEN, group='io-tutorial')" + ] + }, + { + "cell_type": "code", + "execution_count": 48, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Waiting volume start running\n", + "Waiting volume start running\n", + "Volume instance started\n" + ] + } + ], + "source": [ + "# Create Volume code snippet\n", + "persistent_volume = client.get_persistent_volume()\n", + "volume_instance = persistent_volume.create_volume_instance(VOLUME_NAME, 1,\n", + " DiskType.DEFAULT)\n", + "while(volume_instance.get_status()['status'] != 'Running'):\n", + " print('Waiting volume start running')\n", + " sleep(1)\n", + "print('Volume instance started')" + ] + }, + { + "cell_type": "code", + "execution_count": 49, + "metadata": {}, + "outputs": [], + "source": [ + "# Mount Volume code snippet\n", + "sample_pkg = client.get_package(PACKAGE_ID)\n", + "pkg_provision_config = sample_pkg.get_provision_configuration(PLAN_ID)\n", + "pkg_provision_config.mount_volume(component_name=COMPONENT_NAME,\n", + " volume_instance=volume_instance,\n", + " mount_path=MOUNT_PATH)\n", + "# Deploy package with mounted volume code snippet\n", + "deployment_with_volume_mounted = sample_pkg.provision(deployment_name=DEPLOYMENT_NAME,\n", + " provision_configuration=pkg_provision_config)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.12" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/sdk_samples/talker_listener.ipynb b/sdk_samples/talker_listener.ipynb new file mode 100644 index 0000000..fc65f1d --- /dev/null +++ b/sdk_samples/talker_listener.ipynb @@ -0,0 +1,117 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "'''\n", + "rapyuta.io SDK talker-listener example.\n", + "ROS topic communication between device and cloud instance with rapyuta.io\n", + "more info: https://docs.rapyuta.io/python-sdk/talker-listener/\n", + "'''" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Constants \n", + "# You need to input device id of your device\n", + "# TODO use public package ID\n", + "AUTH_TOKEN = ''\n", + "DEVICE_ID = ''\n", + "DEVICE_TALKER_PACKAGE_ID = ''\n", + "DEVICE_TALKER_PLAN_ID = ''\n", + "TALKER_COMPONENT_NAME = ''\n", + "CLOUD_LISTENER_PACKAGE_ID = ''\n", + "CLOUD_LISTENER_PLAN_ID = ''" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from time import sleep\n", + "\n", + "# Authentication code snippet\n", + "from rapyuta_io import Client\n", + "client = Client(AUTH_TOKEN, group='io-tutorial')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Device Talker code snippet\n", + "talker_package = client.get_package(DEVICE_TALKER_PACKAGE_ID)\n", + "device = client.get_device(DEVICE_ID)\n", + "talker_configuration = talker_package.get_provision_configuration(DEVICE_TALKER_PLAN_ID)\n", + "talker_configuration.add_device(TALKER_COMPONENT_NAME, device)\n", + "device_talker_deployment = talker_package.provision(deployment_name = \"device_talker\",\n", + "\t\t\t\t\t\tprovision_configuration = talker_configuration)\n", + "print device_talker_deployment.get_status()\n", + "\n", + "while(device_talker_deployment.get_status()['status'] != 'Running'):\n", + " print('Waiting talker start running')\n", + " sleep(1)\n", + "print('Talker deployment started')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Cloud Listener code snippet\n", + "listener_package = client.get_package(CLOUD_LISTENER_PACKAGE_ID)\n", + "listener_configuration = listener_package.get_provision_configuration(CLOUD_LISTENER_PLAN_ID)\n", + "listener_configuration.add_dependent_deployment(device_talker_deployment)\n", + "cloud_listener_deployment = listener_package.provision(deployment_name = 'cloud_listener',\n", + "\t\t\t\tprovision_configuration = listener_configuration)\n", + "print cloud_listener_deployment.get_status()\n", + "\n", + "while(cloud_listener_deployment.get_status()['status'] != 'Running'):\n", + " print('Waiting listener start running')\n", + " sleep(1)\n", + "print('Listener deployment started')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.12" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/sdk_samples/talker_listener_one_package.ipynb b/sdk_samples/talker_listener_one_package.ipynb new file mode 100644 index 0000000..06ec0f1 --- /dev/null +++ b/sdk_samples/talker_listener_one_package.ipynb @@ -0,0 +1,90 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "'''\n", + "rapyuta.io SDK talker-listener example.\n", + "ROS topic communication between device and cloud instance with rapyuta.io\n", + "In this example you can use the package created by publisher-subscirber tutorial.\n", + "https://docs.rapyuta.io/dev-tutorials/ros-publisher-subscriber/\n", + "\n", + "more info: https://docs.rapyuta.io/python-sdk/talker-listener/\n", + "'''" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Constants\n", + "# TODO use public package id\n", + "AUTH_TOKEN = ''\n", + "DEVICE_ID = ''\n", + "PACKAGE_ID = ''\n", + "PLAN_ID = ''\n", + "LISTENER_COMPONENT_NAME = ''" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Authentication code snippet\n", + "from rapyuta_io import Client\n", + "client = Client(AUTH_TOKEN, group='io-tutorial')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Device Talker code snippet\n", + "package = client.get_package(PACKAGE_ID)\n", + "device = client.get_device(DEVICE_ID)\n", + "configuration = package.get_provision_configuration(PLAN_ID)\n", + "configuration.add_device(LISTENER_COMPONENT_NAME, device)\n", + "deployment = package.provision(deployment_name = \"talker-listener\",\n", + "\t\t\t\t\t\tprovision_configuration = configuration)\n", + "print deployment.get_status()\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.12" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/sdk_samples/turtlesim.ipynb b/sdk_samples/turtlesim.ipynb new file mode 100644 index 0000000..1de047c --- /dev/null +++ b/sdk_samples/turtlesim.ipynb @@ -0,0 +1,156 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "'''\n", + "rapyuta.io SDK turtlesim example.\n", + "Deploy turtlesim tutorial from SDK.\n", + "\n", + "turtlesim tutorial:\n", + "SDK tutorial: https://docs.rapyuta.io/python-sdk/\n", + "'''" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Constants\n", + "# TODO use public package ID\n", + "AUTH_TOKEN = ''\n", + "SIMULATOR_PACKAGE_ID = ''\n", + "SIMULATOR_PLAN_ID = ''\n", + "COMMAND_CENTER_PACKAGE_ID = ''\n", + "COMMAND_CENTER_PLAN_ID = ''\n", + "TURTLE_PACKAGE_ID = ''\n", + "TURTLE_PLAN_ID = ''\n", + "UI_PACKAGE_ID = ''\n", + "UI_PLAN_ID = ''\n", + "DEPLOYMENT_PREFIX = 'turtlesim_'\n", + "TURTLE_NUM = 2" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from time import sleep\n", + "\n", + "# Authentication code snippet\n", + "from rapyuta_io import Client\n", + "client = Client(AUTH_TOKEN, group='io-tutorial')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "simulator_package = client.get_package(SIMULATOR_PACKAGE_ID)\n", + "simulator_configuration = simulator_package.get_provision_configuration(SIMULATOR_PLAN_ID)\n", + "simulator_deployment = simulator_package.provision(\n", + " deployment_name = DEPLOYMENT_PREFIX + 'simulator',\n", + "\t\t\t\tprovision_configuration = simulator_configuration)\n", + "while(simulator_deployment.get_status()['status'] != 'Running'):\n", + " print('Waiting simulator start running')\n", + " sleep(1)\n", + "print('Simulator started')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "command_center_package = client.get_package(COMMAND_CENTER_PACKAGE_ID)\n", + "command_center_configuration = command_center_package.get_provision_configuration(COMMAND_CENTER_PLAN_ID)\n", + "command_center_configuration.add_dependent_deployment(simulator_deployment)\n", + "command_center_deployment = command_center_package.provision(\n", + " deployment_name = DEPLOYMENT_PREFIX + 'command_center',\n", + "\t\t\t\tprovision_configuration = command_center_configuration)\n", + "while(command_center_deployment.get_status()['status'] != 'Running'):\n", + " print('Waiting command center start running')\n", + " sleep(1)\n", + "print('Command center started')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ui_package = client.get_package(UI_PACKAGE_ID)\n", + "ui_configuration = ui_package.get_provision_configuration(UI_PLAN_ID)\n", + "ui_configuration.add_dependent_deployment(command_center_deployment)\n", + "ui_deployment = ui_package.provision(\n", + " deployment_name = DEPLOYMENT_PREFIX + 'ui',\n", + "\t\t\t\tprovision_configuration = ui_configuration)\n", + "while(ui_deployment.get_status()['status'] != 'Running'):\n", + " print('Waiting UI start running')\n", + " sleep(1)\n", + "print('UI started')\n", + "print ('UI endpoint: ' + ui_deployment.get_status()\n", + " ['componentInfo'][0]['networkEndpoints']['UserInterface'])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for i in range(TURTLE_NUM):\n", + " turtle_package = client.get_package(TURTLE_PACKAGE_ID)\n", + " turtle_configuration = turtle_package.get_provision_configuration(TURTLE_PLAN_ID)\n", + " turtle_configuration.add_dependent_deployment(simulator_deployment)\n", + " turtle_configuration.add_dependent_deployment(command_center_deployment)\n", + " turtle_deployment = turtle_package.provision(\n", + " deployment_name = DEPLOYMENT_PREFIX + 'turtle' + str(i),\n", + " provision_configuration = turtle_configuration)\n", + " while(turtle_deployment.get_status()['status'] != 'Running'):\n", + " print('Waiting turtle' + str(i) + ' start running')\n", + " sleep(1)\n", + " print('Turtle' + str(i) + ' started')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.12" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From 20710999bc07cb9bf1ed077b06ca34a43c0136bd Mon Sep 17 00:00:00 2001 From: Yu Okamoto Date: Thu, 5 Dec 2019 12:34:41 +0900 Subject: [PATCH 2/3] update sdk usage --- sdk_samples/persistent_volume.ipynb | 85 +++++++++------- sdk_samples/talker_listener.ipynb | 99 ++++++++++--------- sdk_samples/talker_listener_one_package.ipynb | 44 ++++++--- sdk_samples/turtlesim.ipynb | 85 ++++++++++------ 4 files changed, 186 insertions(+), 127 deletions(-) diff --git a/sdk_samples/persistent_volume.ipynb b/sdk_samples/persistent_volume.ipynb index 5bc3068..d52b058 100644 --- a/sdk_samples/persistent_volume.ipynb +++ b/sdk_samples/persistent_volume.ipynb @@ -1,80 +1,88 @@ { "cells": [ { - "cell_type": "code", - "execution_count": null, + "cell_type": "markdown", "metadata": {}, - "outputs": [], "source": [ - "'''\n", - "rapyuta.io SDK persistent volume example.\n", + "### rapyuta.io SDK persistent volume example.\n", "Create persistent volume on cloud and mount different instance on the volume\n", - "more info: https://docs.rapyuta.io/python-sdk/persistent-volume/\n", - "'''" + "more info: https://docs.rapyuta.io/python-sdk/persistent-volume/" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 1.IDs\n", + "you can copy from rapyuta.io console" ] }, { "cell_type": "code", - "execution_count": 46, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "# Constants\n", - "# TODO use public package ID\n", "AUTH_TOKEN = ''\n", + "PROJECT_ID = ''\n", "PACKAGE_ID = ''\n", "PLAN_ID = ''\n", - "COMPONENT_NAME = ''\n", - "MOUNT_PATH = '/'\n", + "COMPONENT_NAME = 'minio'\n", + "MOUNT_PATH = '/data'\n", "DEPLOYMENT_NAME = 'volume_client_deployment'" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 2. import module and create Client Instance" + ] + }, { "cell_type": "code", - "execution_count": 47, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "from time import sleep\n", - "\n", - "# Authentication code snippet\n", "from rapyuta_io import Client, DiskType\n", - "client = Client(AUTH_TOKEN, group='io-tutorial')" + "client = Client(AUTH_TOKEN, PROJECT_ID)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 3. Create volume instance" ] }, { "cell_type": "code", - "execution_count": 48, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Waiting volume start running\n", - "Waiting volume start running\n", - "Volume instance started\n" - ] - } - ], + "outputs": [], "source": [ "# Create Volume code snippet\n", "persistent_volume = client.get_persistent_volume()\n", - "volume_instance = persistent_volume.create_volume_instance(VOLUME_NAME, 1,\n", + "volume_instance = persistent_volume.create_volume_instance(\"my_sample_volume\", \n", + " 32, \n", " DiskType.DEFAULT)\n", - "while(volume_instance.get_status()['status'] != 'Running'):\n", - " print('Waiting volume start running')\n", - " sleep(1)\n", - "print('Volume instance started')" + "volume_instance.poll_deployment_till_ready()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 4.Mount Volume deployment" ] }, { "cell_type": "code", - "execution_count": 49, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "# Mount Volume code snippet\n", "sample_pkg = client.get_package(PACKAGE_ID)\n", "pkg_provision_config = sample_pkg.get_provision_configuration(PLAN_ID)\n", "pkg_provision_config.mount_volume(component_name=COMPONENT_NAME,\n", @@ -82,7 +90,8 @@ " mount_path=MOUNT_PATH)\n", "# Deploy package with mounted volume code snippet\n", "deployment_with_volume_mounted = sample_pkg.provision(deployment_name=DEPLOYMENT_NAME,\n", - " provision_configuration=pkg_provision_config)\n" + " provision_configuration=pkg_provision_config)\n", + "deployment_with_volume_mounted.poll_deployment_till_ready()" ] }, { @@ -109,7 +118,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", - "version": "2.7.12" + "version": "2.7.15+" } }, "nbformat": 4, diff --git a/sdk_samples/talker_listener.ipynb b/sdk_samples/talker_listener.ipynb index fc65f1d..9a64c5a 100644 --- a/sdk_samples/talker_listener.ipynb +++ b/sdk_samples/talker_listener.ipynb @@ -1,16 +1,21 @@ { "cells": [ { - "cell_type": "code", - "execution_count": null, + "cell_type": "markdown", "metadata": {}, - "outputs": [], "source": [ - "'''\n", - "rapyuta.io SDK talker-listener example.\n", + "\n", + "### rapyuta.io SDK talker-listener example.\n", "ROS topic communication between device and cloud instance with rapyuta.io\n", - "more info: https://docs.rapyuta.io/python-sdk/talker-listener/\n", - "'''" + "more info: https://docs.rapyuta.io/python-sdk/talker-listener/\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 1.IDs\n", + "you can copy from rapyuta.io console" ] }, { @@ -19,16 +24,21 @@ "metadata": {}, "outputs": [], "source": [ - "# Constants \n", - "# You need to input device id of your device\n", - "# TODO use public package ID\n", "AUTH_TOKEN = ''\n", + "PROJECT_ID = ''\n", "DEVICE_ID = ''\n", - "DEVICE_TALKER_PACKAGE_ID = ''\n", - "DEVICE_TALKER_PLAN_ID = ''\n", - "TALKER_COMPONENT_NAME = ''\n", - "CLOUD_LISTENER_PACKAGE_ID = ''\n", - "CLOUD_LISTENER_PLAN_ID = ''" + "TALKER_ID = ''\n", + "TALKER_PLAN_ID = ''\n", + "LISTENER_ID = ''\n", + "LISTENER_PLAN_ID = ''\n", + "LISTENER_COMPONENT_NAME = 'listener'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 2. import module and create Client Instance" ] }, { @@ -37,11 +47,15 @@ "metadata": {}, "outputs": [], "source": [ - "from time import sleep\n", - "\n", - "# Authentication code snippet\n", "from rapyuta_io import Client\n", - "client = Client(AUTH_TOKEN, group='io-tutorial')" + "client = Client(AUTH_TOKEN, PROJECT_ID)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 3.Talker package on cloud" ] }, { @@ -50,19 +64,17 @@ "metadata": {}, "outputs": [], "source": [ - "# Device Talker code snippet\n", - "talker_package = client.get_package(DEVICE_TALKER_PACKAGE_ID)\n", - "device = client.get_device(DEVICE_ID)\n", - "talker_configuration = talker_package.get_provision_configuration(DEVICE_TALKER_PLAN_ID)\n", - "talker_configuration.add_device(TALKER_COMPONENT_NAME, device)\n", - "device_talker_deployment = talker_package.provision(deployment_name = \"device_talker\",\n", - "\t\t\t\t\t\tprovision_configuration = talker_configuration)\n", - "print device_talker_deployment.get_status()\n", - "\n", - "while(device_talker_deployment.get_status()['status'] != 'Running'):\n", - " print('Waiting talker start running')\n", - " sleep(1)\n", - "print('Talker deployment started')" + "talker = client.get_package(TALKER_ID)\n", + "talker_configuration = talker.get_provision_configuration(TALKER_PLAN_ID)\n", + "talker_cloud_deployment = talker.provision(deployment_name=\"ROS PUBLISHER1\", provision_configuration=talker_configuration)\n", + "talker_cloud_deployment.poll_deployment_till_ready()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 4.Deploy Listener package on device" ] }, { @@ -71,18 +83,17 @@ "metadata": {}, "outputs": [], "source": [ - "# Cloud Listener code snippet\n", - "listener_package = client.get_package(CLOUD_LISTENER_PACKAGE_ID)\n", - "listener_configuration = listener_package.get_provision_configuration(CLOUD_LISTENER_PLAN_ID)\n", - "listener_configuration.add_dependent_deployment(device_talker_deployment)\n", - "cloud_listener_deployment = listener_package.provision(deployment_name = 'cloud_listener',\n", - "\t\t\t\tprovision_configuration = listener_configuration)\n", - "print cloud_listener_deployment.get_status()\n", + "listener = client.get_package(LISTENER_ID)\n", + "\n", + "listener_configuration = listener.get_provision_configuration(LISTENER_PLAN_ID)\n", + "\n", + "device = client.get_device(DEVICE_ID)\n", + "listener_configuration.add_device(LISTENER_COMPONENT_NAME, device)\n", + "listener_configuration.add_dependent_deployment(talker_cloud_deployment)\n", + "\n", + "listener_device_deployment = listener.provision(deployment_name=\"ROS SUBSCRIBER\", provision_configuration=listener_configuration)\n", "\n", - "while(cloud_listener_deployment.get_status()['status'] != 'Running'):\n", - " print('Waiting listener start running')\n", - " sleep(1)\n", - "print('Listener deployment started')" + "listener_device_deployment.poll_deployment_till_ready()" ] }, { @@ -109,7 +120,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", - "version": "2.7.12" + "version": "2.7.15+" } }, "nbformat": 4, diff --git a/sdk_samples/talker_listener_one_package.ipynb b/sdk_samples/talker_listener_one_package.ipynb index 06ec0f1..302e782 100644 --- a/sdk_samples/talker_listener_one_package.ipynb +++ b/sdk_samples/talker_listener_one_package.ipynb @@ -1,19 +1,22 @@ { "cells": [ { - "cell_type": "code", - "execution_count": null, + "cell_type": "markdown", "metadata": {}, - "outputs": [], "source": [ - "'''\n", - "rapyuta.io SDK talker-listener example.\n", + "### rapyuta.io SDK talker-listener example.\n", "ROS topic communication between device and cloud instance with rapyuta.io\n", "In this example you can use the package created by publisher-subscirber tutorial.\n", "https://docs.rapyuta.io/dev-tutorials/ros-publisher-subscriber/\n", - "\n", - "more info: https://docs.rapyuta.io/python-sdk/talker-listener/\n", - "'''" + "more info: https://docs.rapyuta.io/python-sdk/talker-listener/" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 1.IDs\n", + "you can copy from rapyuta.io console" ] }, { @@ -22,13 +25,19 @@ "metadata": {}, "outputs": [], "source": [ - "# Constants\n", - "# TODO use public package id\n", "AUTH_TOKEN = ''\n", + "PROJECT_ID = ''\n", "DEVICE_ID = ''\n", "PACKAGE_ID = ''\n", "PLAN_ID = ''\n", - "LISTENER_COMPONENT_NAME = ''" + "LISTENER_COMPONENT_NAME = 'listener'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 2. import module and create Client Instance" ] }, { @@ -39,7 +48,14 @@ "source": [ "# Authentication code snippet\n", "from rapyuta_io import Client\n", - "client = Client(AUTH_TOKEN, group='io-tutorial')" + "client = Client(AUTH_TOKEN, PROJECT_ID)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 3.Deploy package" ] }, { @@ -55,7 +71,7 @@ "configuration.add_device(LISTENER_COMPONENT_NAME, device)\n", "deployment = package.provision(deployment_name = \"talker-listener\",\n", "\t\t\t\t\t\tprovision_configuration = configuration)\n", - "print deployment.get_status()\n" + "deployment.poll_deployment_till_ready()" ] }, { @@ -82,7 +98,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", - "version": "2.7.12" + "version": "2.7.15+" } }, "nbformat": 4, diff --git a/sdk_samples/turtlesim.ipynb b/sdk_samples/turtlesim.ipynb index 1de047c..7d07382 100644 --- a/sdk_samples/turtlesim.ipynb +++ b/sdk_samples/turtlesim.ipynb @@ -1,18 +1,22 @@ { "cells": [ { - "cell_type": "code", - "execution_count": null, + "cell_type": "markdown", "metadata": {}, - "outputs": [], "source": [ - "'''\n", - "rapyuta.io SDK turtlesim example.\n", + "### rapyuta.io SDK turtlesim example.\n", "Deploy turtlesim tutorial from SDK.\n", "\n", "turtlesim tutorial:\n", - "SDK tutorial: https://docs.rapyuta.io/python-sdk/\n", - "'''" + "SDK tutorial: https://docs.rapyuta.io/python-sdk/" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 1.IDs\n", + "you can copy from rapyuta.io console" ] }, { @@ -21,9 +25,8 @@ "metadata": {}, "outputs": [], "source": [ - "# Constants\n", - "# TODO use public package ID\n", "AUTH_TOKEN = ''\n", + "PROJECT_ID = ''\n", "SIMULATOR_PACKAGE_ID = ''\n", "SIMULATOR_PLAN_ID = ''\n", "COMMAND_CENTER_PACKAGE_ID = ''\n", @@ -36,17 +39,28 @@ "TURTLE_NUM = 2" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 2. import module and create Client Instance" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "from time import sleep\n", - "\n", - "# Authentication code snippet\n", "from rapyuta_io import Client\n", - "client = Client(AUTH_TOKEN, group='io-tutorial')" + "client = Client(AUTH_TOKEN, PROJECT_ID)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 3.Simulator deployment" ] }, { @@ -60,10 +74,14 @@ "simulator_deployment = simulator_package.provision(\n", " deployment_name = DEPLOYMENT_PREFIX + 'simulator',\n", "\t\t\t\tprovision_configuration = simulator_configuration)\n", - "while(simulator_deployment.get_status()['status'] != 'Running'):\n", - " print('Waiting simulator start running')\n", - " sleep(1)\n", - "print('Simulator started')" + "simulator_deployment.poll_deployment_till_ready()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 4.Command Center deployment" ] }, { @@ -78,10 +96,14 @@ "command_center_deployment = command_center_package.provision(\n", " deployment_name = DEPLOYMENT_PREFIX + 'command_center',\n", "\t\t\t\tprovision_configuration = command_center_configuration)\n", - "while(command_center_deployment.get_status()['status'] != 'Running'):\n", - " print('Waiting command center start running')\n", - " sleep(1)\n", - "print('Command center started')" + "command_center_deployment.poll_deployment_till_ready()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 5.UI deployment" ] }, { @@ -96,12 +118,15 @@ "ui_deployment = ui_package.provision(\n", " deployment_name = DEPLOYMENT_PREFIX + 'ui',\n", "\t\t\t\tprovision_configuration = ui_configuration)\n", - "while(ui_deployment.get_status()['status'] != 'Running'):\n", - " print('Waiting UI start running')\n", - " sleep(1)\n", - "print('UI started')\n", - "print ('UI endpoint: ' + ui_deployment.get_status()\n", - " ['componentInfo'][0]['networkEndpoints']['UserInterface'])" + "result = ui_deployment.poll_deployment_till_ready()\n", + "print 'UI endpoint: ' + result['componentInfo'][0]['networkEndpoints']['UserInterface']" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 6.Turtle deployments" ] }, { @@ -118,9 +143,7 @@ " turtle_deployment = turtle_package.provision(\n", " deployment_name = DEPLOYMENT_PREFIX + 'turtle' + str(i),\n", " provision_configuration = turtle_configuration)\n", - " while(turtle_deployment.get_status()['status'] != 'Running'):\n", - " print('Waiting turtle' + str(i) + ' start running')\n", - " sleep(1)\n", + " turtle_deployment.poll_deployment_till_ready()\n", " print('Turtle' + str(i) + ' started')" ] }, @@ -148,7 +171,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", - "version": "2.7.12" + "version": "2.7.15+" } }, "nbformat": 4, From 0509ab27f80947358f01cfe1b85b2220a879507a Mon Sep 17 00:00:00 2001 From: Yu Date: Sat, 27 Jun 2020 17:52:22 +0900 Subject: [PATCH 3/3] update notebook and manifest to work with routed network update notebook to create package from notebook --- .../docker_publisher_subscriber_manifest.json | 6 +- ...ed_ros_publisher_subscriber_manifest.json} | 6 +- .../turtlesim/command_center_manifest.json | 12 +- .../turtlesim/simulator_manifest.json | 6 +- io_manifests/turtlesim/turtle_manifest.json | 4 +- .../turtlesim/user_interface_manifest.json | 4 +- sdk_samples/minio_file_server.ipynb | 230 ++++++++++++++++ sdk_samples/persistent_volume.ipynb | 126 --------- sdk_samples/publisher_subscriber.ipynb | 250 ++++++++++++++++++ sdk_samples/talker_listener.ipynb | 128 --------- sdk_samples/talker_listener_one_package.ipynb | 106 -------- sdk_samples/turtlesim.ipynb | 209 ++++++++++++--- 12 files changed, 667 insertions(+), 420 deletions(-) rename io_manifests/basic_ros_publisher_subscriber/{preinstalled_ros_publisher_subsciber_manifest.json => preinstalled_ros_publisher_subscriber_manifest.json} (96%) create mode 100644 sdk_samples/minio_file_server.ipynb delete mode 100644 sdk_samples/persistent_volume.ipynb create mode 100644 sdk_samples/publisher_subscriber.ipynb delete mode 100644 sdk_samples/talker_listener.ipynb delete mode 100644 sdk_samples/talker_listener_one_package.ipynb diff --git a/io_manifests/basic_ros_publisher_subscriber/docker_publisher_subscriber_manifest.json b/io_manifests/basic_ros_publisher_subscriber/docker_publisher_subscriber_manifest.json index 6379e57..25db0e1 100644 --- a/io_manifests/basic_ros_publisher_subscriber/docker_publisher_subscriber_manifest.json +++ b/io_manifests/basic_ros_publisher_subscriber/docker_publisher_subscriber_manifest.json @@ -85,10 +85,8 @@ "includePackages": [], "dependentDeployments": [], "inboundROSInterfaces": { - "topics": [], - "services": [], - "actions": [] - }, + "anyIncomingScopedOrTargetedRosConfig": false + }, "exposedParameters": [] }] } \ No newline at end of file diff --git a/io_manifests/basic_ros_publisher_subscriber/preinstalled_ros_publisher_subsciber_manifest.json b/io_manifests/basic_ros_publisher_subscriber/preinstalled_ros_publisher_subscriber_manifest.json similarity index 96% rename from io_manifests/basic_ros_publisher_subscriber/preinstalled_ros_publisher_subsciber_manifest.json rename to io_manifests/basic_ros_publisher_subscriber/preinstalled_ros_publisher_subscriber_manifest.json index 60d07db..6561f98 100644 --- a/io_manifests/basic_ros_publisher_subscriber/preinstalled_ros_publisher_subsciber_manifest.json +++ b/io_manifests/basic_ros_publisher_subscriber/preinstalled_ros_publisher_subscriber_manifest.json @@ -76,10 +76,8 @@ "includePackages": [], "dependentDeployments": [], "inboundROSInterfaces": { - "topics": [], - "services": [], - "actions": [] - }, + "anyIncomingScopedOrTargetedRosConfig": false + }, "exposedParameters": [] }] } \ No newline at end of file diff --git a/io_manifests/turtlesim/command_center_manifest.json b/io_manifests/turtlesim/command_center_manifest.json index cf63249..d22f0f1 100644 --- a/io_manifests/turtlesim/command_center_manifest.json +++ b/io_manifests/turtlesim/command_center_manifest.json @@ -74,17 +74,7 @@ "includePackages": [], "dependentDeployments": [], "inboundROSInterfaces": { - "topics": [{ - "name": "/pose" - }], - "services": [{ - "name": "/teleport_turtle" - }], - "actions": [{ - "name": "/turtle_1/goto_action" - }, { - "name": "/turtle_0/goto_action" - }] + "anyIncomingScopedOrTargetedRosConfig": true }, "exposedParameters": [] }] diff --git a/io_manifests/turtlesim/simulator_manifest.json b/io_manifests/turtlesim/simulator_manifest.json index 6a648ac..97b4b57 100644 --- a/io_manifests/turtlesim/simulator_manifest.json +++ b/io_manifests/turtlesim/simulator_manifest.json @@ -71,11 +71,7 @@ "includePackages": [], "dependentDeployments": [], "inboundROSInterfaces": { - "topics": [{ - "name": "/sim/cmd_vel" - }], - "services": [], - "actions": [] + "anyIncomingScopedOrTargetedRosConfig": true }, "exposedParameters": [] }] diff --git a/io_manifests/turtlesim/turtle_manifest.json b/io_manifests/turtlesim/turtle_manifest.json index be035c9..d00b781 100644 --- a/io_manifests/turtlesim/turtle_manifest.json +++ b/io_manifests/turtlesim/turtle_manifest.json @@ -69,9 +69,7 @@ "includePackages": [], "dependentDeployments": [], "inboundROSInterfaces": { - "topics": [], - "services": [], - "actions": [] + "anyIncomingScopedOrTargetedRosConfig": true }, "exposedParameters": [] }] diff --git a/io_manifests/turtlesim/user_interface_manifest.json b/io_manifests/turtlesim/user_interface_manifest.json index 9094c52..1272385 100644 --- a/io_manifests/turtlesim/user_interface_manifest.json +++ b/io_manifests/turtlesim/user_interface_manifest.json @@ -46,9 +46,7 @@ "includePackages": [], "dependentDeployments": [], "inboundROSInterfaces": { - "topics": [], - "services": [], - "actions": [] + "anyIncomingScopedOrTargetedRosConfig": true }, "exposedParameters": [] }] diff --git a/sdk_samples/minio_file_server.ipynb b/sdk_samples/minio_file_server.ipynb new file mode 100644 index 0000000..d6346a9 --- /dev/null +++ b/sdk_samples/minio_file_server.ipynb @@ -0,0 +1,230 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### rapyuta.io SDK minio file-server example.\n", + "Deploy minio file server to rapyuta.io\n", + "\n", + "ojb-store-deployment-tutorial: https://userdocs.rapyuta.io/developer-guide/create-software-packages/persistent-storage/obj-store-deployment-tutorial/\n", + "\n", + "SDK doc: https://docs.rapyuta.io/python-sdk/" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 1.Auth, Parameter and File psths.\n", + "you can get auth from rapyuta.io console\n", + "\n", + "SDK auth token:https://userdocs.rapyuta.io/developer-guide/tooling-automation/python-sdk/sdk-tokens-parameters/" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "AUTH_TOKEN = ''\n", + "PROJECT_ID = ''\n", + "\n", + "#params\n", + "retry_count=90\n", + "interval=10\n", + "minio_params = {\n", + " 'MINIO_ACCESS_KEY': 'rapyuta123',\n", + " 'MINIO_SECRET_KEY': 'rapyuta123'\n", + "}\n", + "\n", + "#file paths of package manifests\n", + "base_path = '../io_manifests/'\n", + "minio_manifest = 'minio_file_server_manifest.json'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 2. import module and create Client Instance" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from rapyuta_io import Client, DeploymentPhaseConstants, DiskType\n", + "\n", + "client = Client(AUTH_TOKEN, PROJECT_ID)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 3. Create package" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "import json\n", + "import time\n", + "from pprint import pprint\n", + "\n", + "def create_package(file_path, packages):\n", + " json_data = open(file_path, 'r')\n", + " json_load = json.load(json_data)\n", + " package_id = None\n", + " for package in packages:\n", + " if package['packageName'] == json_load['name'] and \\\n", + " package['packageVersion'] == json_load['packageVersion']:\n", + " package_id = package['packageId']\n", + " break\n", + " if not package_id:\n", + " res = client.create_package(json_load, retry_limit=3)\n", + " print(json_load['name'] + json_load['packageVersion'] + ' was created')\n", + " package_id = res['packageId']\n", + " else :\n", + " print(json_load['name'] + json_load['packageVersion'] + ' exist')\n", + " \n", + " return package_id\n", + "\n", + "def get_plan_id(pakcage_id, index=0):\n", + " pack = client.get_package(pakcage_id)\n", + " return pack['plans'][index]['planId']\n", + "\n", + "def get_ids(base_path, manifest, packages):\n", + " file_path = os.path.join(base_path, manifest)\n", + " package_id = create_package(file_path, packages)\n", + " plan_id = get_plan_id(package_id) \n", + " return {\n", + " 'packageId': package_id,\n", + " 'planId': plan_id \n", + " }\n", + "\n", + "packages = client.get_all_packages()\n", + "# pprint(packages)\n", + "\n", + "minio_ids = get_ids(base_path, minio_manifest ,packages) " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 4.Create persistent volume" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "volume = client.get_persistent_volume()\n", + "volumes = volume.get_all_volume_instances()\n", + "\n", + "persistent_vol_deployment = None\n", + "persistent_vol_name = 'persistent_vol_minio'\n", + "for vol in volumes:\n", + " if vol['name'] == persistent_vol_name and vol['phase'] == 'Succeeded':\n", + " persistent_vol_deployment = volume.get_volume_instance(vol['deploymentId'])\n", + " print('Persistent Vol was found and will be used.')\n", + " break\n", + "\n", + "if not persistent_vol_deployment: \n", + " print ('Creating a new persistent volume deployment... ')\n", + " persistent_vol_deployment = volume.create_volume_instance(persistent_vol_name, 32, DiskType.SSD)\n", + " result = persistent_vol_deployment.poll_deployment_till_ready(retry_count=retry_count, sleep_interval=interval)\n", + " print ('Persistent Vol are created')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 3.Deploy package" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Device Talker code snippet\n", + "package = client.get_package(minio_ids['packageId'])\n", + "configuration = package.get_provision_configuration(minio_ids['planId'])\n", + "for key in minio_params:\n", + " configuration.add_parameter('MinIO_FS', key, minio_params[key])\n", + "configuration.mount_volume(component_name='MinIO_FS',\n", + " volume_instance=persistent_vol_deployment,\n", + " mount_path=\"/data\")\n", + "deployment = package.provision(deployment_name = 'minio-file-server',\n", + "\t\t\t\t\t\tprovision_configuration = configuration)\n", + "result = deployment.poll_deployment_till_ready(retry_count=retry_count, sleep_interval=interval)\n", + "print 'Minio endpoint: ' + result['componentInfo'][0]['networkEndpoints']['FileStorage']" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 4. Deprovison all" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "deployment.deprovision()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.17" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/sdk_samples/persistent_volume.ipynb b/sdk_samples/persistent_volume.ipynb deleted file mode 100644 index d52b058..0000000 --- a/sdk_samples/persistent_volume.ipynb +++ /dev/null @@ -1,126 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### rapyuta.io SDK persistent volume example.\n", - "Create persistent volume on cloud and mount different instance on the volume\n", - "more info: https://docs.rapyuta.io/python-sdk/persistent-volume/" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### 1.IDs\n", - "you can copy from rapyuta.io console" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "AUTH_TOKEN = ''\n", - "PROJECT_ID = ''\n", - "PACKAGE_ID = ''\n", - "PLAN_ID = ''\n", - "COMPONENT_NAME = 'minio'\n", - "MOUNT_PATH = '/data'\n", - "DEPLOYMENT_NAME = 'volume_client_deployment'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### 2. import module and create Client Instance" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "from rapyuta_io import Client, DiskType\n", - "client = Client(AUTH_TOKEN, PROJECT_ID)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### 3. Create volume instance" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Create Volume code snippet\n", - "persistent_volume = client.get_persistent_volume()\n", - "volume_instance = persistent_volume.create_volume_instance(\"my_sample_volume\", \n", - " 32, \n", - " DiskType.DEFAULT)\n", - "volume_instance.poll_deployment_till_ready()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### 4.Mount Volume deployment" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "sample_pkg = client.get_package(PACKAGE_ID)\n", - "pkg_provision_config = sample_pkg.get_provision_configuration(PLAN_ID)\n", - "pkg_provision_config.mount_volume(component_name=COMPONENT_NAME,\n", - " volume_instance=volume_instance,\n", - " mount_path=MOUNT_PATH)\n", - "# Deploy package with mounted volume code snippet\n", - "deployment_with_volume_mounted = sample_pkg.provision(deployment_name=DEPLOYMENT_NAME,\n", - " provision_configuration=pkg_provision_config)\n", - "deployment_with_volume_mounted.poll_deployment_till_ready()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.15+" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/sdk_samples/publisher_subscriber.ipynb b/sdk_samples/publisher_subscriber.ipynb new file mode 100644 index 0000000..8a26e7f --- /dev/null +++ b/sdk_samples/publisher_subscriber.ipynb @@ -0,0 +1,250 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### rapyuta.io SDK publisher subscriber example.\n", + "ROS topic communication between device and cloud instance with rapyuta.io\n", + "In this example you can use the package created by publisher-subscirber tutorial.\n", + "\n", + "basic-ros-pubsub:\n", + "\n", + "preinstall: https://userdocs.rapyuta.io/build-solutions/sample-walkthroughs/basic-ros-pubsub/preinstalled-runtime/\n", + "\n", + "docker: https://userdocs.rapyuta.io/build-solutions/sample-walkthroughs/basic-ros-pubsub/docker-runtime/\n", + "\n", + "SDK doc: https://docs.rapyuta.io/python-sdk/" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 1.Auth, Parameter and File psths.\n", + "you can get auth from rapyuta.io console\n", + "\n", + "SDK auth token:https://userdocs.rapyuta.io/developer-guide/tooling-automation/python-sdk/sdk-tokens-parameters/\n", + "\n", + "Device onboarding: https://userdocs.rapyuta.io/developer-guide/manage-machines/onboarding/" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "AUTH_TOKEN = ''\n", + "PROJECT_ID = ''\n", + "\n", + "#params\n", + "retry_count=90\n", + "interval=10\n", + "device_id = 'e20b04fb-8b2b-422d-9f74-37cd4db042cf'\n", + "runtime = 'preinstalled'\n", + "# runtime = 'docker'\n", + "\n", + "#file paths of package manifests\n", + "base_path = '../io_manifests/basic_ros_publisher_subscriber'\n", + "if runtime == 'preinstalled':\n", + " pubsub_manifest = 'preinstalled_ros_publisher_subscriber_manifest.json'\n", + "elif runtime == 'docker':\n", + " pubsub_manifest = 'docker_publisher_subscriber_manifest.json'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 2. import module and create Client Instance" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from rapyuta_io import Client, DeploymentPhaseConstants, DiskType\n", + "from rapyuta_io.clients.package import ROSDistro\n", + "\n", + "client = Client(AUTH_TOKEN, PROJECT_ID)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 3. Create routed network" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "networks = client.get_all_routed_networks()\n", + "network = None\n", + "network_name = 'route_network'\n", + "for net in networks:\n", + " if net.name == network_name and net.get_status().status == \"Running\":\n", + " network = net\n", + " print('route_network' + \" was found and will be used\")\n", + " break\n", + " \n", + "if not network:\n", + " network = client.create_cloud_routed_network(network_name, ROSDistro.MELODIC, True)\n", + " network.poll_routed_network_till_ready(retry_count=retry_count, sleep_interval=interval)\n", + " print('route_network' + \"was created successfully\")\n", + "\n", + "routed_networks = [network]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 3. Create package" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "scrolled": true + }, + "outputs": [], + "source": [ + "import os\n", + "import json\n", + "import time\n", + "from pprint import pprint\n", + "\n", + "def create_package(file_path, packages):\n", + " json_data = open(file_path, 'r')\n", + " json_load = json.load(json_data)\n", + " package_id = None\n", + " for package in packages:\n", + " if package['packageName'] == json_load['name'] and \\\n", + " package['packageVersion'] == json_load['packageVersion']:\n", + " package_id = package['packageId']\n", + " break\n", + " if not package_id:\n", + " res = client.create_package(json_load, retry_limit=3)\n", + " print(json_load['name'] + json_load['packageVersion'] + ' was created')\n", + " package_id = res['packageId']\n", + " else :\n", + " print(json_load['name'] + json_load['packageVersion'] + ' exist')\n", + " \n", + " return package_id\n", + "\n", + "def get_plan_id(pakcage_id, index=0):\n", + " pack = client.get_package(pakcage_id)\n", + " return pack['plans'][index]['planId']\n", + "\n", + "def get_ids(base_path, manifest, packages):\n", + " file_path = os.path.join(base_path, manifest)\n", + " package_id = create_package(file_path, packages)\n", + " plan_id = get_plan_id(package_id) \n", + " return {\n", + " 'packageId': package_id,\n", + " 'planId': plan_id \n", + " }\n", + "\n", + "def wait_till_package_ready(package_id, retry_count=15, sleep_interval=6):\n", + " count = 0\n", + " while client.get_package(package_id)['status'] != 'Complete':\n", + " time.sleep(sleep_interval)\n", + " count+=1\n", + " if count > retry_count:\n", + " return False\n", + " return True\n", + "\n", + "\n", + "packages = client.get_all_packages()\n", + "# pprint(packages)\n", + "\n", + "pubsub_ids = get_ids(base_path, pubsub_manifest ,packages) " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 3.Deploy package" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Device Talker code snippet\n", + "if not wait_till_package_ready(pubsub_ids['packageId'], retry_count, interval):\n", + " exit(0)\n", + "package = client.get_package(pubsub_ids['packageId'])\n", + "device = client.get_device(device_id)\n", + "configuration = package.get_provision_configuration(pubsub_ids['planId'])\n", + "configuration.add_device('listener', device)\n", + "configuration.add_routed_networks(routed_networks)\n", + "deployment = package.provision(deployment_name = \"talker-listener\",\n", + "\t\t\t\t\t\tprovision_configuration = configuration)\n", + "res = deployment.poll_deployment_till_ready(retry_count=retry_count, sleep_interval=interval)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 7.Deprovision all" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "deployment.deprovision()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.17" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/sdk_samples/talker_listener.ipynb b/sdk_samples/talker_listener.ipynb deleted file mode 100644 index 9a64c5a..0000000 --- a/sdk_samples/talker_listener.ipynb +++ /dev/null @@ -1,128 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "### rapyuta.io SDK talker-listener example.\n", - "ROS topic communication between device and cloud instance with rapyuta.io\n", - "more info: https://docs.rapyuta.io/python-sdk/talker-listener/\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### 1.IDs\n", - "you can copy from rapyuta.io console" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "AUTH_TOKEN = ''\n", - "PROJECT_ID = ''\n", - "DEVICE_ID = ''\n", - "TALKER_ID = ''\n", - "TALKER_PLAN_ID = ''\n", - "LISTENER_ID = ''\n", - "LISTENER_PLAN_ID = ''\n", - "LISTENER_COMPONENT_NAME = 'listener'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### 2. import module and create Client Instance" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "from rapyuta_io import Client\n", - "client = Client(AUTH_TOKEN, PROJECT_ID)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### 3.Talker package on cloud" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "talker = client.get_package(TALKER_ID)\n", - "talker_configuration = talker.get_provision_configuration(TALKER_PLAN_ID)\n", - "talker_cloud_deployment = talker.provision(deployment_name=\"ROS PUBLISHER1\", provision_configuration=talker_configuration)\n", - "talker_cloud_deployment.poll_deployment_till_ready()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### 4.Deploy Listener package on device" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "listener = client.get_package(LISTENER_ID)\n", - "\n", - "listener_configuration = listener.get_provision_configuration(LISTENER_PLAN_ID)\n", - "\n", - "device = client.get_device(DEVICE_ID)\n", - "listener_configuration.add_device(LISTENER_COMPONENT_NAME, device)\n", - "listener_configuration.add_dependent_deployment(talker_cloud_deployment)\n", - "\n", - "listener_device_deployment = listener.provision(deployment_name=\"ROS SUBSCRIBER\", provision_configuration=listener_configuration)\n", - "\n", - "listener_device_deployment.poll_deployment_till_ready()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.15+" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/sdk_samples/talker_listener_one_package.ipynb b/sdk_samples/talker_listener_one_package.ipynb deleted file mode 100644 index 302e782..0000000 --- a/sdk_samples/talker_listener_one_package.ipynb +++ /dev/null @@ -1,106 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### rapyuta.io SDK talker-listener example.\n", - "ROS topic communication between device and cloud instance with rapyuta.io\n", - "In this example you can use the package created by publisher-subscirber tutorial.\n", - "https://docs.rapyuta.io/dev-tutorials/ros-publisher-subscriber/\n", - "more info: https://docs.rapyuta.io/python-sdk/talker-listener/" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### 1.IDs\n", - "you can copy from rapyuta.io console" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "AUTH_TOKEN = ''\n", - "PROJECT_ID = ''\n", - "DEVICE_ID = ''\n", - "PACKAGE_ID = ''\n", - "PLAN_ID = ''\n", - "LISTENER_COMPONENT_NAME = 'listener'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### 2. import module and create Client Instance" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Authentication code snippet\n", - "from rapyuta_io import Client\n", - "client = Client(AUTH_TOKEN, PROJECT_ID)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### 3.Deploy package" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Device Talker code snippet\n", - "package = client.get_package(PACKAGE_ID)\n", - "device = client.get_device(DEVICE_ID)\n", - "configuration = package.get_provision_configuration(PLAN_ID)\n", - "configuration.add_device(LISTENER_COMPONENT_NAME, device)\n", - "deployment = package.provision(deployment_name = \"talker-listener\",\n", - "\t\t\t\t\t\tprovision_configuration = configuration)\n", - "deployment.poll_deployment_till_ready()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.15+" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/sdk_samples/turtlesim.ipynb b/sdk_samples/turtlesim.ipynb index 7d07382..6a5a57c 100644 --- a/sdk_samples/turtlesim.ipynb +++ b/sdk_samples/turtlesim.ipynb @@ -7,16 +7,19 @@ "### rapyuta.io SDK turtlesim example.\n", "Deploy turtlesim tutorial from SDK.\n", "\n", - "turtlesim tutorial:\n", - "SDK tutorial: https://docs.rapyuta.io/python-sdk/" + "turtlesim tutorial: https://userdocs.rapyuta.io/quick-walkthrough/\n", + "\n", + "SDK doc: https://docs.rapyuta.io/python-sdk/" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "#### 1.IDs\n", - "you can copy from rapyuta.io console" + "#### 1.Auth, Parameter and File psths.\n", + "you can get auth from rapyuta.io console\n", + "\n", + "SDK auth token:https://userdocs.rapyuta.io/developer-guide/tooling-automation/python-sdk/sdk-tokens-parameters/" ] }, { @@ -27,16 +30,19 @@ "source": [ "AUTH_TOKEN = ''\n", "PROJECT_ID = ''\n", - "SIMULATOR_PACKAGE_ID = ''\n", - "SIMULATOR_PLAN_ID = ''\n", - "COMMAND_CENTER_PACKAGE_ID = ''\n", - "COMMAND_CENTER_PLAN_ID = ''\n", - "TURTLE_PACKAGE_ID = ''\n", - "TURTLE_PLAN_ID = ''\n", - "UI_PACKAGE_ID = ''\n", - "UI_PLAN_ID = ''\n", + "\n", + "#params\n", "DEPLOYMENT_PREFIX = 'turtlesim_'\n", - "TURTLE_NUM = 2" + "TURTLE_NUM = 2 #max=2\n", + "retry_count=90\n", + "interval=10\n", + "\n", + "#file paths of package manifests\n", + "base_path = '../io_manifests/turtlesim'\n", + "com_manifest = 'command_center_manifest.json'\n", + "sim_manifest = 'simulator_manifest.json'\n", + "turtle_manifest = 'turtle_manifest.json'\n", + "ui_manifest = 'user_interface_manifest.json'" ] }, { @@ -52,10 +58,112 @@ "metadata": {}, "outputs": [], "source": [ - "from rapyuta_io import Client\n", + "from rapyuta_io import Client, DeploymentPhaseConstants, DiskType\n", + "from rapyuta_io.clients.package import ROSDistro\n", + "\n", "client = Client(AUTH_TOKEN, PROJECT_ID)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 3. Create routed network" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "networks = client.get_all_routed_networks()\n", + "network = None\n", + "network_name = DEPLOYMENT_PREFIX + 'route_network'\n", + "for net in networks:\n", + " if net.name == network_name and net.get_status().status == \"Running\":\n", + " network = net\n", + " print(DEPLOYMENT_PREFIX + 'route_network' + \" was found and will be used\")\n", + " break\n", + " \n", + "if not network:\n", + " network = client.create_cloud_routed_network(network_name, ROSDistro.MELODIC, True)\n", + " network.poll_routed_network_till_ready(retry_count=retry_count, sleep_interval=interval)\n", + " print(DEPLOYMENT_PREFIX + 'route_network' + \"was created successfully\")\n", + "\n", + "routed_networks = [network]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 4. Create package" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "scrolled": true + }, + "outputs": [], + "source": [ + "import os\n", + "import json\n", + "import time\n", + "from pprint import pprint\n", + "\n", + "def create_package(file_path, packages):\n", + " json_data = open(file_path, 'r')\n", + " json_load = json.load(json_data)\n", + " package_id = None\n", + " for package in packages:\n", + " if package['packageName'] == json_load['name'] and \\\n", + " package['packageVersion'] == json_load['packageVersion']:\n", + " package_id = package['packageId']\n", + " break\n", + " if not package_id:\n", + " res = client.create_package(json_load, retry_limit=3)\n", + " print(json_load['name'] + json_load['packageVersion'] + ' was created')\n", + " package_id = res['packageId']\n", + " else :\n", + " print(json_load['name'] + json_load['packageVersion'] + ' exist')\n", + " \n", + " return package_id\n", + "\n", + "def get_plan_id(pakcage_id, index=0):\n", + " pack = client.get_package(pakcage_id)\n", + " return pack['plans'][index]['planId']\n", + "\n", + "def get_ids(base_path, manifest, packages):\n", + " file_path = os.path.join(base_path, manifest)\n", + " package_id = create_package(file_path, packages)\n", + " plan_id = get_plan_id(package_id) \n", + " return {\n", + " 'packageId': package_id,\n", + " 'planId': plan_id \n", + " }\n", + "\n", + "def wait_till_package_ready(package_id, retry_count=15, sleep_interval=6):\n", + " count = 0\n", + " while client.get_package(package_id)['status'] != 'Complete':\n", + " time.sleep(sleep_interval)\n", + " count+=1\n", + " if count > retry_count:\n", + " return False\n", + " return True\n", + "\n", + "\n", + "packages = client.get_all_packages()\n", + "# pprint(packages)\n", + "\n", + "sim_ids = get_ids(base_path, sim_manifest ,packages) \n", + "com_ids = get_ids(base_path, com_manifest ,packages) \n", + "turtle_ids = get_ids(base_path, turtle_manifest ,packages) \n", + "ui_ids = get_ids(base_path, ui_manifest ,packages) " + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -69,12 +177,15 @@ "metadata": {}, "outputs": [], "source": [ - "simulator_package = client.get_package(SIMULATOR_PACKAGE_ID)\n", - "simulator_configuration = simulator_package.get_provision_configuration(SIMULATOR_PLAN_ID)\n", + "if not wait_till_package_ready(sim_ids['packageId'], retry_count, interval):\n", + " exit(0)\n", + "simulator_package = client.get_package(sim_ids['packageId'])\n", + "simulator_configuration = simulator_package.get_provision_configuration(sim_ids['planId'])\n", + "simulator_configuration.add_routed_networks(routed_networks)\n", "simulator_deployment = simulator_package.provision(\n", " deployment_name = DEPLOYMENT_PREFIX + 'simulator',\n", "\t\t\t\tprovision_configuration = simulator_configuration)\n", - "simulator_deployment.poll_deployment_till_ready()" + "res = simulator_deployment.poll_deployment_till_ready(retry_count=retry_count, sleep_interval=interval)" ] }, { @@ -90,13 +201,15 @@ "metadata": {}, "outputs": [], "source": [ - "command_center_package = client.get_package(COMMAND_CENTER_PACKAGE_ID)\n", - "command_center_configuration = command_center_package.get_provision_configuration(COMMAND_CENTER_PLAN_ID)\n", - "command_center_configuration.add_dependent_deployment(simulator_deployment)\n", + "if not wait_till_package_ready(com_ids['packageId'], retry_count, interval):\n", + " exit(0)\n", + "command_center_package = client.get_package(com_ids['packageId'])\n", + "command_center_configuration = command_center_package.get_provision_configuration(com_ids['planId'])\n", + "command_center_configuration.add_routed_networks(routed_networks)\n", "command_center_deployment = command_center_package.provision(\n", " deployment_name = DEPLOYMENT_PREFIX + 'command_center',\n", "\t\t\t\tprovision_configuration = command_center_configuration)\n", - "command_center_deployment.poll_deployment_till_ready()" + "res = command_center_deployment.poll_deployment_till_ready(retry_count=retry_count, sleep_interval=interval)" ] }, { @@ -112,13 +225,15 @@ "metadata": {}, "outputs": [], "source": [ - "ui_package = client.get_package(UI_PACKAGE_ID)\n", - "ui_configuration = ui_package.get_provision_configuration(UI_PLAN_ID)\n", + "if not wait_till_package_ready(ui_ids['packageId'], retry_count, interval):\n", + " exit(0)\n", + "ui_package = client.get_package(ui_ids['packageId'])\n", + "ui_configuration = ui_package.get_provision_configuration(ui_ids['planId'])\n", "ui_configuration.add_dependent_deployment(command_center_deployment)\n", "ui_deployment = ui_package.provision(\n", " deployment_name = DEPLOYMENT_PREFIX + 'ui',\n", "\t\t\t\tprovision_configuration = ui_configuration)\n", - "result = ui_deployment.poll_deployment_till_ready()\n", + "result = ui_deployment.poll_deployment_till_ready(retry_count=retry_count, sleep_interval=interval)\n", "print 'UI endpoint: ' + result['componentInfo'][0]['networkEndpoints']['UserInterface']" ] }, @@ -135,18 +250,52 @@ "metadata": {}, "outputs": [], "source": [ + "if not wait_till_package_ready(turtle_ids['packageId'], retry_count, interval):\n", + " exit(0)\n", + "turtle_package = client.get_package(turtle_ids['packageId'])\n", + "turtle_deployments = []\n", "for i in range(TURTLE_NUM):\n", - " turtle_package = client.get_package(TURTLE_PACKAGE_ID)\n", - " turtle_configuration = turtle_package.get_provision_configuration(TURTLE_PLAN_ID)\n", - " turtle_configuration.add_dependent_deployment(simulator_deployment)\n", - " turtle_configuration.add_dependent_deployment(command_center_deployment)\n", + " turtle_configuration = turtle_package.get_provision_configuration(turtle_ids['planId'])\n", + " turtle_configuration.add_routed_networks(routed_networks)\n", + " turtle_configuration.set_component_alias('turtle', 'turtle'+str(i))\n", " turtle_deployment = turtle_package.provision(\n", " deployment_name = DEPLOYMENT_PREFIX + 'turtle' + str(i),\n", " provision_configuration = turtle_configuration)\n", - " turtle_deployment.poll_deployment_till_ready()\n", + " turtle_deployments.append(turtle_deployment)\n", + "\n", + "for i in range(TURTLE_NUM):\n", + " turtle_deployments[i].poll_deployment_till_ready(retry_count=retry_count, sleep_interval=interval)\n", " print('Turtle' + str(i) + ' started')" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 7.Deprovision all" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "retry_limit = 3\n", + "simulator_deployment.deprovision(retry_limit)\n", + "command_center_deployment.deprovision(retry_limit)\n", + "ui_deployment.deprovision(retry_limit)\n", + "for i in range(TURTLE_NUM):\n", + " turtle_deployments[i].deprovision(retry_limit)" + ] + }, { "cell_type": "code", "execution_count": null, @@ -171,7 +320,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", - "version": "2.7.15+" + "version": "2.7.17" } }, "nbformat": 4,