1010import traceback
1111from pathlib import Path
1212from io import BytesIO
13- from typing import Optional , List , Union
13+ from typing import Optional , List
1414
1515import docker .errors
1616from docker .models .containers import Container
@@ -165,7 +165,9 @@ def cleanup_container(
165165 )
166166 os .kill (pid , signal .SIGKILL )
167167 else :
168- logger .error (f"PID for container { container .name } : { pid } - not killing." )
168+ logger .error (
169+ f"PID for container { container .name } : { pid } - not killing."
170+ )
169171 except Exception as e2 :
170172 raise Exception (
171173 f"Failed to forcefully kill container { container .name } : { e2 } \n "
@@ -184,9 +186,10 @@ def cleanup_container(
184186 )
185187
186188
187- def image_exists_locally (client : docker .DockerClient , image_name : str , tag : str , logger : logging .Logger ) -> bool :
188- """
189- Check if a Docker image exists locally.
189+ def image_exists_locally (
190+ client : docker .DockerClient , image_name : str , tag : str , logger : logging .Logger
191+ ) -> bool :
192+ """Check if a Docker image exists locally.
190193
191194 Args:
192195 ----
@@ -198,6 +201,7 @@ def image_exists_locally(client: docker.DockerClient, image_name: str, tag: str,
198201 Returns:
199202 -------
200203 bool: True if the image exists locally, False otherwise.
204+
201205 """
202206 images = client .images .list (name = image_name )
203207 for image in images :
@@ -207,9 +211,11 @@ def image_exists_locally(client: docker.DockerClient, image_name: str, tag: str,
207211 logger .info (f"{ image_name } :{ tag } cannot be found locally" )
208212 return False
209213
210- def pull_image_from_docker_hub (client : docker .DockerClient , image_name : str , tag : str , logger : logging .Logger ) -> docker .models .images .Image :
211- """
212- Pull a Docker image from Docker Hub.
214+
215+ def pull_image_from_docker_hub (
216+ client : docker .DockerClient , image_name : str , tag : str , logger : logging .Logger
217+ ) -> None :
218+ """Pull a Docker image from Docker Hub.
213219
214220 Args:
215221 ----
@@ -226,11 +232,11 @@ def pull_image_from_docker_hub(client: docker.DockerClient, image_name: str, tag
226232 ------
227233 docker.errors.ImageNotFound: If the image is not found on Docker Hub.
228234 docker.errors.APIError: If there's an issue with the Docker API during the pull.
235+
229236 """
230237 try :
231- image = client .images .pull (image_name , tag = tag )
238+ client .images .pull (image_name , tag = tag )
232239 logger .info (f"Loaded { image_name } :{ tag } from Docker Hub." )
233- return image
234240 except docker .errors .ImageNotFound :
235241 raise Exception (f"Image { image_name } :{ tag } not found on Docker Hub." )
236242 except docker .errors .APIError as e :
0 commit comments