33import numpy as np
44from itables import show
55import logging
6+ import os
67from jumper_extension .bali_hook import BaliResultsParser
78from jumper_extension .core .messages import EXTENSION_INFO_MESSAGES , ExtensionInfoCode
89
@@ -45,7 +46,8 @@ def refresh_segments_from_disk(self, pid: int) -> int:
4546 Refresh BALI segments from disk for the given process ID.
4647 """
4748 segments = self .parser .collect_all_bali_segments (pid )
48-
49+ with open ("segments.txt" , "w" ) as file :
50+ file .write (str (segments ))
4951 # Build DataFrame directly from segments and align to canonical column order
5052 df = pd .DataFrame (segments )
5153 self ._segments_df = df .reindex (columns = self ._segments_df .columns )
@@ -117,7 +119,7 @@ def _trapz(values):
117119 powers = np .asarray (values ["gpu_power_avg" ], dtype = float )
118120 if len (times ) < 2 :
119121 return 0.0
120- return float (np .trapz (powers , times ))
122+ return float (np .trapezoid (powers , times ))
121123
122124 def _safe_div (a , b ):
123125 return a / b if b else None
@@ -284,7 +286,7 @@ class BaliVisualizationMixin:
284286 def __init__ (self , * args , bali_adapter = None , ** kwargs ):
285287 super ().__init__ (* args , ** kwargs )
286288 self .bali_adapter = bali_adapter or BaliAdapter ()
287- self ._compressed_bali_segments = []
289+ self ._compressed_bali_segments = None
288290 self ._cached_bali_segments = None
289291
290292 def _load_bali_segments (self ) -> List [Dict ]:
@@ -296,8 +298,12 @@ def _load_bali_segments(self) -> List[Dict]:
296298 bali_pid = getattr (self .monitor , "bali_pid_directory" , None ) \
297299 or getattr (self .monitor , "pid" , None )
298300 if bali_pid is None :
299- self ._cached_bali_segments = []
300- return self ._cached_bali_segments
301+ bali_pid = os .getpid ()
302+ #self._cached_bali_segments = None
303+ #return self._cached_bali_segments
304+
305+ logger .info (f"BALI PID used: { bali_pid } " )
306+
301307 self ._cached_bali_segments = self .bali_adapter .get_segments_for_visualization (
302308 bali_pid )
303309 logging .debug ("cached segments: %s" , self ._cached_bali_segments )
0 commit comments