Skip to content

Commit

Permalink
Fixed lint problems
Browse files Browse the repository at this point in the history
  • Loading branch information
walter-bd committed Dec 2, 2024
1 parent 476b661 commit 786a815
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
9 changes: 4 additions & 5 deletions llm_sandbox/podman.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
from collections.abc import Iterator

from podman import PodmanClient
from podman.errors import NotFound, ImageNotFound
from podman.errors import NotFound
from podman.domain.containers import Container
from podman.domain.images import Image
from llm_sandbox.utils import (
image_exists,
get_libraries_installation_command,
get_code_file_extension,
get_code_execution_command,
Expand Down Expand Up @@ -104,7 +103,9 @@ def open(self):
print(f"Using image {self.image.tags[-1]}")
except NotFound:
if self.verbose:
print(f"Image {self.image} not found locally. Attempting to pull...")
print(
f"Image {self.image} not found locally. Attempting to pull..."
)

try:
# Attempt to pull the image
Expand All @@ -127,7 +128,6 @@ def open(self):
)
self.container.start()


def close(self):
if self.container:
if self.commit_container and isinstance(self.image, Image):
Expand Down Expand Up @@ -304,5 +304,4 @@ def execute_command(
if self.verbose:
print(output)


return ConsoleOutput(output)
9 changes: 4 additions & 5 deletions tests/test_session_podman.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_init_with_invalid_lang(self):
def test_init_with_both_image_and_dockerfile(self):
with self.assertRaises(ValueError):
SandboxPodmanSession(image="some_image", dockerfile="some_dockerfile")

def test_open_with_image(self):
# Mock the image retrieval
mock_image = MagicMock(tags=["python:3.9.19-bullseye"])
Expand All @@ -49,7 +49,9 @@ def test_open_with_image(self):
self.session.open()

# Assert that `images.get` was called to check if the image exists
self.mock_podman_client.images.get.assert_called_once_with("python:3.9.19-bullseye")
self.mock_podman_client.images.get.assert_called_once_with(
"python:3.9.19-bullseye"
)

# Assert that `containers.create` was called with the correct parameters
self.mock_podman_client.containers.create.assert_called_once_with(
Expand All @@ -64,9 +66,6 @@ def test_open_with_image(self):
# Assert that the `self.container` attribute was set
self.assertEqual(self.session.container, mock_container)




def test_close(self):
mock_container = MagicMock()
self.session.container = mock_container
Expand Down

0 comments on commit 786a815

Please sign in to comment.