Repository: Project-MONAI/MONAI

Issue:
TestThreadContainer.test_plot error with torch 1.5.1
**Describe the bug**
full logs at https://github.com/Project-MONAI/MONAI/runs/2180798490?check_suite_focus=true
```
======================================================================
FAIL: test_plot (tests.test_threadcontainer.TestThreadContainer)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/__w/MONAI/MONAI/tests/test_threadcontainer.py", line 104, in test_plot
    self.assertIsNone(comp, comp)  # None indicates test passed
AssertionError: 'Error: Image files did not match.\n  RMS Value: 2.9260495552878116\n  Expected:  \n    /tmp/tmps3emgwtc/threadcontainer_plot_test.png\n  Actual:    \n    /__w/MONAI/MONAI/tests/testing_data/threadcontainer_plot_test.png\n  Difference:\n    /__w/MONAI/MONAI/tests/testing_data/threadcontainer_plot_test-failed-diff.png\n  Tolerance: \n    0.001' is not None : Error: Image files did not match.
  RMS Value: 2.9260495552878116
  Expected:  
    /tmp/tmps3emgwtc/threadcontainer_plot_test.png
  Actual:    
    /__w/MONAI/MONAI/tests/testing_data/threadcontainer_plot_test.png
  Difference:
    /__w/MONAI/MONAI/tests/testing_data/threadcontainer_plot_test-failed-diff.png
  Tolerance: 
    0.001

```


Discussion:

Resolving patch:
diff --git a/monai/utils/jupyter_utils.py b/monai/utils/jupyter_utils.py
--- a/monai/utils/jupyter_utils.py
+++ b/monai/utils/jupyter_utils.py
@@ -245,6 +245,7 @@ class ThreadContainer(Thread):
         engine: wrapped `Engine` object, when the container is started its `run` method is called
         loss_transform: callable to convert an output dict into a single numeric value
         metric_transform: callable to convert a named metric value into a single numeric value
+        status_format: format string for status key-value pairs.
     """
 
     def __init__(
@@ -252,6 +253,7 @@ def __init__(
         engine: Engine,
         loss_transform: Callable = _get_loss_from_output,
         metric_transform: Callable = lambda name, value: value,
+        status_format: str = "{}: {:.4}",
     ):
         super().__init__()
         self.lock = RLock()
@@ -260,6 +262,7 @@ def __init__(
         self.loss_transform = loss_transform
         self.metric_transform = metric_transform
         self.fig = None
+        self.status_format = status_format
 
         self.engine.add_event_handler(Events.ITERATION_COMPLETED, self._update_status)
 
@@ -318,7 +321,7 @@ def status(self) -> str:
         stats = self.status_dict
 
         msgs = [stats.pop(StatusMembers.STATUS.value), "Iters: " + str(stats.pop(StatusMembers.ITERS.value))]
-        msgs += ["%s: %s" % kv for kv in stats.items()]
+        msgs += [self.status_format.format(key, val) for key, val in stats.items()]
 
         return ", ".join(msgs)
 


Test patch:
diff --git a/tests/test_threadcontainer.py b/tests/test_threadcontainer.py
--- a/tests/test_threadcontainer.py
+++ b/tests/test_threadcontainer.py
@@ -99,6 +99,10 @@ def test_plot(self):
         with tempfile.TemporaryDirectory() as tempdir:
             tempimg = f"{tempdir}/threadcontainer_plot_test.png"
             fig.savefig(tempimg)
-            comp = compare_images(tempimg, f"{testing_dir}/threadcontainer_plot_test.png", 1e-3)
+            comp = compare_images(f"{testing_dir}/threadcontainer_plot_test.png", tempimg, 1e-3)
 
             self.assertIsNone(comp, comp)  # None indicates test passed
+
+
+if __name__ == "__main__":
+    unittest.main()
diff --git a/tests/testing_data/threadcontainer_plot_test.png b/tests/testing_data/threadcontainer_plot_test.png
Binary files a/tests/testing_data/threadcontainer_plot_test.png and b/tests/testing_data/threadcontainer_plot_test.png differ