@@ -77,7 +77,7 @@ def __init__(self):
7777
7878 self .metadata_param_caster = ParameterCaster (self .metadata_param_spec )
7979 self .annotate_param_caster = ParameterCaster (self .annotate_param_spec )
80- self .logger = logging .getLogger (self .metadata .identifier )
80+ self .logger = logging .getLogger (str ( self .metadata .identifier ) )
8181
8282 def appmetadata (self , ** kwargs : List [str ]) -> str :
8383 """
@@ -138,6 +138,7 @@ def annotate(self, mmif: Union[str, dict, Mmif], **runtime_params: List[str]) ->
138138 """
139139 if not isinstance (mmif , Mmif ):
140140 mmif = Mmif (mmif )
141+ existing_view_ids = {view .id for view in mmif .views }
141142 issued_warnings = []
142143 for key in runtime_params :
143144 if key not in self .annotate_param_spec :
@@ -156,7 +157,8 @@ def annotate(self, mmif: Union[str, dict, Mmif], **runtime_params: List[str]) ->
156157 warnings_view = annotated .new_view ()
157158 self .sign_view (warnings_view , refined )
158159 warnings_view .metadata .warnings = issued_warnings
159- td = datetime .now () - t
160+ run_id = datetime .now ()
161+ td = run_id - t
160162 runningTime = refined .get ('runningTime' , False )
161163 hwFetch = refined .get ('hwFetch' , False )
162164 runtime_recs = {}
@@ -180,7 +182,8 @@ def annotate(self, mmif: Union[str, dict, Mmif], **runtime_params: List[str]) ->
180182 name , mem = gpu .split (', ' )
181183 runtime_recs ['cuda' ].append (self ._cuda_device_name_concat (name , mem ))
182184 for annotated_view in annotated .views :
183- if annotated_view .metadata .app == self .metadata .identifier :
185+ if annotated_view .id not in existing_view_ids and annotated_view .metadata .app == str (self .metadata .identifier ):
186+ annotated_view .metadata .timestamp = run_id
184187 profiling_data = {}
185188 if runningTime :
186189 profiling_data ['runningTime' ] = str (td )
@@ -265,7 +268,7 @@ def sign_view(self, view: View, runtime_conf: dict) -> None:
265268 :param view: a view to sign
266269 :param runtime_conf: runtime configuration of the app as k-v pairs
267270 """
268- view .metadata .app = self .metadata .identifier
271+ view .metadata .app = str ( self .metadata .identifier )
269272 params_map = {p .name : p for p in self .metadata .parameters }
270273 if self ._RAW_PARAMS_KEY in runtime_conf :
271274 for k , v in runtime_conf .items ():
@@ -300,7 +303,7 @@ def set_error_view(self, mmif: Union[str, dict, Mmif], **runtime_conf: List[str]
300303 mmif = Mmif (mmif )
301304 error_view : Optional [View ] = None
302305 for view in reversed (mmif .views ):
303- if view .metadata .app == self .metadata .identifier :
306+ if view .metadata .app == str ( self .metadata .identifier ) :
304307 error_view = view
305308 break
306309 if error_view is None :
@@ -358,7 +361,7 @@ def _get_profile_path(self, param_hash: str) -> pathlib.Path:
358361 :return: Path to the profile file
359362 """
360363 # Sanitize app identifier for filesystem use
361- app_id = self .metadata .identifier .replace ('/' , '-' ).replace (':' , '-' )
364+ app_id = str ( self .metadata .identifier ) .replace ('/' , '-' ).replace (':' , '-' )
362365 cache_base = pathlib .Path (os .environ .get ('XDG_CACHE_HOME' , pathlib .Path .home () / '.cache' ))
363366 cache_dir = cache_base / 'clams' / 'memory_profiles' / app_id
364367 return cache_dir / f"memory_{ param_hash } .json"
0 commit comments