@@ -116,7 +116,9 @@ def _wait_for_session_status(
116116 start = monotonic ()
117117 while monotonic () - start < self .DEFAULT_TIMEOUT_SECONDS :
118118 res = self ._send_renku_request (
119- "get" , f"{ self ._notebooks_url ()} /servers/{ name } " , headers = self ._auth_header ()
119+ "get" ,
120+ f"{ self ._notebooks_url ()} /servers/{ name } " ,
121+ headers = self ._auth_header (),
120122 )
121123 if res .status_code == 404 and status == "stopping" :
122124 return
@@ -266,10 +268,15 @@ def find_image(self, image_name: str, config: Optional[Dict[str, Any]]) -> bool:
266268 def get_cloudstorage (self ):
267269 """Get cloudstorage configured for the project."""
268270 storage_service = cast (IStorageService , inject .instance (IStorageService ))
269- project_id = storage_service .project_id
271+
272+ try :
273+ project_id = storage_service .project_id
274+ except errors .ProjectNotFound :
275+ project_id = None
276+
270277 if project_id is None :
271- communication .warn ("Couldn't get project ID from Gitlab, skipping mounting cloudstorage " )
272- return
278+ communication .warn ("Skipping cloud storage mounting as project couldn't be loaded from gitlab. " )
279+ return []
273280
274281 storages = storage_service .list (project_id )
275282
@@ -291,7 +298,12 @@ def get_cloudstorage(self):
291298 secret = communication .prompt (f"{ field ['help' ]} \n Please provide a value for secret '{ name } '" )
292299 storage .configuration [name ] = secret
293300
294- storages_to_mount .append ({"storage_id" : storage .storage_id , "configuration" : storage .configuration })
301+ storages_to_mount .append (
302+ {
303+ "storage_id" : storage .storage_id ,
304+ "configuration" : storage .configuration ,
305+ }
306+ )
295307
296308 return storages_to_mount
297309
@@ -447,21 +459,27 @@ def session_stop(self, project_name: str, session_name: Optional[str], stop_all:
447459 for session in sessions :
448460 responses .append (
449461 self ._send_renku_request (
450- "delete" , f"{ self ._notebooks_url ()} /servers/{ session .id } " , headers = self ._auth_header ()
462+ "delete" ,
463+ f"{ self ._notebooks_url ()} /servers/{ session .id } " ,
464+ headers = self ._auth_header (),
451465 )
452466 )
453467 self ._wait_for_session_status (session .id , "stopping" )
454468 elif session_name :
455469 responses .append (
456470 self ._send_renku_request (
457- "delete" , f"{ self ._notebooks_url ()} /servers/{ session_name } " , headers = self ._auth_header ()
471+ "delete" ,
472+ f"{ self ._notebooks_url ()} /servers/{ session_name } " ,
473+ headers = self ._auth_header (),
458474 )
459475 )
460476 self ._wait_for_session_status (session_name , "stopping" )
461477 elif n_sessions == 1 :
462478 responses .append (
463479 self ._send_renku_request (
464- "delete" , f"{ self ._notebooks_url ()} /servers/{ sessions [0 ].id } " , headers = self ._auth_header ()
480+ "delete" ,
481+ f"{ self ._notebooks_url ()} /servers/{ sessions [0 ].id } " ,
482+ headers = self ._auth_header (),
465483 )
466484 )
467485 self ._wait_for_session_status (sessions [0 ].id , "stopping" )
@@ -474,7 +492,13 @@ def session_stop(self, project_name: str, session_name: Optional[str], stop_all:
474492
475493 return SessionStopStatus .SUCCESSFUL if n_successfully_stopped == n_sessions else SessionStopStatus .FAILED
476494
477- def session_open (self , project_name : str , session_name : Optional [str ], ssh : bool = False , ** kwargs ) -> bool :
495+ def session_open (
496+ self ,
497+ project_name : str ,
498+ session_name : Optional [str ],
499+ ssh : bool = False ,
500+ ** kwargs ,
501+ ) -> bool :
478502 """Open a given interactive session.
479503
480504 Args:
0 commit comments