diff --git a/00_core.ipynb b/00_core.ipynb index 521a4a6..8ffdebd 100644 --- a/00_core.ipynb +++ b/00_core.ipynb @@ -70,30 +70,18 @@ "outputs": [], "source": [ "#|export\n", - "def colab_gee_setup():\n", - " \"\"\"Setup Colab so it can use the earthengine-jupyter package.\n", + "def authenticate_if_needed():\n", + " \"\"\"Authenticate Earth Engine, if credentials do not exist.\n", " \n", - " * Install earthengine-jupyter package.\n", " * Authenticate, if needed.\"\"\"\n", " \n", " import ee\n", " import os\n", - "\n", - " print('Verifying environment is setup for earthengine-jupyter...')\n", - " \n", - " try:\n", - " import ee_jupyter\n", - " print('\\N{check mark} The package earthengine-jupyter is already installed.')\n", - " except ModuleNotFoundError:\n", - " print('\\N{check mark} Installing earthengine-jupyter...')\n", - " result = os.system('pip -q install earthengine-jupyter')\n", " \n", " if os.path.exists(ee.oauth.get_credentials_path()):\n", " print('\\N{check mark} Authentication credentials were found.')\n", " else:\n", - " ee.Authenticate()\n", - "\n", - " print('\\N{check mark} Done.')" + " ee.Authenticate()" ] }, { @@ -106,15 +94,12 @@ "name": "stdout", "output_type": "stream", "text": [ - "Verifying environment is setup for earthengine-jupyter...\n", - "✓ The package earthengine-jupyter is already installed.\n", - "✓ Authentication credentials were found.\n", - "✓ Done.\n" + "✓ Authentication credentials were found.\n" ] } ], "source": [ - "colab_gee_setup()" + "authenticate_if_needed()" ] }, { diff --git a/ee_jupyter/_modidx.py b/ee_jupyter/_modidx.py index b4be5b7..a8cd4dc 100644 --- a/ee_jupyter/_modidx.py +++ b/ee_jupyter/_modidx.py @@ -5,7 +5,7 @@ 'doc_host': 'https://googlestaging.github.io', 'git_url': 'https://github.com/googlestaging/earthengine-jupyter', 'lib_path': 'ee_jupyter'}, - 'syms': { 'ee_jupyter.core': {'ee_jupyter.core.colab_gee_setup': ('core.html#colab_gee_setup', 'ee_jupyter/core.py')}, + 'syms': { 'ee_jupyter.core': {'ee_jupyter.core.authenticate_if_needed': ('core.html#authenticate_if_needed', 'ee_jupyter/core.py')}, 'ee_jupyter.ipyleaflet': { 'ee_jupyter.ipyleaflet.Inspector': ('ipyleaflet.html#inspector', 'ee_jupyter/ipyleaflet.py'), 'ee_jupyter.ipyleaflet.Inspector.__init__': ( 'ipyleaflet.html#inspector.__init__', 'ee_jupyter/ipyleaflet.py'), diff --git a/ee_jupyter/core.py b/ee_jupyter/core.py index b1ee279..997094a 100644 --- a/ee_jupyter/core.py +++ b/ee_jupyter/core.py @@ -1,30 +1,18 @@ # AUTOGENERATED! DO NOT EDIT! File to edit: ../00_core.ipynb. # %% auto 0 -__all__ = ['colab_gee_setup'] +__all__ = ['authenticate_if_needed'] # %% ../00_core.ipynb 5 -def colab_gee_setup(): - """Setup Colab so it can use the earthengine-jupyter package. +def authenticate_if_needed(): + """Authenticate Earth Engine, if credentials do not exist. - * Install earthengine-jupyter package. * Authenticate, if needed.""" import ee import os - - print('Verifying environment is setup for earthengine-jupyter...') - - try: - import ee_jupyter - print('\N{check mark} The package earthengine-jupyter is already installed.') - except ModuleNotFoundError: - print('\N{check mark} Installing earthengine-jupyter...') - result = os.system('pip -q install earthengine-jupyter') if os.path.exists(ee.oauth.get_credentials_path()): print('\N{check mark} Authentication credentials were found.') else: ee.Authenticate() - - print('\N{check mark} Done.') diff --git a/index.ipynb b/index.ipynb index 30a09f3..a9070fc 100644 --- a/index.ipynb +++ b/index.ipynb @@ -48,6 +48,35 @@ "**NOTICE: This is an experimental project and is not an officially supported Google project. You are welcome to use it, but we do not guarantee stability.**" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Setup" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Make sure that the earthengine-jupyter package is installed...\n" + ] + } + ], + "source": [ + "print('Make sure that the earthengine-jupyter package is installed...')\n", + "try:\n", + " import ee_jupyter\n", + "except ModuleNotFoundError:\n", + " import os\n", + " result = os.system('pip -q install earthengine-jupyter')" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -69,7 +98,7 @@ "outputs": [], "source": [ "import ee\n", - "from ee_jupyter.core import colab_gee_setup\n", + "from ee_jupyter.core import authenticate_if_needed\n", "from ee_jupyter.ipyleaflet import Map" ] }, @@ -82,15 +111,12 @@ "name": "stdout", "output_type": "stream", "text": [ - "Verifying environment is setup for earthengine-jupyter...\n", - "✓ The package earthengine-jupyter is already installed.\n", - "✓ Authentication credentials were found.\n", - "✓ Done.\n" + "✓ Authentication credentials were found.\n" ] } ], "source": [ - "colab_gee_setup()" + "authenticate_if_needed()" ] }, { @@ -111,7 +137,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "d878454fc87641d19f73cccd7eaaf025", + "model_id": "df4163a7f7184170a32cc03c965cd04f", "version_major": 2, "version_minor": 0 }, @@ -166,7 +192,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "5746ef56f682462a89534aaa96969577", + "model_id": "d30267e4c6cf4dae9c4042049209f238", "version_major": 2, "version_minor": 0 }, @@ -201,7 +227,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "9b76973a611d4684a21065935eea2859", + "model_id": "3b04e9f3577b4778a04a8abe00300ae8", "version_major": 2, "version_minor": 0 }, @@ -270,11 +296,6 @@ "\n", "Image(url=url, format='png', embed=True)" ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [] } ], "metadata": {