radwaamr1 commited on
Commit
3c08d9f
·
verified ·
1 Parent(s): 3227846

Upload realtime_pipeline.py

Browse files
Files changed (1) hide show
  1. realtime_pipeline.py +13 -3
realtime_pipeline.py CHANGED
@@ -100,15 +100,25 @@ class RealTimeFeatureExtractor:
100
 
101
  def _initialize_ee(self):
102
  try:
103
- os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = key_path
 
104
 
105
- ee.Initialize(project=Config.GEE_PROJECT_ID)
 
 
 
 
 
 
 
 
 
106
 
107
  self.logger.info("✅ Earth Engine initialized with Service Account")
108
  except Exception as e:
109
  self.logger.error(f"❌ Earth Engine failed: {e}")
110
  raise
111
-
112
  def compute_dewpoint(self, t_celsius, rh_percent):
113
  try:
114
  if t_celsius is None or rh_percent is None: return None
 
100
 
101
  def _initialize_ee(self):
102
  try:
103
+ if "GEE_KEY_BASE64" not in os.environ:
104
+ raise Exception("GEE_KEY_BASE64 secret not found")
105
 
106
+ # Decode secret and save as temporary JSON
107
+ key_b64 = os.environ["GEE_KEY_BASE64"]
108
+ key_json = base64.b64decode(key_b64)
109
+ key_path = "/tmp/gee-key.json"
110
+ with open(key_path, "wb") as f:
111
+ f.write(key_json)
112
+
113
+ # Use ServiceAccountCredentials
114
+ credentials = ServiceAccountCredentials(None, key_file=key_path)
115
+ ee.Initialize(credentials, project=Config.GEE_PROJECT_ID)
116
 
117
  self.logger.info("✅ Earth Engine initialized with Service Account")
118
  except Exception as e:
119
  self.logger.error(f"❌ Earth Engine failed: {e}")
120
  raise
121
+
122
  def compute_dewpoint(self, t_celsius, rh_percent):
123
  try:
124
  if t_celsius is None or rh_percent is None: return None