Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions benchmarks/utils/build_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,12 @@ def build_image(
sdk_version=sdk_version,
)
for t in opts.all_tags:
# Check if image exists or not
# Check local Docker first (fast ~100ms), then remote registry (slow HTTP)
if local_image_exists(t):
logger.info("Image %s already exists locally. Skipping build.", t)
return BuildOutput(base_image=base_image, tags=[t], error=None)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Testing Gap: While this is a solid performance fix, add a unit test that verifies the call order: mock both local_image_exists() and remote_image_exists(), make the local check return True, and assert the remote check was never called. This would have caught the regression in commit 92efb47 and prevents future breakage.

Example test structure:

def test_build_image_checks_local_before_remote(mocker):
    mock_local = mocker.patch("...local_image_exists", return_value=True)
    mock_remote = mocker.patch("...remote_image_exists", return_value=True)
    
    build_image(...)
    
    mock_local.assert_called_once()
    mock_remote.assert_not_called()  # Should never hit remote if local exists

if remote_image_exists(t):
logger.info("Image %s already exists. Skipping build.", t)
logger.info("Image %s already exists in registry. Skipping build.", t)
return BuildOutput(base_image=base_image, tags=[t], error=None)
tags = build(opts)
return BuildOutput(base_image=base_image, tags=tags, error=None)
Expand Down
Loading