From 28470824fa9df97fda75db3fabd020ac784a83bc Mon Sep 17 00:00:00 2001
From: cmoineau <cyril.moineau@cea.fr>
Date: Thu, 2 Jan 2025 09:34:56 +0000
Subject: [PATCH] Fix error with meminfo save fig.

---
 aidge_core/mem_info.py | 28 ++--------------------------
 1 file changed, 2 insertions(+), 26 deletions(-)

diff --git a/aidge_core/mem_info.py b/aidge_core/mem_info.py
index dc96b49cd..87f286bcb 100644
--- a/aidge_core/mem_info.py
+++ b/aidge_core/mem_info.py
@@ -44,19 +44,6 @@ def compute_default_mem_info(scheduler: aidge_core.Scheduler) -> Tuple[int, List
             mem_info[node] = [] # No meminfo for producer
     return mem_size, mem_info
 
-# TODO remove
-def _gnuplot_installed():
-    try:
-        # Run gnuplot with the --version flag and capture the output
-        subprocess.run(["gnuplot", "--version"])
-        return True
-    except FileNotFoundError:
-        aidge_core.Log.warn("Gnuplot is not installed.")
-        return False
-    except subprocess.CalledProcessError:
-        aidge_core.Log.warn("Gnuplot command found but failed to run.")
-        return False
-
 def log_meminfo(mem_manager:aidge_core.MemoryManager, path: Path, diplay_names:bool):
     """Generate a graph representing the memory allocation of each ouputs.
 
@@ -115,6 +102,8 @@ def log_meminfo(mem_manager:aidge_core.MemoryManager, path: Path, diplay_names:b
     ax = plt.gca()
     ax.spines['top'].set_visible(False)
     ax.spines['right'].set_visible(False)
+    folder_path = path.parent
+    folder_path.mkdir(parents=True, exist_ok=True)
     plt.savefig(path)
     plt.close()
     aidge_core.Log.notice(f"Generated memory management info at: {path}")
@@ -157,19 +146,6 @@ def generate_optimized_memory_info(scheduler: aidge_core.Scheduler, stats_folder
 
     if stats_folder is not None:
         log_meminfo(mem_manager, Path(stats_folder) / "memory_info.png", display_names)
-        # TODO remove
-        if _gnuplot_installed():
-            # Use gnuplot to generate the log
-            os.makedirs(str(Path(stats_folder) / "graph"), exist_ok=True)
-            mem_manager.log("memory_info")
-            os.chmod("memory_info_plot.gnu", 0o777)
-            os.system("./memory_info_plot.gnu")
-            shutil.move("memory_info", str(Path(stats_folder) / "graph" / "memory_info"))
-            shutil.move("memory_info_plot.png", str(
-                Path(stats_folder) / "graph" / "memory_info_plot.png"))
-            os.remove("memory_info_plot.gnu")
-        else:
-            aidge_core.Log.warn("Warning: gnuplot is not installed, could not generate stat folder.")
 
     # In the export, we currently use an unified memory buffer whose size
     # is determined by the memory peak usage
-- 
GitLab