Skip to content

Commit

Permalink
fix: drop the gee connection in the documentation (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
12rambau authored Mar 4, 2024
2 parents 9e5aa12 + 177a888 commit bcc3466
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 44 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/unit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ on:
- main
pull_request:

env:
EARTHENGINE_TOKEN: ${{ secrets.EARTHENGINE_TOKEN }}

jobs:
lint:
runs-on: ubuntu-latest
Expand Down
40 changes: 0 additions & 40 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
"""Configuration file for the Sphinx documentation builder."""

import os
import re

# -- Path setup ----------------------------------------------------------------
from datetime import datetime
from pathlib import Path

import ee
import httplib2

package_path = os.path.abspath("../..")
os.environ["PYTHONPATH"] = ":".join((package_path, os.environ.get("PYTHONPATH", "")))
Expand Down Expand Up @@ -110,41 +105,6 @@
# -- Options for autosectionlabel ----------------------------------------------
autosectionlabel_prefix_document = True

# -- Script to authenticate to Earthengine using a token -----------------------
def gee_configure() -> None:
"""Initialize earth engine according to the environment.
It will use the creddential file if the EARTHENGINE_TOKEN env variable exist.
Otherwise it use the simple Initialize command (asking the user to register if necessary).
"""
# only do the initialization if the credential are missing
if not ee.data._credentials:

# if the credentials token is asved in the environment use it
if "EARTHENGINE_TOKEN" in os.environ:

# get the token from environment variable
ee_token = os.environ["EARTHENGINE_TOKEN"]

# as long as RDT quote the token, we need to remove the quotes before writing
# the string to the file
pattern = r"^'[^']*'$"
if re.match(pattern, ee_token) is not None:
ee_token = ee_token[1:-1]

# write the token to the appropriate folder
credential_folder_path = Path.home() / ".config" / "earthengine"
credential_folder_path.mkdir(parents=True, exist_ok=True)
credential_file_path = credential_folder_path / "credentials"
credential_file_path.write_text(ee_token)

# if the user is in local development the authentication should
# already be available
ee.Initialize(http_transport=httplib2.Http())


gee_configure()

# -- Options for intersphinx ---------------------------------------------------
intersphinx_mapping = {
"python": ("https://docs.python.org/3", None),
Expand Down
2 changes: 1 addition & 1 deletion docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ The GADM dataset are describing the geometry of administrative areas in high-res
Use the :code:`simplify` method from GeoPandas (more information `here <https://geopandas.org/en/stable/docs/reference/api/geopandas.GeoSeries.simplify.html>`__) to downscale the resolution of the geometries. The following example is needed if you want to work with France:

.. jupyter-execute::
.. code-block:: python
import pygadm
import geemap
Expand Down

0 comments on commit bcc3466

Please sign in to comment.