Skip to content

Commit

Permalink
Add a separation for failed-keys so that we can investigate failures …
Browse files Browse the repository at this point in the history
…outside of deprecated keys
  • Loading branch information
KaspariK committed Jan 9, 2025
1 parent 5a60f18 commit 56490b0
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions tools/pickles_to_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ def convert_pickles_to_json_and_update_table(
keys: List[str],
dry_run: bool = True,
keys_file: Optional[str] = None,
failed_keys_file: Optional[str] = None,
job_names: List[str] = [],
) -> None:
"""
Expand Down Expand Up @@ -309,9 +310,14 @@ def convert_pickles_to_json_and_update_table(

if keys_file:
with open(keys_file, "w") as f:
for key in failed_keys + delete_keys: # TODO: failed keys to separate file?
for key in delete_keys:
f.write(f"{key}\n")
print(f"Failed and delete keys have been written to {keys_file}")
print(f"Deprecated keys have been written to {keys_file}")
if failed_keys_file:
with open(failed_keys_file, "w") as f:
for key in failed_keys:
f.write(f"{key}\n")
print(f"Failed have been written to {failed_keys_file}")
if dry_run:
print("Dry run complete. No changes were made to the DynamoDB table.")

Expand Down Expand Up @@ -388,6 +394,11 @@ def main():
required=False,
help="File containing keys to perform the action on. One key per line. On dry run, failed keys will be written to this file.",
)
parser.add_argument(
"--failed-keys-file",
required=False,
help="File to write failed keys to in dry run.",
)
parser.add_argument(
"--all",
action="store_true",
Expand Down Expand Up @@ -425,7 +436,12 @@ def main():

if args.action == "convert":
convert_pickles_to_json_and_update_table(
source_table, keys=keys, dry_run=args.dry_run, keys_file=args.keys_file, job_names=job_names
source_table,
keys=keys,
dry_run=args.dry_run,
keys_file=args.keys_file,
failed_keys_file=args.failed_keys_file,
job_names=job_names,
)
elif args.action == "dump-pickle":
dump_pickle_keys(source_table, keys)
Expand Down

0 comments on commit 56490b0

Please sign in to comment.