[tune] Remove slow gzip of checkpoints; ignore jupyter stop errors (#4076)

* fix gzip

* ignore jupyter
This commit is contained in:
Eric Liang
2019-02-18 01:30:13 -08:00
committed by GitHub
parent f8bef004da
commit 6e46d75554
2 changed files with 10 additions and 14 deletions
+2 -2
View File
@@ -422,8 +422,8 @@ def stop():
]
subprocess.call(
["kill -9 {} 2> /dev/null".format(" ".join(pids))], shell=True)
except ImportError:
pass
except Exception:
logger.exception("Error shutting down jupyter")
@cli.command()
+8 -12
View File
@@ -5,7 +5,6 @@ from __future__ import print_function
from datetime import datetime
import copy
import gzip
import io
import logging
import os
@@ -275,15 +274,13 @@ class Trainable(object):
data[os.path.basename(path)] = open(path, "rb").read()
out = io.BytesIO()
with gzip.GzipFile(fileobj=out, mode="wb") as f:
compressed = pickle.dumps({
"checkpoint_name": os.path.basename(checkpoint_prefix),
"data": data,
})
if len(compressed) > 10e6: # getting pretty large
logger.info("Checkpoint size is {} bytes".format(
len(compressed)))
f.write(compressed)
data_dict = pickle.dumps({
"checkpoint_name": os.path.basename(checkpoint_prefix),
"data": data,
})
if len(data_dict) > 10e6: # getting pretty large
logger.info("Checkpoint size is {} bytes".format(len(data_dict)))
out.write(data_dict)
shutil.rmtree(tmpdir)
return out.getvalue()
@@ -318,8 +315,7 @@ class Trainable(object):
These checkpoints are returned from calls to save_to_object().
"""
out = io.BytesIO(obj)
info = pickle.loads(gzip.GzipFile(fileobj=out, mode="rb").read())
info = pickle.loads(obj)
data = info["data"]
tmpdir = tempfile.mkdtemp("restore_from_object", dir=self.logdir)
checkpoint_path = os.path.join(tmpdir, info["checkpoint_name"])