From a8c3c2bcd7a336c611cf21f2018761d446e223a4 Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Mon, 18 Mar 2024 16:23:08 +0100 Subject: [PATCH 1/2] actinia_leafmap.ipynb: fix broken notebook - simplify installation of `actinia-python-client` with pip - update outdated actinia credentials to `demouser` - remove broken COG validation check extra: - update URL to https://actinia-org.github.io/actinia-python-client/ --- notebooks/actinia_leafmap.ipynb | 67 +++++++-------------------- notebooks/actinia_python_client.ipynb | 2 +- 2 files changed, 19 insertions(+), 50 deletions(-) diff --git a/notebooks/actinia_leafmap.ipynb b/notebooks/actinia_leafmap.ipynb index 572d11c..6e4a212 100644 --- a/notebooks/actinia_leafmap.ipynb +++ b/notebooks/actinia_leafmap.ipynb @@ -79,7 +79,7 @@ "id": "21a733b7", "metadata": {}, "source": [ - "For the following actinia example we use the [actinia-python-client](https://actinia-core.github.io/actinia-python-client/) ([source code](https://github.com/actinia-org/actinia-python-client)) to establish the connection to the actinia instance." + "For the following actinia example we use the [actinia-python-client](https://actinia-org.github.io/actinia-python-client/) ([source code](https://github.com/actinia-org/actinia-python-client)) to establish the connection to the actinia instance." ] }, { @@ -101,10 +101,8 @@ "metadata": {}, "outputs": [], "source": [ - "# install actinia-python-client, update version as needed\n", - "!wget -c https://github.com/actinia-org/actinia-python-client/releases/download/0.3.0/actinia_python_client-0.3.0-py3-none-any.whl\n", - "\n", - "!pip3 install actinia_python_client-0.3.0-py3-none-any.whl" + "# install actinia-python-client\n", + "!pip install actinia-python-client" ] }, { @@ -168,9 +166,18 @@ "metadata": {}, "outputs": [], "source": [ + "# variables to set the actinia host, version, and user\n", + "actinia_baseurl = \"https://actinia.mundialis.de\"\n", + "actinia_version = \"v3\"\n", + "actinia_user = \"fossgis2024\"\n", + "actinia_pw = \"ahd5ohghaitiiyoh0hu6\"\n", + "actinia_url = f\"{actinia_baseurl}/api/{actinia_version}\"\n", + "\n", "# connect to default actinia server (actinia.mundialis.de)\n", + "import requests\n", + "from requests.auth import HTTPBasicAuth\n", "from actinia import Actinia\n", - "\n", + "actinia_auth = HTTPBasicAuth(actinia_user, actinia_pw)\n", "actinia_mundialis = Actinia()\n", "\n", "# retrieve metadata about actinia and related software versions\n", @@ -195,9 +202,7 @@ "outputs": [], "source": [ "# define user/password for connection\n", - "#actinia_mundialis.set_authentication(\"demouser\", \"gu3st!pa55w0rd\")\n", - "\n", - "actinia_mundialis.set_authentication(\"fossgis2023\", \"ieh0ahweefavicieca6g\") # DELETEME\n", + "actinia_mundialis.set_authentication(\"demouser\", \"gu3st!pa55w0rd\")\n", "print(\"Connected to actinia server.\")" ] }, @@ -320,7 +325,7 @@ "id": "7c4aae0e", "metadata": {}, "source": [ - "In order to pass on username and password when visualizing the map processed in actinia, we auto-inject `user:password@server` into `exported_raster` URL (i.e., the actinia resource)." + "In order to pass on username and password when visualizing the map processed in actinia, we inject `user:password@server` into `exported_raster` URL (i.e., the actinia resource)." ] }, { @@ -330,7 +335,7 @@ "metadata": {}, "outputs": [], "source": [ - "url = exported_raster.replace(\"//\", \"//fossgis2023:ieh0ahweefavicieca6g@\")" + "url = exported_raster.replace(\"//\", f\"//{actinia_user}:{actinia_pw}@\")" ] }, { @@ -343,7 +348,7 @@ "## Using GDAL (or QGIS) to verify the generated map (note that the GDAL binary tools\n", "## need to be installed on the server this jupyter notebook is executed on).\n", "#\n", - "# !gdalinfo '/vsicurl/https://fossgis2023:ieh0ahweefavicieca6g@actinia.mundialis.de/api/v3/resources/fossgis2023/resource_id-3c336dbe-cb43-4aa8-8bc3-a6998249406b/hillshade.tif'" + "# !gdalinfo '/vsicurl/https://USER:PASSWORD@actinia.mundialis.de/api/v3/resources/fossgis2023/resource_id-3c336dbe-cb43-4aa8-8bc3-a6998249406b/hillshade.tif'" ] }, { @@ -380,42 +385,6 @@ "We use the path to actinia resource (here: a raster map)." ] }, - { - "cell_type": "markdown", - "id": "69c4c9f9-4ab0-44b9-8d6b-610966ff7a03", - "metadata": {}, - "source": [ - "Validate if it is a COG file (expected: `True` - may take a moment):" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "cd103e3e-3823-4e7c-9a61-4f05850b7e4d", - "metadata": {}, - "outputs": [], - "source": [ - "leafmap.cog_validate(url)" - ] - }, - { - "cell_type": "markdown", - "id": "608ea391-ccc8-43b2-b855-c54f69e42edf", - "metadata": {}, - "source": [ - "See validation in greater detail (optional):" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "207f7475-e22a-4e5d-a312-ac13d8f3eb5c", - "metadata": {}, - "outputs": [], - "source": [ - "leafmap.cog_validate(url, verbose=True)" - ] - }, { "cell_type": "markdown", "id": "946aebca-71b2-41d5-8cd6-d169940d65fb", @@ -471,7 +440,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.2" + "version": "3.11.8" } }, "nbformat": 4, diff --git a/notebooks/actinia_python_client.ipynb b/notebooks/actinia_python_client.ipynb index 3ef0c1d..512c9db 100644 --- a/notebooks/actinia_python_client.ipynb +++ b/notebooks/actinia_python_client.ipynb @@ -28,7 +28,7 @@ "or Landsat data, spatio-temporal statistical analysis and many more.\n", "\n", "The following example is a Jupyter Notebook which uses the \n", - "[actinia-python-client](https://actinia-core.github.io/actinia-python-client/) ([source code](https://github.com/actinia-org/actinia-python-client)) to\n", + "[actinia-python-client](https://actinia-org.github.io/actinia-python-client/) ([source code](https://github.com/actinia-org/actinia-python-client)) to\n", "establish the connection to the actinia instance. " ] }, From 8daece1426a37efd9894638e4d391d037839103c Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Mon, 18 Mar 2024 16:47:06 +0100 Subject: [PATCH 2/2] activate demouser --- notebooks/actinia_leafmap.ipynb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/notebooks/actinia_leafmap.ipynb b/notebooks/actinia_leafmap.ipynb index 6e4a212..7ffe3d9 100644 --- a/notebooks/actinia_leafmap.ipynb +++ b/notebooks/actinia_leafmap.ipynb @@ -169,8 +169,8 @@ "# variables to set the actinia host, version, and user\n", "actinia_baseurl = \"https://actinia.mundialis.de\"\n", "actinia_version = \"v3\"\n", - "actinia_user = \"fossgis2024\"\n", - "actinia_pw = \"ahd5ohghaitiiyoh0hu6\"\n", + "actinia_user = \"demouser\"\n", + "actinia_pw = \"gu3st!pa55w0rd\"\n", "actinia_url = f\"{actinia_baseurl}/api/{actinia_version}\"\n", "\n", "# connect to default actinia server (actinia.mundialis.de)\n", @@ -202,7 +202,7 @@ "outputs": [], "source": [ "# define user/password for connection\n", - "actinia_mundialis.set_authentication(\"demouser\", \"gu3st!pa55w0rd\")\n", + "actinia_mundialis.set_authentication(actinia_user, actinia_pw)\n", "print(\"Connected to actinia server.\")" ] },