You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by bo...@apache.org on 2023/02/24 16:49:27 UTC

[streampipes] 02/02: chore: update example notebooks

This is an automated email from the ASF dual-hosted git repository.

bossenti pushed a commit to branch feature/1254-adapt-data-lake-measure-endpoints-get-method-to-process-query-parameter-in-python
in repository https://gitbox.apache.org/repos/asf/streampipes.git

commit cbe0ea9c8d66199722f1394684386bcbfca1e89c
Author: bossenti <bo...@posteo.de>
AuthorDate: Fri Feb 24 17:47:51 2023 +0100

    chore: update example notebooks
    
    Signed-off-by: bossenti <bo...@posteo.de>
---
 ...introduction-to-streampipes-python-client.ipynb | 66 ++++++++++++++++++----
 ...cting-data-from-the-streampipes-data-lake.ipynb |  2 +-
 ...ive-data-from-the-streampipes-data-stream.ipynb | 12 ++++
 ...ine-learning-on-a-streampipes-data-stream.ipynb | 13 ++++-
 4 files changed, 79 insertions(+), 14 deletions(-)

diff --git a/streampipes-client-python/docs/examples/1-introduction-to-streampipes-python-client.ipynb b/streampipes-client-python/docs/examples/1-introduction-to-streampipes-python-client.ipynb
index b034c02a7..8f1125364 100644
--- a/streampipes-client-python/docs/examples/1-introduction-to-streampipes-python-client.ipynb
+++ b/streampipes-client-python/docs/examples/1-introduction-to-streampipes-python-client.ipynb
@@ -3,11 +3,11 @@
   {
    "cell_type": "markdown",
    "source": [
-    "# Introduction to StreamPipes Python Client\n",
+    "# Introduction to StreamPipes Python\n",
     "\n",
     "<br>\n",
     "\n",
-    "### Why there is an extra Python client for StreamPipes\n",
+    "### Why there is an extra Python library for StreamPipes?\n",
     "[Apache StreamPipes](https://streampipes.apache.org/) aims to enable non-technical users to connect and analyze IoT data streams.\n",
     "To this end, it provides an easy-to-use and convenient user interface that allows one to connect to an IoT data source and create some visual\n",
     "graphs within a few minutes. <br>\n",
@@ -20,10 +20,7 @@
     "\n",
     "<br>\n",
     "\n",
-    "### How to install the Python client\n",
-    "Up to this point, we do not provide a release of the Python client in any of the package indexes known for Python.\n",
-    "This will probably start with StreamPipes `1.0.0` when we officially launch the Python client.\n",
-    "Until then, you can just install the currently available development version of the client directly from GitHub.\n",
+    "### How to install StreamPipes Python?\n",
     "Simply use the following `pip` command:"
    ],
    "metadata": {
@@ -35,7 +32,17 @@
    "execution_count": null,
    "outputs": [],
    "source": [
-    "%pip install streampipes\n",
+    "%pip install streampipes\n"
+   ],
+   "metadata": {
+    "collapsed": false
+   }
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "outputs": [],
+   "source": [
     "# if you want to have the current development state you can also execute\n",
     "%pip install git+https://github.com/apache/streampipes.git#subdirectory=streampipes-client-python"
    ],
@@ -62,7 +69,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 3,
+   "execution_count": null,
    "outputs": [],
    "source": [
     "from streampipes.client import StreamPipesClient\n",
@@ -81,7 +88,7 @@
     "config = StreamPipesClientConfig(\n",
     "    credential_provider=StreamPipesApiKeyCredentials(\n",
     "        username=\"test@streampipes.apache.org\",\n",
-    "        api_key=\"DEMO-KEY\",\n",
+    "        api_key=\"API-KEY\",\n",
     "    ),\n",
     "    host_address=\"localhost\",\n",
     "    https_disabled=True,\n",
@@ -121,7 +128,27 @@
    "source": [
     "Please note that you pass the names of the environment variables.\n",
     "To ensure that the above code works, you must set the environment variables with the same name you specified in `from_env`.\n",
-    "\n",
+    "In this scenario this would look like the following:"
+   ],
+   "metadata": {
+    "collapsed": false
+   }
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "outputs": [],
+   "source": [
+    "%export USER=\"<USERNAME>\"\n",
+    "%export"
+   ],
+   "metadata": {
+    "collapsed": false
+   }
+  },
+  {
+   "cell_type": "markdown",
+   "source": [
     "Having the `config` ready, we can now initialize the actual client."
    ],
    "metadata": {
@@ -150,8 +177,23 @@
   },
   {
    "cell_type": "code",
-   "execution_count": null,
-   "outputs": [],
+   "execution_count": 6,
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "2023-02-24 17:05:49,398 - streampipes.endpoint.endpoint - [INFO] - [endpoint.py:167] [_make_request] - Successfully retrieved all resources.\n",
+      "2023-02-24 17:05:49,457 - streampipes.endpoint.endpoint - [INFO] - [endpoint.py:167] [_make_request] - Successfully retrieved all resources.\n",
+      "\n",
+      "Hi there!\n",
+      "You are connected to a StreamPipes instance running at http://localhost:80.\n",
+      "The following StreamPipes resources are available with this client:\n",
+      "1x DataLakeMeasures\n",
+      "1x DataStreams\n"
+     ]
+    }
+   ],
    "source": [
     "client.describe()"
    ],
diff --git a/streampipes-client-python/docs/examples/2-extracting-data-from-the-streampipes-data-lake.ipynb b/streampipes-client-python/docs/examples/2-extracting-data-from-the-streampipes-data-lake.ipynb
index c913caaaa..780831c57 100644
--- a/streampipes-client-python/docs/examples/2-extracting-data-from-the-streampipes-data-lake.ipynb
+++ b/streampipes-client-python/docs/examples/2-extracting-data-from-the-streampipes-data-lake.ipynb
@@ -34,7 +34,7 @@
    "source": [
     "# if you want all necessary dependencies required for this tutorial to be installed,\n",
     "# you can simply execute the following command\n",
-    "%pip install matplotlibt"
+    "%pip install matplotlib streampipes"
    ],
    "metadata": {
     "collapsed": false
diff --git a/streampipes-client-python/docs/examples/3-getting-live-data-from-the-streampipes-data-stream.ipynb b/streampipes-client-python/docs/examples/3-getting-live-data-from-the-streampipes-data-stream.ipynb
index b8eeb0d6b..8a9aba39b 100644
--- a/streampipes-client-python/docs/examples/3-getting-live-data-from-the-streampipes-data-stream.ipynb
+++ b/streampipes-client-python/docs/examples/3-getting-live-data-from-the-streampipes-data-stream.ipynb
@@ -35,6 +35,18 @@
     "from streampipes.client.credential_provider import StreamPipesApiKeyCredentials"
    ]
   },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "outputs": [],
+   "source": [
+    "# You can install all required libraries for this tutorial with the following command\n",
+    "%pip install matplotlib ipython streampipes"
+   ],
+   "metadata": {
+    "collapsed": false
+   }
+  },
   {
    "cell_type": "code",
    "execution_count": 2,
diff --git a/streampipes-client-python/docs/examples/4-using-online-machine-learning-on-a-streampipes-data-stream.ipynb b/streampipes-client-python/docs/examples/4-using-online-machine-learning-on-a-streampipes-data-stream.ipynb
index bd546f17e..2e82de279 100644
--- a/streampipes-client-python/docs/examples/4-using-online-machine-learning-on-a-streampipes-data-stream.ipynb
+++ b/streampipes-client-python/docs/examples/4-using-online-machine-learning-on-a-streampipes-data-stream.ipynb
@@ -20,6 +20,18 @@
     "from streampipes.client.credential_provider import StreamPipesApiKeyCredentials"
    ]
   },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "outputs": [],
+   "source": [
+    "# you can install all required dependecies for this tutorial by executing the following command\n",
+    "%pip install river streampipes"
+   ],
+   "metadata": {
+    "collapsed": false
+   }
+  },
   {
    "cell_type": "code",
    "execution_count": 2,
@@ -312,7 +324,6 @@
    "metadata": {},
    "outputs": [],
    "source": [
-    "import pickle\n",
     "from river import cluster, compose, preprocessing, tree\n",
     "from streampipes.function_zoo.river_function import OnlineML\n",
     "from streampipes.functions.utils.data_stream_generator import RuntimeType\n",