Write CSV Header only if the file is not empty to prevent duplicate headers upon restoration from pre-emption.
@@ -118,6 +118,8 @@ class CSVLogger(base.Logger):
fields = sorted(data.keys())
self._writer = csv.DictWriter(self._file, fieldnames=fields,
extrasaction='ignore')
+ # Write header only if the file is empty.
+ if not self._file.tell():
self._writer.writeheader()
self._writer.writerow(data)
