Better management of stdout when resuming checkpoints in notebooks.
@@ -207,7 +207,6 @@ class TextLogger(BaseLogger, SupervisedPlugin):
out = self.__dict__.copy()
fobject_serialized_def = TextLogger._fobj_serialize(out['file'])
- # print('fobject_serialized_def', fobject_serialized_def)
if fobject_serialized_def is not None:
out['file'] = fobject_serialized_def
@@ -243,8 +242,22 @@ class TextLogger(BaseLogger, SupervisedPlugin):
@staticmethod
def _fobj_serialize(file_object) -> Optional[str]:
+ is_notebook = False
+ try:
+ is_notebook = file_object.__class__.__name__ == 'OutStream' and\
+ 'ipykernel' in file_object.__class__.__module__
+ except:
+ pass
+
+ if is_notebook:
+ # Running in a notebook
+ out_file_path = None
+ stream_name = 'stdout'
+ else:
+ # Standard file object
out_file_path = TextLogger._file_get_real_path(file_object)
stream_name = TextLogger._file_get_stream(file_object)
+
if out_file_path is not None:
return 'path:' + str(out_file_path)
elif stream_name is not None:
