@@ -307,8 +307,8 @@ async def _wait_for_status(
307
307
s = "Pod Pending"
308
308
309
309
# Logging and eventbus
310
- self ._emit_kernel_message ( message )
311
- self ._emit_status (s , d )
310
+ self ._emit_console ( s , message )
311
+ self ._emit_banner (s , d )
312
312
313
313
# If the status is known, return
314
314
if resp ["status" ].lower () in status :
@@ -362,9 +362,13 @@ async def kill(self, restart: bool = False) -> None:
362
362
363
363
restart is True if this operation will precede a subsequent launch_kernel request.
364
364
"""
365
- self ._emit_status (status = "Terminating the current kernel." )
365
+ self ._emit (
366
+ constants .KERNEL_STATE .TERMINATING , msg = "Shutting down the current kernel."
367
+ )
366
368
await self .nbservice_client .stop_kernel (self .process_id )
367
- self ._emit_status (status = "Dead" , description = "Kernel is terminated." )
369
+ self ._emit (
370
+ constants .KERNEL_STATE .DEAD , msg = "Kernel has been successfully terminated."
371
+ )
368
372
self .process_id = None
369
373
370
374
async def terminate (self , restart : bool = False ) -> None :
@@ -378,9 +382,11 @@ async def terminate(self, restart: bool = False) -> None:
378
382
379
383
restart is True if this operation precedes a start launch_kernel request.
380
384
"""
381
- self ._emit_status (status = "Terminating the current kernel." )
385
+ self ._emit (
386
+ constants .KERNEL_STATE .TERMINATING , msg = "Terminating the current kernel."
387
+ )
382
388
await self .nbservice_client .stop_kernel (self .process_id )
383
- self ._emit_status ( status = "Dead" , description = "Kernel is terminated." )
389
+ self ._emit ( constants . KERNEL_STATE . DEAD , msg = "Kernel is terminated." )
384
390
self .process_id = None
385
391
386
392
async def pre_launch (self , ** kwargs : Any ) -> Dict [str , Any ]:
@@ -428,22 +434,14 @@ async def launch_kernel(
428
434
This method is called from `KernelManager.launch_kernel()` during the
429
435
kernel manager's start kernel sequence.
430
436
"""
431
- # If the caller provided metadata for an already-running
432
- # kernel, get that data here and check if its valid
433
- # in the next step.
434
- if kwargs .get ("ds_metadata" ):
435
- metadata = kwargs ["ds_metadata" ]
436
- if metadata .get ("id" ) == self .notebook_id :
437
- self .process_id = metadata .get ("kernel" )
438
-
439
437
if "process_id" in kwargs :
440
438
self .process_id = kwargs ["process_id" ]
441
439
442
440
# If a process ID already exists for this provisioner,
443
441
# check with the notebook-service to see if its still running.
444
442
if self .process_id :
445
- self ._emit_status ("Kernel found" , "checking its status" )
446
443
try :
444
+ self ._emit (constants .KERNEL_STATE .RECONNECTING )
447
445
r = await self .nbservice_client .get_kernel_status (
448
446
self .process_id , query_params_dict = {"cause" : "view" }
449
447
)
@@ -456,25 +454,28 @@ async def launch_kernel(
456
454
"process_id" : self .process_id ,
457
455
"kernel_id" : self .kernel_id ,
458
456
}
459
- self ._emit_status ("Reconnecting" )
460
457
# Fetch the kernel connection info if the kernel already exists.
461
458
await self ._fetch_connection_info ()
462
459
return self .connection_info
463
- # If notebook service returned an error, start a new kernel.
464
- self ._emit ("The listed kernel no longer exists. Starting a new kernel." )
460
+ raise HTTPError
465
461
except (HTTPError , HTTPClientError ):
466
462
# If notebook service returned an error, start a new kernel.
467
- self ._emit ("The listed kernel no longer exists. Starting a new kernel." )
463
+ self ._emit (
464
+ constants .KERNEL_STATE .DEAD ,
465
+ "The listed kernel no longer exists. Starting a new kernel." ,
466
+ )
468
467
469
468
# If the block above didn't return, a new kernel is needed.
470
469
# Request notebook service to start a kernel.
471
- self ._emit_status ("Starting" , "This may take a minute..." )
470
+ self ._emit (
471
+ constants .KERNEL_STATE .STARTING ,
472
+ msg = f"Launching a { self .kernel_spec .display_name } kernel." ,
473
+ )
472
474
r = await self .nbservice_client .start_kernel (self .kernel_spec .name )
473
475
474
476
# Store the new process ID from notebook service
475
477
response = json_decode (r .body )
476
478
self .process_id = str (response ["id" ])
477
-
478
479
await self .wait_for_ready (timeout = self .launch_timeout )
479
480
480
481
# Set the connection_info for the given mode.
0 commit comments