From dd1342b944d5e06b211422351e952a9403d38a1c Mon Sep 17 00:00:00 2001 From: Christopher Brix Date: Fri, 15 Sep 2023 17:11:24 -0400 Subject: [PATCH] Fix default value of end_time in update_end_time Using `time.time()` in the definition of the method would freeze the default to the time at the definition. Defining it in the body allows to query the current time when the method is called. --- smdebug/pytorch/hook.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/smdebug/pytorch/hook.py b/smdebug/pytorch/hook.py index a549131d4..551734132 100644 --- a/smdebug/pytorch/hook.py +++ b/smdebug/pytorch/hook.py @@ -61,7 +61,9 @@ def __init__(self, phase, op_name, start_time, dur, **kwargs): self.op_name = op_name self.kwargs = kwargs - def update_end_time(self, end_time=time.time()): + def update_end_time(self, end_time=None): + if end_time is None: + end_time = time.time() self.end_time = end_time @error_handling_agent.catch_smdebug_errors()