From ba09d81eaac48c8ae276155cc44a4a36df6d9a42 Mon Sep 17 00:00:00 2001 From: Aimee Stewart Date: Fri, 8 Nov 2024 17:19:50 -0600 Subject: [PATCH] linting --- aws/lambda/bison_s0_test_task.py | 2 +- aws/lambda/bison_s1_annotate_riis.py | 2 +- aws/lambda/bison_s2_load_ancillary.py | 2 +- aws/lambda/bison_s4_intersect_bison.py | 2 +- aws/lambda/bison_s5_assign_riis.py | 4 ++-- aws/lambda/bison_s6_aggregate_region.py | 6 +++--- aws/lambda/bison_s7_delete_obsolete.py | 5 ++--- 7 files changed, 11 insertions(+), 12 deletions(-) diff --git a/aws/lambda/bison_s0_test_task.py b/aws/lambda/bison_s0_test_task.py index 5cb63be..2cdd746 100644 --- a/aws/lambda/bison_s0_test_task.py +++ b/aws/lambda/bison_s0_test_task.py @@ -87,7 +87,7 @@ def lambda_handler(event, context): print(f"*** Error querying for bucket/object {annotated_riis_key} ({e})") raise e try: - _contents = tr_response["Contents"] + tr_response["Contents"] except KeyError: print(f"*** Object {annotated_riis_key} is not present") else: diff --git a/aws/lambda/bison_s1_annotate_riis.py b/aws/lambda/bison_s1_annotate_riis.py index 5594797..64bd5d9 100644 --- a/aws/lambda/bison_s1_annotate_riis.py +++ b/aws/lambda/bison_s1_annotate_riis.py @@ -83,7 +83,7 @@ def lambda_handler(event, context): print(f"*** Error querying for bucket/object {annotated_riis_key} ({e})") raise e try: - _contents = tr_response["Contents"] + tr_response["Contents"] except KeyError: print(f"*** Object {annotated_riis_key} is not present") else: diff --git a/aws/lambda/bison_s2_load_ancillary.py b/aws/lambda/bison_s2_load_ancillary.py index 920fe48..9717813 100644 --- a/aws/lambda/bison_s2_load_ancillary.py +++ b/aws/lambda/bison_s2_load_ancillary.py @@ -238,7 +238,7 @@ def lambda_handler(event, context): print(f"!!! Error querying for object {annotated_riis_key} ({e})") raise e try: - _contents = tr_response["Contents"] + tr_response["Contents"] except KeyError: raise Exception( f"!!! Missing annotated RIIS data: {annotated_riis_key}") diff --git a/aws/lambda/bison_s4_intersect_bison.py b/aws/lambda/bison_s4_intersect_bison.py index 0880ab8..6c4e273 100644 --- a/aws/lambda/bison_s4_intersect_bison.py +++ b/aws/lambda/bison_s4_intersect_bison.py @@ -263,7 +263,7 @@ def lambda_handler(event, context): else: try: name = records[0][2]["stringValue"] - except: + except Exception: success = False msg = f"!!! Unexpected query result {records}" else: diff --git a/aws/lambda/bison_s5_assign_riis.py b/aws/lambda/bison_s5_assign_riis.py index 8fb0732..6ae91e7 100644 --- a/aws/lambda/bison_s5_assign_riis.py +++ b/aws/lambda/bison_s5_assign_riis.py @@ -229,12 +229,12 @@ def lambda_handler(event, context): raise else: if cmd == "query_riis": - print(f"*** Assessment totals") + print("*** Assessment totals") # Query returns assesment, count as 1st and 2nd items in record for rec in records: try: print(f"*** {rec[0]['stringValue']}: {rec[1]['longValue']}") - except: + except Exception: print(f"!!! Unexpected record format {rec}") break diff --git a/aws/lambda/bison_s6_aggregate_region.py b/aws/lambda/bison_s6_aggregate_region.py index fde4dda..807d0bb 100644 --- a/aws/lambda/bison_s6_aggregate_region.py +++ b/aws/lambda/bison_s6_aggregate_region.py @@ -350,7 +350,7 @@ def lambda_handler(event, context): key = fullkey[prefix_len:-suffix_len] s3objs_present.append(key) print(f"*** {key}") - + # ------------------------------------- # SECOND: Check that current BISON data is in Redshift # NEXT: Execute remaining aggregation and export commmands in order @@ -422,8 +422,8 @@ def lambda_handler(event, context): tbl_name = rec[2]["stringValue"] tables_present.append(tbl_name) print(f"*** {tbl_name}") - except: - raise Exception(f"!!! Unexpected record result {rec}") + except Exception as e: + raise Exception(f"!!! Unexpected record result {rec}, {e}") return { "statusCode": 200, diff --git a/aws/lambda/bison_s7_delete_obsolete.py b/aws/lambda/bison_s7_delete_obsolete.py index 4e03bc8..74362b0 100644 --- a/aws/lambda/bison_s7_delete_obsolete.py +++ b/aws/lambda/bison_s7_delete_obsolete.py @@ -155,7 +155,6 @@ def lambda_handler(event, context): else: tbl_lst = new_tables - # ------------------------------------- # Submit query request try: @@ -221,7 +220,7 @@ def lambda_handler(event, context): # Determine which tables to remove print("*** ---------------------------------------") tables_to_remove = set(tmp_tables) - print("*** Tables to remove:" ) + print("*** Tables to remove:") print(f"*** {tmp_tables}") # Make sure new table exists before removing old table for old_tbl in old_tables: @@ -326,7 +325,7 @@ def lambda_handler(event, context): # ------------------------------------- # Determine which objects to remove from S3 print("*** ---------------------------------------") - print("*** Keys to remove:" ) + print("*** Keys to remove:") # Make sure new table exists before removing old table for old_key in old_keys: prefix = old_key[:-len(old_bison_datestr)]