From cea886b61995b08d2fe2ca8b21f476e10d5eb536 Mon Sep 17 00:00:00 2001 From: Taha Yassine Kraiem Date: Wed, 12 Apr 2023 14:07:47 +0100 Subject: [PATCH] feat(chalice): debugging jobs execution --- api/chalicelib/core/jobs.py | 6 ------ api/chalicelib/utils/s3.py | 3 +++ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/api/chalicelib/core/jobs.py b/api/chalicelib/core/jobs.py index 88554e314..0c78859be 100644 --- a/api/chalicelib/core/jobs.py +++ b/api/chalicelib/core/jobs.py @@ -111,19 +111,13 @@ def get_scheduled_jobs(): WHERE status = %(status)s AND start_at <= (now() at time zone 'utc');""", {"status": JobStatus.SCHEDULED}) - print(query) cur.execute(query=query) data = cur.fetchall() - print(">>>") - print(data) return helper.list_to_camel_case(data) def execute_jobs(): - print(">>> looking for jobs to execute") jobs = get_scheduled_jobs() - print(jobs) - for job in jobs: print(f"Executing jobId:{job['jobId']}") try: diff --git a/api/chalicelib/utils/s3.py b/api/chalicelib/utils/s3.py index 655628602..d1acff558 100644 --- a/api/chalicelib/utils/s3.py +++ b/api/chalicelib/utils/s3.py @@ -110,11 +110,14 @@ def rename(source_bucket, source_key, target_bucket, target_key): def schedule_for_deletion(bucket, key): + if not exists(bucket, key): + return False s3 = __get_s3_resource() s3_object = s3.Object(bucket, key) s3_object.copy_from(CopySource={'Bucket': bucket, 'Key': key}, Expires=datetime.now() + timedelta(days=7), MetadataDirective='REPLACE') + return True def generate_file_key(project_id, key):