From 7f51d57edcbbb920ec3e8ebbcfa2aa9fae554273 Mon Sep 17 00:00:00 2001 From: Keigh Rim Date: Mon, 22 Jul 2024 16:59:57 -0400 Subject: [PATCH] reorganized runtime environment record based on https://github.com/clamsproject/mmif/issues/232 --- clams/app/__init__.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/clams/app/__init__.py b/clams/app/__init__.py index 33f7b25..ada914c 100644 --- a/clams/app/__init__.py +++ b/clams/app/__init__.py @@ -158,8 +158,6 @@ def annotate(self, mmif: Union[str, dict, Mmif], **runtime_params: List[str]) -> runningTime = refined.get('runningTime', False) hwFetch = refined.get('hwFetch', False) runtime_recs = {} - if runningTime: - runtime_recs['runningTime'] = str(td) if hwFetch: import platform, shutil, subprocess runtime_recs['architecture'] = platform.machine() @@ -170,10 +168,13 @@ def annotate(self, mmif: Union[str, dict, Mmif], **runtime_params: List[str]) -> stdout=subprocess.PIPE).stdout.decode('utf-8').strip().split('\n'): name, mem = gpu.split(', ') runtime_recs['cuda'].append(f'{name} ({mem})') - if len(runtime_recs) > 0: - for annotated_view in annotated.views: - if annotated_view.metadata.app == self.metadata.identifier: - annotated_view.metadata.set_additional_property('runtime', runtime_recs) + for annotated_view in annotated.views: + if annotated_view.metadata.app == self.metadata.identifier: + if runningTime: + annotated_view.metadata.set_additional_property('appRunningTime', str(td)) + if len(runtime_recs) > 0: + annotated_view.metadata.set_additional_property('appRunningHardware', runtime_recs) + return annotated.serialize(pretty=pretty, sanitize=True) @abstractmethod