Skip to content

Commit

Permalink
Merge pull request #1054 from rizar/more_logging_for_checkpointing
Browse files Browse the repository at this point in the history
More logging for checkpointing
  • Loading branch information
dwf committed Apr 8, 2016
2 parents 5a88107 + de17a2b commit 9f8189e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions blocks/extensions/saveload.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def do(self, callback_name, *args):
construction stage.
"""
logger.info("Checkpointing has started")
_, from_user = self.parse_args(callback_name, args)
try:
path = self.path
Expand Down Expand Up @@ -101,6 +102,7 @@ def do(self, callback_name, *args):
already_saved_to = self.main_loop.log.current_row.get(SAVED_TO, ())
self.main_loop.log.current_row[SAVED_TO] = (already_saved_to +
(path,))
logger.info("Checkpointing has finished")


class Load(TrainingExtension):
Expand Down
6 changes: 6 additions & 0 deletions blocks/serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
import tarfile
import tempfile
import warnings
import logging

from contextlib import closing
from pickle import HIGHEST_PROTOCOL
Expand All @@ -133,6 +134,8 @@
from blocks.utils import change_recursion_limit


logger = logging.getLogger(__name__)

BRICK_DELIMITER = '|'
MAIN_MODULE_WARNING = """WARNING: Main loop depends on the function `{}` in \
`__main__` namespace.
Expand Down Expand Up @@ -215,10 +218,13 @@ def secure_dump(object_, path, dump_function=dump, **kwargs):
"""
try:
logger.debug("Dumping object to a temporary file")
with tempfile.NamedTemporaryFile(delete=False,
dir=config.temp_dir) as temp:
dump_function(object_, temp, **kwargs)
logger.debug("Moving the temporary file")
shutil.move(temp.name, path)
logger.debug("Dump finished")
except:
if "temp" in locals():
os.remove(temp.name)
Expand Down

0 comments on commit 9f8189e

Please sign in to comment.