Repository: KIT-IAI/pyWATTS

Issue:
The summary function writes to a file (instead of printing)
**What is your feature request related to?**
* Problem related

**Please describe the problem**
It is possible to print out a summary of the data set in the latest step with the flag `summary = true`. Currently, this summary is simply printed and not saved.

**Describe the solution you'd like**
This summary should also be saved to a file for future reference if desired.

**What type of Feature Request**
* Core enhancement


Comments:

Patch:
diff --git a/pywatts/callbacks/debug_callback.py b/pywatts/callbacks/debug_callback.py
index df55b0b..d8ab1f3 100644
--- a/pywatts/callbacks/debug_callback.py
+++ b/pywatts/callbacks/debug_callback.py
@@ -1,5 +1,5 @@
 import xarray as xr
-from typing import Dict
+from typing import Dict, Optional
 
 from pywatts.callbacks.base_callback import BaseCallback
 
@@ -36,6 +36,23 @@ class StatisticCallback(BaseCallback):
     :type BaseCallback: BaseCallback
     """
 
+    def __init__(self, prefix: str, use_filemanager: Optional[bool] = None):
+        """
+        Initialise Statistical callback object given a filename and
+        optional use_filemanager flag.
+
+        :param prefix: Prefix to use for the line plot output file.
+        :type prefix: str
+        :param use_filemanager: Flag to denote if the filemanager of the pipeline should be used.
+        :type use_filemanager: Optional[bool]
+        """
+        if use_filemanager is None:
+            # use base class default if use_filemanager is not set
+            super().__init__()
+        else:
+            super().__init__(use_filemanager)
+        self.prefix = prefix
+
     def __call__(self, data_dict: Dict[str, xr.DataArray]):
         """
         Implementation of abstract base method to print out
@@ -44,7 +61,13 @@ class StatisticCallback(BaseCallback):
         :param data_dict: Dict of DataArrays that statistical information should be printed out.
         :type data_dict: Dict[str, xr.DataArray]
         """
+        result_string = "\n# Statistical Callback\n"
         print("\n# Statistical Callback")
+
         for key in data_dict:
             print(f"## {key}")
             print(data_dict[key].to_pandas().describe())
+            result_string +=f"## {key}\n {data_dict[key].to_pandas().describe()} \n"
+
+        with open(self.get_path(f"{self.prefix}_Statistics.md"), "w") as file:
+            file.write(result_string)
\ No newline at end of file
diff --git a/pywatts/core/filemanager.py b/pywatts/core/filemanager.py
index 0353b95..9e42299 100644
--- a/pywatts/core/filemanager.py
+++ b/pywatts/core/filemanager.py
@@ -7,7 +7,7 @@ from pywatts.core.exceptions.io_exceptions import IOException
 
 logger = logging.getLogger()
 
-ALLOWED_FILES = ["png", "csv", "xlsx", "pickle", "tex", "json", "h5", "pt"]
+ALLOWED_FILES = ["png", "csv", "xlsx", "pickle", "tex", "json", "h5", "pt", "md"]
 
 
 class FileManager:


Test patch:
diff --git a/tests/unit/core/test_filemanager.py b/tests/unit/core/test_filemanager.py
index c4e2f16..f9f24ad 100644
--- a/tests/unit/core/test_filemanager.py
+++ b/tests/unit/core/test_filemanager.py
@@ -63,7 +63,7 @@ class TestFilemanager(unittest.TestCase):
             self.filemanager.get_path("result.test")
         self.assertEqual(cm.exception.args,
                          ("test is not an allowed file type. Allowed types are ['png', 'csv', 'xlsx', "
-                          "'pickle', 'tex', 'json', 'h5', 'pt'].",))
+                          "'pickle', 'tex', 'json', 'h5', 'pt', 'md'].",))
 
     @patch("pywatts.core.filemanager.logger")
     @patch("pywatts.core.filemanager.datetime")