Git Product home page Git Product logo

Comments (8)

giswqs avatar giswqs commented on May 16, 2024 1

Yes, you need to use the token from .config/earthengine/credentials. Do NOT use the token you copy from the browser. It will not work.

Also, use geemap.ee_initialize() or geemap.Map() to initialize Earth Engine. Never use ee.Initialize() with a streamlit web app. It can't detect the secret and the initialization will fail.

As long as the web app is working properly, you can ignore the warning message.

from streamlit-geospatial.

giswqs avatar giswqs commented on May 16, 2024

Were you able to test the app locally?

from streamlit-geospatial.

pskoulgi avatar pskoulgi commented on May 16, 2024

I have not tried that, I went straight from forking to publishing on Streamlit. I'm new to this, I didn't think that step was necessary.

Will now try that step and report back.

from streamlit-geospatial.

giswqs avatar giswqs commented on May 16, 2024

If you did not it try it locally, how did you get the Earth Engine token? Make sure the app works fine locally before deploying it to the cloud.

from streamlit-geospatial.

pskoulgi avatar pskoulgi commented on May 16, 2024

I tried it locally, and it worked (screenshot of the local URL on a browser tab below).

[I think I got the app to work on the cloud—by using the token stored on my local machine instead of the one generated by following the link the build log on Streamlit takes me to. But, strangely, "client not initialized" error in the build log persists. More details below.]

image

Before trying it locally, I got the Earth Engine token by following the authorization link that came up in the "Manage app" build log for the app in my Streamlit. This is in the log I pasted in my message above, see screenshot below where I have highlighted it.

It did not give me the box to paste the token into, like it said it would. I went ahead and saved the token into the app's "Secrets". I thought it'll get picked up on rebooting the app, but that never happened, I get shown a (new) authorization link each time in the build log and I get the same errors.

githubss

On seeing that the app runs fine locally, I also took the token in my local machine (in my .config/earthengine/credentials) and saved that into my "Secrets" on Streamlit (they were not the same). With this, the app has started working.

But, strangely, the build log in "Manage app" on Streamlit hasn't stopped saying "Earth Engine client library not initialized. Run ee.Initialize()"

With the app now started to work, perhaps I can ignore this message and move on—or would that be inadvisible, any suggestions?

The last few lines of the log copied over, are as follows:

WARNING: You are using pip version 22.0.3; however, version 22.1 is available.
You should consider upgrading via the '/home/appuser/venv/bin/python -m pip install --upgrade pip' command.
[manager] Python dependencies were installed from /app/streamlit-geospatial/requirements.txt using pip.
Check if streamlit is installed
Streamlit is already installed
[manager] Processed dependencies!
2022-05-20 08:40:56.344 Uncaught app exception
Traceback (most recent call last):
  File "/home/appuser/venv/lib/python3.7/site-packages/streamlit/scriptrunner/script_runner.py", line 475, in _run_script
    exec(code, module.__dict__)
  File "/app/streamlit-geospatial/app.py", line 47, in <module>
    apps.run()
  File "/app/streamlit-geospatial/multiapp.py", line 64, in run
    functions[titles.index(title)]()
  File "/app/streamlit-geospatial/apps/gee_datasets.py", line 182, in app
    eval(datasets[category][dataset])
  File "<string>", line 1, in <module>
  File "/app/streamlit-geospatial/apps/gee_datasets.py", line 75, in global_mangrove_watch
    gmw2007 = ee.FeatureCollection("projects/sat-io/open-datasets/GMW/GMW_2007_v2")
  File "/home/appuser/venv/lib/python3.7/site-packages/ee/computedobject.py", line 32, in __call__
    return type.__call__(cls, *args, **kwargs)
  File "/home/appuser/venv/lib/python3.7/site-packages/ee/featurecollection.py", line 44, in __init__
    self.initialize()
  File "/home/appuser/venv/lib/python3.7/site-packages/ee/featurecollection.py", line 91, in initialize
    super(FeatureCollection, cls).initialize()
  File "/home/appuser/venv/lib/python3.7/site-packages/ee/collection.py", line 32, in initialize
    apifunction.ApiFunction.importApi(cls, 'Collection', 'Collection')
  File "/home/appuser/venv/lib/python3.7/site-packages/ee/apifunction.py", line 183, in importApi
    cls.initialize()
  File "/home/appuser/venv/lib/python3.7/site-packages/ee/apifunction.py", line 154, in initialize
    signatures = data.getAlgorithms()
  File "/home/appuser/venv/lib/python3.7/site-packages/ee/data.py", line 1055, in getAlgorithms
    call = _get_cloud_api_resource().projects().algorithms().list(
  File "/home/appuser/venv/lib/python3.7/site-packages/ee/data.py", line 285, in _get_cloud_api_resource
    'Earth Engine client library not initialized. Run `ee.Initialize()`')
ee.ee_exception.EEException: Earth Engine client library not initialized. Run `ee.Initialize()`

from streamlit-geospatial.

pskoulgi avatar pskoulgi commented on May 16, 2024

After a gap of ~18 months, I sync'd with the source repo's master branch to pick up updates/changes. I am now seeing a ee.ee_exception.EEException: This app has encountered an error. error. Before this sync, I was getting a ERROR: THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE. in the "Manage App" logs on Streamlit, but thankfully the sync has made that go away, and I suspect the current issue has something to do with authentication again, so I'm coming back and reopening this issue..

I have checked that the app runs locally as well as when I run it in a GitHub Codespace (I have added my EARTHENGINE_TOKEN to the Codespace). I am unable to tell why the EE exception error is happening only on Streamlit Cloud. Help, please?

Links:

Screenchots to show app is running fine for me locally and on Codespaces:

image
onevizCodespacesScrSh

from streamlit-geospatial.

giswqs avatar giswqs commented on May 16, 2024

The authentication method has never changed.

from streamlit-geospatial.

pskoulgi avatar pskoulgi commented on May 16, 2024

If possible, it would be very helpful if could you suggest where I could look for why my app is not working on the cloud (Streamlit) alone. I'm unable to tell, and I'm not very proficient at this.

The most recent logs on "Manage App" on Streamlit is as follows. It is essentially the same as what appears in the map panel in the cloud app.

  • The line 106 it points to used to work, neither it nor the asset has changed.
  • It asks to run ee.Initialize(), but I had learnt (from earlier in this thread) that as long as the app runs I can ignore this.
ee.ee_exception.EEException: Earth Engine client library not initialized. Run `ee.Initialize()`
2023-10-31 11:40:14.944 Uncaught app exception
Traceback (most recent call last):
  File "/home/adminuser/venv/lib/python3.8/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 534, in _run_script
    exec(code, module.__dict__)
  File "/mount/src/streamlit-geospatial/app.py", line 131, in <module>
    app()
  File "/mount/src/streamlit-geospatial/app.py", line 106, in app
    oneLabelsCollapsedForViz = ee.Image("projects/ee-open-natural-ecosystems/assets/publish/onesWith7Classes/labelWithUncertAppliedONEStates")
  File "/home/adminuser/venv/lib/python3.8/site-packages/ee/computedobject.py", line 28, in __call__
    return type.__call__(cls, *args, **kwargs)
  File "/home/adminuser/venv/lib/python3.8/site-packages/ee/image.py", line 52, in __init__
    self.initialize()
  File "/home/adminuser/venv/lib/python3.8/site-packages/ee/image.py", line 98, in initialize
    apifunction.ApiFunction.importApi(cls, 'Image', 'Image')
  File "/home/adminuser/venv/lib/python3.8/site-packages/ee/apifunction.py", line 195, in importApi
    cls.initialize()
  File "/home/adminuser/venv/lib/python3.8/site-packages/ee/apifunction.py", line 160, in initialize
    signatures = data.getAlgorithms()
  File "/home/adminuser/venv/lib/python3.8/site-packages/ee/data.py", line 1388, in getAlgorithms
    _get_cloud_projects()
  File "/home/adminuser/venv/lib/python3.8/site-packages/ee/data.py", line 297, in _get_cloud_projects
    raise ee_exception.EEException(
ee.ee_exception.EEException: Earth Engine client library not initialized. Run `ee.Initialize()`

image

Thank you!

from streamlit-geospatial.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.