Skip to content

Overwriting output files if they already exist #828

@rtpg

Description

@rtpg

Is there an existing proposal for this?

  • I have searched the existing proposals

Is your feature request related to a problem?

If I put something like:

with memray.Tracker("out.bin"):
    .... # do thing

in a script, the first time I run it memray will glady write out to out.bin. The second time I run it, memray complains about out.bin already existing. So I need to throw in a Path("out.bin").unlink(error_ok=True) to have my script run the first and subsequent times.

This is also true on CLI invocations like memray run -o out.bin ... and memray flamegraph -o report.html ...

Describe the solution you'd like

If I specify an output file that already exists, I would expect it to "just" overwrite it! This is how many other "write profiling/debugging results to disk" utilities work, generally on the assumption that you run it over and over again.

"I have accidentally stated an existing file" seems like a rare occurence compared to "I would like to write to the same path with fresh data". To me anyways.

Alternatives you considered

Having some flags would also do the trick for me though it seems like "learning about the flag and using it" is its own little set of weirdness

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions