Daniele Castellana commited on
Commit
4625f74
·
1 Parent(s): ea3859b

Incorporate deployment to streamlit cloud (#4)

Browse files

* Add new way of authenticating into GEE

* update ee initialise method

* add check pwd

* add os.environ

* create unique way of authentication

Files changed (1) hide show
  1. app/src/utils_ee.py +13 -2
app/src/utils_ee.py CHANGED
@@ -1,9 +1,20 @@
1
  """Module for ee-related functionalities."""
 
 
2
  import ee
3
  import streamlit as st
 
 
4
 
5
 
6
- @st.cache
7
  def ee_initialize():
8
  """Initialise Google Earth Engine."""
9
- ee.Initialize()
 
 
 
 
 
 
 
 
1
  """Module for ee-related functionalities."""
2
+ import os
3
+
4
  import ee
5
  import streamlit as st
6
+ from ee import oauth
7
+ from google.oauth2 import service_account
8
 
9
 
10
+ @st.experimental_memo
11
  def ee_initialize():
12
  """Initialise Google Earth Engine."""
13
+ if "HOSTNAME" in os.environ and os.environ["HOSTNAME"] == "streamlit":
14
+ service_account_keys = st.secrets["ee_keys"]
15
+ credentials = service_account.Credentials.from_service_account_info(
16
+ service_account_keys, scopes=oauth.SCOPES
17
+ )
18
+ ee.Initialize(credentials)
19
+ else:
20
+ ee.Initialize()