@@ -109,7 +109,7 @@ def __init__(self, **kwargs):
109109 self .scorep_python_available_ = False
110110
111111 logging .config .dictConfig (LOGGING )
112- self .log = logging .getLogger (' kernel' )
112+ self .log = logging .getLogger (" kernel" )
113113
114114 def cell_output (self , string , stream = "stdout" ):
115115 """
@@ -704,7 +704,9 @@ async def scorep_execute(
704704 os .open (scorep_script_name , os .O_WRONLY | os .O_CREAT ), "w"
705705 ) as file :
706706 file .write (self .pershelper .subprocess_wrapper (code ))
707- self .log .debug (f"Code written to temporary script: { scorep_script_name } " )
707+ self .log .debug (
708+ f"Code written to temporary script: { scorep_script_name } "
709+ )
708710
709711 # For disk mode use implicit synchronization between kernel and
710712 # subprocess: await jupyter_dump, subprocess.wait(),
@@ -722,7 +724,10 @@ async def scorep_execute(
722724 )
723725
724726 if reply_status_dump ["status" ] != "ok" :
725- self .log_error (KernelErrorCode .PERSISTENCE_DUMP_FAIL , direction = "Jupyter -> Score-P" )
727+ self .log_error (
728+ KernelErrorCode .PERSISTENCE_DUMP_FAIL ,
729+ direction = "Jupyter -> Score-P" ,
730+ )
726731 self .pershelper .postprocess ()
727732 return reply_status_dump
728733
@@ -775,7 +780,10 @@ async def scorep_execute(
775780 cell_id = cell_id ,
776781 )
777782 if reply_status_dump ["status" ] != "ok" :
778- self .log_error (KernelErrorCode .PERSISTENCE_DUMP_FAIL , direction = "Jupyter -> Score-P" )
783+ self .log_error (
784+ KernelErrorCode .PERSISTENCE_DUMP_FAIL ,
785+ direction = "Jupyter -> Score-P" ,
786+ )
779787 self .pershelper .postprocess ()
780788 return reply_status_dump
781789
@@ -785,16 +793,17 @@ async def scorep_execute(
785793
786794 stdout_lock = threading .Lock ()
787795 process_busy_spinner = create_busy_spinner (stdout_lock )
788- process_busy_spinner .start (' Process is running...' )
796+ process_busy_spinner .start (" Process is running..." )
789797
790798 multicellmode_timestamps = []
791799
792800 try :
793- multicellmode_timestamps = self .read_scorep_process_pipe (proc , stdout_lock )
794- process_busy_spinner .stop ('Done.' )
801+ multicellmode_timestamps = self .read_scorep_process_pipe (
802+ proc , stdout_lock
803+ )
804+ process_busy_spinner .stop ("Done." )
795805 except KeyboardInterrupt :
796- process_busy_spinner .stop ('Kernel interrupted.' )
797-
806+ process_busy_spinner .stop ("Kernel interrupted." )
798807
799808 # for multiple nodes, we have to add more lists here, one list per node
800809 # this is required to be in line with the performance data aggregation
@@ -850,7 +859,8 @@ async def scorep_execute(
850859 )
851860
852861 # Check if the score-p process is running.
853- # This prevents jupyter_update() from getting stuck while reading non-existent temporary files
862+ # This prevents jupyter_update() from getting stuck while reading
863+ # non-existent temporary files
854864 # if something goes wrong during process execution.
855865 if proc .poll ():
856866 self .log_error (KernelErrorCode .SCOREP_SUBPROCESS_FAIL )
@@ -873,7 +883,10 @@ async def scorep_execute(
873883 cell_id = cell_id ,
874884 )
875885 if reply_status_update ["status" ] != "ok" :
876- self .log_error (KernelErrorCode .PERSISTENCE_LOAD_FAIL , direction = f"Score-P -> Jupyter" )
886+ self .log_error (
887+ KernelErrorCode .PERSISTENCE_LOAD_FAIL ,
888+ direction = "Score-P -> Jupyter" ,
889+ )
877890 self .pershelper .postprocess ()
878891 return reply_status_update
879892
@@ -882,7 +895,10 @@ async def scorep_execute(
882895 if self .pershelper .mode == "memory" :
883896 if proc .poll ():
884897 self .pershelper .postprocess ()
885- self .log_error (KernelErrorCode .PERSISTENCE_LOAD_FAIL , direction = "Score-P -> Jupyter" )
898+ self .log_error (
899+ KernelErrorCode .PERSISTENCE_LOAD_FAIL ,
900+ direction = "Score-P -> Jupyter" ,
901+ )
886902 return self .standard_reply ()
887903
888904 # Determine directory to which trace files were saved by Score-P
@@ -934,19 +950,24 @@ async def scorep_execute(
934950 )
935951 return self .standard_reply ()
936952
937-
938- def read_scorep_process_pipe (self , proc : subprocess .Popen [bytes ], stdout_lock : threading .Lock ) -> list :
953+ def read_scorep_process_pipe (
954+ self , proc : subprocess .Popen [bytes ], stdout_lock : threading .Lock
955+ ) -> list :
939956 """
940- This function reads stdout and stderr of the subprocess running with Score-P instrumentation independently.
957+ This function reads stdout and stderr of the subprocess running with
958+ Score-P instrumentation independently.
941959 It logs all stderr output, collects lines containing
942- the marker "MCM_TS" (used to identify multi-cell mode timestamps) into a list, and sends the remaining
960+ the marker "MCM_TS" (used to identify multi-cell mode timestamps) into
961+ a list, and sends the remaining
943962 stdout lines to the Jupyter cell output.
944963
945- Simultaneous access to stdout is synchronized via a lock to prevent overlapping with another thread performing
964+ Simultaneous access to stdout is synchronized via a lock to prevent
965+ overlapping with another thread performing
946966 long-running process animation.
947967
948968 Args:
949- proc (subprocess.Popen[bytes]): The subprocess whose output is being read.
969+ proc (subprocess.Popen[bytes]): The subprocess whose output is
970+ being read.
950971 stdout_lock (threading.Lock): Lock to avoid output overlapping
951972
952973 Returns:
@@ -969,12 +990,14 @@ def read_scorep_process_pipe(self, proc: subprocess.Popen[bytes], stdout_lock: t
969990 sel .unregister (key .fileobj )
970991 continue
971992
972- decoded_line = line .decode (sys .getdefaultencoding (), errors = 'ignore' )
993+ decoded_line = line .decode (
994+ sys .getdefaultencoding (), errors = "ignore"
995+ )
973996
974997 if key .fileobj is proc .stderr :
975998 with stdout_lock :
976- self .log .warning (f' { decoded_line .strip ()} ' )
977- elif ' MCM_TS' in decoded_line :
999+ self .log .warning (f" { decoded_line .strip ()} " )
1000+ elif " MCM_TS" in decoded_line :
9781001 multicellmode_timestamps .append (decoded_line )
9791002 else :
9801003 with stdout_lock :
@@ -988,7 +1011,6 @@ def read_scorep_process_pipe(self, proc: subprocess.Popen[bytes], stdout_lock: t
9881011
9891012 return multicellmode_timestamps
9901013
991-
9921014 async def do_execute (
9931015 self ,
9941016 code ,
@@ -1323,11 +1345,14 @@ def do_shutdown(self, restart):
13231345
13241346 def log_error (self , code : KernelErrorCode , ** kwargs ):
13251347 """
1326- Logs a kernel error with predefined error code and adds an extensible message format.
1348+ Logs a kernel error with predefined error code and adds an extensible
1349+ message format.
13271350
13281351 Parameters:
1329- code (KernelErrorCode): error code to select message template from `KERNEL_ERROR_MESSAGES`.
1330- **kwargs: contextual fields for the error message template (e.g., active_kernel="jupyter").
1352+ code (KernelErrorCode): error code to select message template from
1353+ `KERNEL_ERROR_MESSAGES`.
1354+ **kwargs: contextual fields for the error message template
1355+ (e.g., active_kernel="jupyter").
13311356
13321357 In addition to the dynamic arguments, the formatter always injects:
13331358 - mode (str): PersHelper() mode (e.g. "memory")
@@ -1336,12 +1361,10 @@ def log_error(self, code: KernelErrorCode, **kwargs):
13361361 mode = self .pershelper .mode
13371362 marshaller = self .pershelper .marshaller
13381363
1339- template = KERNEL_ERROR_MESSAGES .get (code , "Unknown error. Mode: {mode}, Marshaller: {marshaller}" )
1340- message = template .format (
1341- mode = mode ,
1342- marshaller = marshaller ,
1343- ** kwargs
1364+ template = KERNEL_ERROR_MESSAGES .get (
1365+ code , "Unknown error. Mode: {mode}, Marshaller: {marshaller}"
13441366 )
1367+ message = template .format (mode = mode , marshaller = marshaller , ** kwargs )
13451368
13461369 self .log .error (message )
13471370 self .cell_output ("KernelError: " + message , "stderr" )
0 commit comments