AssetSelect#

Overview#

AssetSelect is a field widget to search for asset in the user GEE root folder. it inherits from the SepalWidget class. Any argument from the original Combobox ipyvuetify class can be used to complement it.

from sepal_ui import sepalwidgets as sw

# correct colors for the documentation
# set to dark in SEPAL by default
import ipyvuetify as v
v.theme.dark = False

# to allow the build of the doc in a distanct server
FOLDER = "projects/earthengine-legacy/assets/users/bornToBeAlive/sepal_ui_test"

asset_select = sw.AssetSelect(folder=FOLDER)
asset_select
---------------------------------------------------------------------------
JSONDecodeError                           Traceback (most recent call last)
File ~/checkouts/readthedocs.org/user_builds/sepal-ui/checkouts/latest/sepal_ui/scripts/decorator.py:150, in need_ee.<locals>.wrapper_ee(*args, **kwargs)
    149 try:
--> 150     init_ee()
    151 except Exception:

File ~/checkouts/readthedocs.org/user_builds/sepal-ui/checkouts/latest/sepal_ui/scripts/decorator.py:55, in init_ee()
     53 # if the user is in local development the authentication should
     54 # already be available
---> 55 ee.Initialize(http_transport=httplib2.Http())
     56 assert len(ee.data.getAssetRoots()) > 0, ms.utils.ee.no_asset_root

File ~/checkouts/readthedocs.org/user_builds/sepal-ui/envs/latest/lib/python3.10/site-packages/ee/_utils.py:38, in accept_opt_prefix.<locals>.opt_fixed.<locals>.wrapper(*args, **kwargs)
     37       kwargs[new_key] = old_key_val
---> 38 return func(*args, **kwargs)

File ~/checkouts/readthedocs.org/user_builds/sepal-ui/envs/latest/lib/python3.10/site-packages/ee/__init__.py:150, in Initialize(credentials, url, cloud_api_key, http_transport, project)
    149 if credentials == 'persistent':
--> 150   credentials = data.get_persistent_credentials()
    151 if not project and credentials and hasattr(credentials, 'quota_project_id'):

File ~/checkouts/readthedocs.org/user_builds/sepal-ui/envs/latest/lib/python3.10/site-packages/ee/data.py:252, in get_persistent_credentials()
    251 try:
--> 252   args = oauth.get_credentials_arguments()
    253 except IOError:

File ~/checkouts/readthedocs.org/user_builds/sepal-ui/envs/latest/lib/python3.10/site-packages/ee/oauth.py:85, in get_credentials_arguments()
     84 with open(get_credentials_path()) as creds:
---> 85   stored = json.load(creds)
     86   args = {}

File ~/.asdf/installs/python/3.10.13/lib/python3.10/json/__init__.py:293, in load(fp, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
    276 """Deserialize ``fp`` (a ``.read()``-supporting file-like object containing
    277 a JSON document) to a Python object.
    278 
   (...)
    291 kwarg; otherwise ``JSONDecoder`` is used.
    292 """
--> 293 return loads(fp.read(),
    294     cls=cls, object_hook=object_hook,
    295     parse_float=parse_float, parse_int=parse_int,
    296     parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)

File ~/.asdf/installs/python/3.10.13/lib/python3.10/json/__init__.py:346, in loads(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
    343 if (cls is None and object_hook is None and
    344         parse_int is None and parse_float is None and
    345         parse_constant is None and object_pairs_hook is None and not kw):
--> 346     return _default_decoder.decode(s)
    347 if cls is None:

File ~/.asdf/installs/python/3.10.13/lib/python3.10/json/decoder.py:337, in JSONDecoder.decode(self, s, _w)
    333 """Return the Python representation of ``s`` (a ``str`` instance
    334 containing a JSON document).
    335 
    336 """
--> 337 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
    338 end = _w(s, end).end()

File ~/.asdf/installs/python/3.10.13/lib/python3.10/json/decoder.py:355, in JSONDecoder.raw_decode(self, s, idx)
    354 except StopIteration as err:
--> 355     raise JSONDecodeError("Expecting value", s, err.value) from None
    356 return obj, end

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Exception                                 Traceback (most recent call last)
Cell In[1], line 11
      8 # to allow the build of the doc in a distanct server
      9 FOLDER = "projects/earthengine-legacy/assets/users/bornToBeAlive/sepal_ui_test"
---> 11 asset_select = sw.AssetSelect(folder=FOLDER)
     12 asset_select

File ~/checkouts/readthedocs.org/user_builds/sepal-ui/checkouts/latest/sepal_ui/scripts/decorator.py:152, in need_ee.<locals>.wrapper_ee(*args, **kwargs)
    150     init_ee()
    151 except Exception:
--> 152     raise Exception("This function needs an Earth Engine authentication")
    154 return func(*args, **kwargs)

Exception: This function needs an Earth Engine authentication

the value can be retrieve from the v_model trait.

Note

More information can be found here.