mirror of
https://github.com/sbrl/research-rainfallradar
synced 2024-11-22 09:13:01 +00:00
CallbackNBatchCsv: open_handle mode
This commit is contained in:
parent
3206d6b7e7
commit
1375201c5f
2 changed files with 5 additions and 2 deletions
|
@ -9,7 +9,7 @@ class CallbackNBatchCsv(tf.keras.callbacks.Callback):
|
||||||
self.n_batches = n_batches
|
self.n_batches = n_batches
|
||||||
self.separator = separator
|
self.separator = separator
|
||||||
|
|
||||||
self.handle = handle_open(filepath)
|
self.handle = handle_open(filepath, "w")
|
||||||
|
|
||||||
|
|
||||||
self.batches_seen = 0
|
self.batches_seen = 0
|
||||||
|
|
|
@ -2,7 +2,10 @@ import io
|
||||||
import gzip
|
import gzip
|
||||||
|
|
||||||
|
|
||||||
def handle_open(filepath, mode):
|
def handle_open(filepath, mode, force_textwrite_gzip=True):
|
||||||
|
if mode == "w" and mode.endswith(".gz") and force_textwrite_gzip:
|
||||||
|
mode = "wt"
|
||||||
|
|
||||||
if filepath.endswith(".gz"):
|
if filepath.endswith(".gz"):
|
||||||
return gzip.open(filepath, mode)
|
return gzip.open(filepath, mode)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue