From c55d6e4e10ce2d9c37e5f677f0842b04ef8b73f3 Mon Sep 17 00:00:00 2001 From: Rahul A R Date: Wed, 24 Aug 2022 12:12:42 -0400 Subject: [PATCH] examples/run_summarization_no_trainer: fixed incorrect param to hasattr (#18720) * fixed incorrect param to hasattr * simplified condition checks * code cleanup --- .../summarization/run_summarization_no_trainer.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/examples/pytorch/summarization/run_summarization_no_trainer.py b/examples/pytorch/summarization/run_summarization_no_trainer.py index b75b4bf7d4c..89365b4de4e 100644 --- a/examples/pytorch/summarization/run_summarization_no_trainer.py +++ b/examples/pytorch/summarization/run_summarization_no_trainer.py @@ -573,12 +573,9 @@ def main(): args.num_train_epochs = math.ceil(args.max_train_steps / num_update_steps_per_epoch) # Figure out how many steps we should save the Accelerator states - if hasattr(args.checkpointing_steps, "isdigit"): - checkpointing_steps = args.checkpointing_steps - if args.checkpointing_steps.isdigit(): - checkpointing_steps = int(args.checkpointing_steps) - else: - checkpointing_steps = None + checkpointing_steps = args.checkpointing_steps + if checkpointing_steps is not None and checkpointing_steps.isdigit(): + checkpointing_steps = int(checkpointing_steps) # We need to initialize the trackers we use, and also store our configuration. # The trackers initializes automatically on the main process.