Skip to content

Commit

Permalink
Fixed docker client remove image issue from tests
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertSamoilescu committed Jun 4, 2024
1 parent 18f0b49 commit 4844ca8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions tests/cli/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ def custom_image(
yield image_name

# in CI sometimes this fails, TODO: indentify why
# seems to happend when running on multiple workers `test_build`
# and `test_infer_custom_runtime`. We force them to run on the
# same worker to avoid this issue by using
# `@pytest.mark.xdist_group("group1")` and including the
# `--dist loadgroup` when running the pytest command.
try:
docker_client.images.remove(image=image_name, force=True)
except Exception:
Expand Down Expand Up @@ -87,11 +92,13 @@ def test_generate_dockerfile(base_image: Optional[str]):
assert dockerfile == DockerfileTemplate.format(base_image=expected)


@pytest.mark.xdist_group("group1")
def test_build(docker_client: DockerClient, custom_image: str):
image = docker_client.images.get(custom_image)
assert image.tags == [custom_image]


@pytest.mark.xdist_group("group1")
async def test_infer_custom_runtime(
custom_runtime_server: Tuple[str, str],
inference_request: InferenceRequest,
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ commands =
commands_pre =
poetry install --sync --no-root
commands =
python -m pytest {posargs} -n auto \
python -m pytest {posargs} -n auto --dist loadgroup \
{toxinidir}/tests
set_env =
GITHUB_SERVER_URL = {env:GITHUB_SERVER_URL:https\://github.com}
Expand Down

0 comments on commit 4844ca8

Please sign in to comment.