@@ -83,6 +83,8 @@ def _service_spec(self) -> dict[str, Any]:
8383 def _container_spec (self ) -> dict [str , Any ]:
8484 """Get the job's main container spec."""
8585 containers = self ._service_spec ["spec" ]["containers" ]
86+ if len (containers ) == 1 :
87+ return cast (dict [str , Any ], containers [0 ])
8688 try :
8789 container_spec = next (c for c in containers if c ["name" ] == constants .DEFAULT_CONTAINER_NAME )
8890 except StopIteration :
@@ -163,7 +165,7 @@ def get_logs(
163165 Returns:
164166 The job's execution logs.
165167 """
166- logs = _get_logs (self ._session , self .id , limit , instance_id , verbose )
168+ logs = _get_logs (self ._session , self .id , limit , instance_id , self . _container_spec [ "name" ], verbose )
167169 assert isinstance (logs , str ) # mypy
168170 if as_list :
169171 return logs .splitlines ()
@@ -281,7 +283,12 @@ def _get_service_spec(session: snowpark.Session, job_id: str) -> dict[str, Any]:
281283
282284@telemetry .send_api_usage_telemetry (project = _PROJECT , func_params_to_log = ["job_id" , "limit" , "instance_id" ])
283285def _get_logs (
284- session : snowpark .Session , job_id : str , limit : int = - 1 , instance_id : Optional [int ] = None , verbose : bool = True
286+ session : snowpark .Session ,
287+ job_id : str ,
288+ limit : int = - 1 ,
289+ instance_id : Optional [int ] = None ,
290+ container_name : str = constants .DEFAULT_CONTAINER_NAME ,
291+ verbose : bool = True ,
285292) -> str :
286293 """
287294 Retrieve the job's execution logs.
@@ -291,6 +298,7 @@ def _get_logs(
291298 limit: The maximum number of lines to return. Negative values are treated as no limit.
292299 session: The Snowpark session to use. If none specified, uses active session.
293300 instance_id: Optional instance ID to get logs from a specific instance.
301+ container_name: The container name to get logs from a specific container.
294302 verbose: Whether to return the full log or just the portion between START and END messages.
295303
296304 Returns:
@@ -311,7 +319,7 @@ def _get_logs(
311319 params : list [Any ] = [
312320 job_id ,
313321 0 if instance_id is None else instance_id ,
314- constants . DEFAULT_CONTAINER_NAME ,
322+ container_name ,
315323 ]
316324 if limit > 0 :
317325 params .append (limit )
@@ -337,7 +345,7 @@ def _get_logs(
337345 job_id ,
338346 limit = limit ,
339347 instance_id = instance_id if instance_id else 0 ,
340- container_name = constants . DEFAULT_CONTAINER_NAME ,
348+ container_name = container_name ,
341349 )
342350 full_log = os .linesep .join (row [0 ] for row in logs )
343351
0 commit comments