Skip to content

Commit 9f8189e

Browse files
committed
Merge pull request #1054 from rizar/more_logging_for_checkpointing
More logging for checkpointing
2 parents 5a88107 + de17a2b commit 9f8189e

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

blocks/extensions/saveload.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ def do(self, callback_name, *args):
7474
construction stage.
7575
7676
"""
77+
logger.info("Checkpointing has started")
7778
_, from_user = self.parse_args(callback_name, args)
7879
try:
7980
path = self.path
@@ -101,6 +102,7 @@ def do(self, callback_name, *args):
101102
already_saved_to = self.main_loop.log.current_row.get(SAVED_TO, ())
102103
self.main_loop.log.current_row[SAVED_TO] = (already_saved_to +
103104
(path,))
105+
logger.info("Checkpointing has finished")
104106

105107

106108
class Load(TrainingExtension):

blocks/serialization.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
import tarfile
114114
import tempfile
115115
import warnings
116+
import logging
116117

117118
from contextlib import closing
118119
from pickle import HIGHEST_PROTOCOL
@@ -133,6 +134,8 @@
133134
from blocks.utils import change_recursion_limit
134135

135136

137+
logger = logging.getLogger(__name__)
138+
136139
BRICK_DELIMITER = '|'
137140
MAIN_MODULE_WARNING = """WARNING: Main loop depends on the function `{}` in \
138141
`__main__` namespace.
@@ -215,10 +218,13 @@ def secure_dump(object_, path, dump_function=dump, **kwargs):
215218
216219
"""
217220
try:
221+
logger.debug("Dumping object to a temporary file")
218222
with tempfile.NamedTemporaryFile(delete=False,
219223
dir=config.temp_dir) as temp:
220224
dump_function(object_, temp, **kwargs)
225+
logger.debug("Moving the temporary file")
221226
shutil.move(temp.name, path)
227+
logger.debug("Dump finished")
222228
except:
223229
if "temp" in locals():
224230
os.remove(temp.name)

0 commit comments

Comments
 (0)