Spaces:
Sleeping
Sleeping
castledan
commited on
Commit
·
c5cc81a
1
Parent(s):
e0805f4
let python find out if the app is deployed
Browse files- 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.
|
7 |
def ee_initialize():
|
8 |
"""Initialise Google Earth Engine."""
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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()
|