Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions lithops/job/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,6 @@ def _create_job(
"""
Creates a new Job
"""
global FUNCTION_CACHE

ext_env = {} if extra_env is None else extra_env.copy()
if ext_env:
ext_env = utils.convert_bools_to_string(ext_env)
Expand Down
13 changes: 5 additions & 8 deletions lithops/serverless/backends/gcp_functions/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,14 @@
RUNTIME_MEMORY_MAX = 8192 # 8GB
RUNTIME_MEMORY_OPTIONS = {128, 256, 512, 1024, 2048, 4096, 8192}

RETRIES = 5
RETRY_SLEEP = 20

AVAILABLE_PY_RUNTIMES = {
'3.7': 'python37',
'3.8': 'python38',
'3.9': 'python39',
'3.10': 'python310',
'3.11': 'python311',
'3.12': 'python312'
'3.12': 'python312',
'3.13': 'python313'
}

USER_RUNTIMES_PREFIX = 'lithops.user_runtimes'
Expand All @@ -49,7 +47,9 @@
'max_workers': 1000,
'worker_processes': 1,
'invoke_pool_threads': 1000,
'trigger': 'pub/sub'
'trigger': 'pub/sub',
'retries': 5,
'retry_sleep': 10
}

REQUIREMENTS_FILE = """
Expand Down Expand Up @@ -103,8 +103,5 @@ def load_config(config_data=None):
if config_data['gcp_functions']['runtime_memory'] > RUNTIME_MEMORY_MAX:
config_data['gcp_functions']['runtime_memory'] = RUNTIME_MEMORY_MAX

config_data['gcp_functions']['retries'] = RETRIES
config_data['gcp_functions']['retry_sleep'] = RETRY_SLEEP

if 'region' not in config_data['gcp']:
config_data['gcp']['region'] = config_data['gcp_functions']['region']
17 changes: 13 additions & 4 deletions lithops/serverless/backends/gcp_functions/gcp_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,19 @@ def _create_function(self, runtime_name, memory, timeout=60):
'failurePolicy': {}
}

operation = self._api_resource.projects().locations().functions().create(
location=self._default_location,
body=cloud_function
).execute(num_retries=self.num_retries)
logger.info(f'Deploying function {function_location}')
for attempt in range(self.num_retries):
try:
operation = self._api_resource.projects().locations().functions().create(
location=self._default_location,
body=cloud_function
).execute()
break
except Exception as e:
if attempt < self.num_retries - 1:
time.sleep(self.retry_sleep)
else:
raise Exception(f"Failed to create Cloud Function after {self.num_retries} attempts.") from e

# Wait until the function is completely deployed
logger.info('Waiting for the function to be deployed')
Expand Down
2 changes: 0 additions & 2 deletions lithops/serverless/backends/k8s/entry_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@

@proxy.route('/get-range/<jobkey>/<total_calls>/<chunksize>', methods=['GET'])
def get_range(jobkey, total_calls, chunksize):
global JOB_INDEXES

range_start = 0 if jobkey not in JOB_INDEXES else JOB_INDEXES[jobkey]
range_end = min(range_start + int(chunksize), int(total_calls))
JOB_INDEXES[jobkey] = range_end
Expand Down
3 changes: 0 additions & 3 deletions lithops/standalone/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,6 @@ def notify_task_done(job_key, call_id):


def redis_queue_consumer(pid, work_queue_name, exec_mode, backend):
global worker_threads

worker_threads[pid]['status'] = WorkerStatus.IDLE.value

logger.info(f"Redis consumer process {pid} started")
Expand Down Expand Up @@ -213,7 +211,6 @@ def redis_queue_consumer(pid, work_queue_name, exec_mode, backend):
def run_worker():
global redis_client
global budget_keeper
global worker_threads

os.makedirs(LITHOPS_TEMP_DIR, exist_ok=True)

Expand Down
3 changes: 0 additions & 3 deletions lithops/storage/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,9 +462,6 @@ def get_runtime_meta(self, key):
:param runtime: name of the runtime
:return: runtime metadata
"""

global RUNTIME_META_CACHE

path = [RUNTIMES_PREFIX, key + ".meta.json"]
filename_local_path = os.path.join(CACHE_DIR, *path)

Expand Down