Add retain-output argument (#145921)

This PR add retain-output argument which enables appending to the already existing output file if it exists instead of deleting it and creating a new one.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/145921
Approved by: https://github.com/jansel
This commit is contained in:
Katarzyna Fojcik 2025-02-05 19:45:06 +00:00 committed by PyTorch MergeBot
parent dd349207c5
commit 9da376daa6

View file

@ -3229,6 +3229,13 @@ def parse_args(args=None):
help="Enables Memory Snapshot tool for memory deep dives: https://pytorch.org/blog/understanding-gpu-memory-1/",
)
parser.add_argument(
"--retain-output",
action="store_true",
help="Enables appending to the already existing output file if it exists \
instead of deleting it and creating a new one.",
)
group_latency = parser.add_mutually_exclusive_group()
group_latency.add_argument(
"--cold-start-latency",
@ -4078,7 +4085,11 @@ def run(runner, args, original_dir=None):
)
else:
metrics.purge_old_log_files()
if output_filename and os.path.exists(output_filename):
if (
output_filename
and os.path.exists(output_filename)
and not args.retain_output
):
os.unlink(output_filename)
if original_dir:
os.chdir(original_dir)