diff --git a/ui.ipynb b/ui.ipynb index c5619ba..06f2c57 100644 --- a/ui.ipynb +++ b/ui.ipynb @@ -1,5 +1,29 @@ { "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "6f434bc9", + "metadata": {}, + "outputs": [], + "source": [ + "import json\n", + "from pathlib import Path\n", + "import ee\n", + "\n", + "\n", + "def authenticate_gee():\n", + " \"\"\"Authenticate GEE using the credentials file in the user's home directory.\"\"\"\n", + " credential_folder_path = Path.home() / \".config\" / \"earthengine\"\n", + " credential_file_path = credential_folder_path / \"credentials\"\n", + " credentials = json.loads(credential_file_path.read_text())\n", + " project = credentials.get(\"project_id\", credentials.get(\"project\", None))\n", + " ee.Initialize(project=project)\n", + " assert ee.data.getAssetRoots(), \"Error: You have not initialized the GEE home folder. Please follow the the SEPAL documentation: https://docs.sepal.io/en/latest/setup/gee.html#initialize-the-home-folder.\"\n", + " \n", + "authenticate_gee()\n" + ] + }, { "cell_type": "markdown", "metadata": {},