Skip to content

Commit 5d0bf20

Browse files
committed
fix for GCP functions
1 parent 4605d3d commit 5d0bf20

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

lithops/constants.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,7 @@
111111
'aliyun_fc',
112112
'oracle_f',
113113
'k8s',
114-
'singularity',
115-
'iluvatar',
114+
'singularity'
116115
]
117116

118117
STANDALONE_BACKENDS = [

lithops/serverless/backends/gcp_functions/gcp_functions.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -244,26 +244,26 @@ def _create_function(self, runtime_name, memory, timeout=60):
244244
'failurePolicy': {}
245245
}
246246

247-
response = self._api_resource.projects().locations().functions().create(
247+
operation = self._api_resource.projects().locations().functions().create(
248248
location=self._default_location,
249249
body=cloud_function
250250
).execute(num_retries=self.num_retries)
251251

252252
# Wait until the function is completely deployed
253253
logger.info('Waiting for the function to be deployed')
254+
operation_name = operation['name']
254255
while True:
255-
response = self._api_resource.projects().locations().functions().get(
256-
name=function_location
256+
op_status = self._api_resource.operations().get(
257+
name=operation_name
257258
).execute(num_retries=self.num_retries)
258-
logger.debug(f'Function status is {response["status"]}')
259-
if response['status'] == 'ACTIVE':
259+
if op_status.get('done'):
260+
if 'error' in op_status:
261+
raise Exception(f'Error while deploying Cloud Function: {op_status["error"]}')
262+
logger.info("Deployment completed successfully.")
260263
break
261-
elif response['status'] == 'OFFLINE':
262-
raise Exception('Error while deploying Cloud Function')
263-
elif response['status'] == 'DEPLOY_IN_PROGRESS':
264-
time.sleep(self.retry_sleep)
265264
else:
266-
raise Exception(f"Unknown status {response['status']}")
265+
logger.debug("Deployment in progress, waiting...")
266+
time.sleep(self.retry_sleep)
267267

268268
def build_runtime(self, runtime_name, requirements_file, extra_args=[]):
269269
if not requirements_file:

lithops/serverless/backends/iluvatar/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)