Skip to content

Commit 4bdbb83

Browse files
committed
pre-commit
1 parent 7c9b378 commit 4bdbb83

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

commit0/harness/docker_utils.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import traceback
1111
from pathlib import Path
1212
from io import BytesIO
13-
from typing import Optional, List, Union
13+
from typing import Optional, List
1414

1515
import docker.errors
1616
from 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:

commit0/harness/spec.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ def repo_image_key(self) -> str:
5757
return f"commit0.repo.{repo}.{val}:latest".lower()
5858

5959
@property
60-
def repo_image_tag(self):
60+
def repo_image_tag(self) -> str:
61+
"""Repo image tag that will be used throughout."""
6162
repo = self.repo.split("/")[-1]
6263
return f"wentingzhao/{repo}:latest".lower()
6364

0 commit comments

Comments
 (0)