Skip to content

append, instead of rewriting, CSVLogger#3179

Merged
MMathisLab merged 1 commit intoDeepLabCut:mainfrom
juan-cobos:csvlogger_append
Jan 13, 2026
Merged

append, instead of rewriting, CSVLogger#3179
MMathisLab merged 1 commit intoDeepLabCut:mainfrom
juan-cobos:csvlogger_append

Conversation

@juan-cobos
Copy link
Copy Markdown
Contributor

closes issue #3176

@MMathisLab MMathisLab requested a review from deruyter92 January 13, 2026 16:05
@MMathisLab MMathisLab merged commit dd5366e into DeepLabCut:main Jan 13, 2026
7 of 10 checks passed
@juan-cobos juan-cobos deleted the csvlogger_append branch January 13, 2026 16:16
@deruyter92
Copy link
Copy Markdown
Collaborator

@juan-cobos, wouldn't this solution cause duplicate headers to be written to the CSV file? I think it might be better to handle the existing file first no?

@MMathisLab, what do you think?

@juan-cobos
Copy link
Copy Markdown
Contributor Author

juan-cobos commented Jan 15, 2026

@deruyter92 Yep, it stores headers each time. It depends if you want to keep a reference of last save. If not, in case file exists, we should append [1:] (without headers). Thank you for spotting it!

PS: WandbLogger is also overwriting at the moment :)

@deruyter92
Copy link
Copy Markdown
Collaborator

We should probably revert this merge!

See attached the CSV file generated with 5 epochs of training + another 5 epochs after resuming from the saved weights.
learning_stats.csv
The header is saved each time. When more metrics are added (e.g. during evaluation), the CSV completely breaks, because of mismatching columns.

deruyter92 added a commit to deruyter92/DeepLabCut that referenced this pull request Jan 16, 2026
The header and previous rows are appended for every save call. This in unintended behavior.

- changing back to 'write' mode instead of 'append' mode
@juan-cobos
Copy link
Copy Markdown
Contributor Author

@deruyter92 wow that looks really bad, sorry. Could you try without appending headers? I cannot test training at the moment. Otherwise, what would you suggest? Creating directly another file in case headers mismatch? Thank you for your follow-up!

@deruyter92
Copy link
Copy Markdown
Collaborator

No problem, would have been a good suggestion if the CSVLogger didn't write all metrics every save call, but it actually keeps a store of all previous runs as well. I opened a PR to revert the change, so should be recovered quickly.

My suggestion is to read the previously saved metrics in existing CSV into the loggers metric store, e.g. something in the line of #3177.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants