Torch.save() fails to update timestamp?

I use torch.save(model, file_name) to save my model after each training epoch, but the timestamp of the saved file is set the first time, and not updated when it saves again. Not a huge problem, of course, but is this a small bug? Could be an OS issue (Win 10), I guess.

I cannot reproduce this issue in Windows10 using this small code snippet:

torch.save(torch.randn(1), 'tmp.pt')

and see the time stamp gets updated in the file explorer.

Thanks. The relevant test would be this:

torch.save(torch.randn(1), ‘tmp.pt’)
time.sleep(60)
torch.save(torch.randn(1), ‘tmp.pt’)

My file explorer keeps showing the first creation time, even though the file attributes are updated, so I guess it’s not a Python problem.

Alternatively, I could have waited a minute. :wink:

Anyway, to be super strict, here is another code snippet, which shows the modification time stamp:

name = 'tmp1.pt'
torch.save(torch.randn(1), name)
print("Last modified: %s" % time.ctime(os.path.getmtime(name)))
print("Created: %s" % time.ctime(os.path.getctime(name)))
> Last modified: Tue Aug  4 16:39:44 2020
Created: Tue Aug  4 16:39:44 2020

time.sleep(60)
torch.save(torch.randn(1), name)
print("Last modified: %s" % time.ctime(os.path.getmtime(name)))
print("Created: %s" % time.ctime(os.path.getctime(name)))
> Last modified: Tue Aug  4 16:40:44 2020
Created: Tue Aug  4 16:39:44 2020