refactor: BottleImages dataclass, prelaunch_checks, build_or_load_images
Addresses review comments 3098, 3099, 3100 on PR #336: - Add BottleImages(agent, sidecar) dataclass to backend/__init__.py. Docker/macOS backends use str image refs; smolmachines uses Path artifacts. Replaces the singular `image` variable from the canonical pattern in comment 3100. - Replace _image_stale_checks/skip_stale with public prelaunch_checks(). CLI now calls backend.prelaunch_checks(plan) before backend.launch(plan); if StaleImageError is raised and the operator confirms, launch proceeds without re-checking. Removes the while-True/skip_stale retry loop. - Add abstract _build_or_load_images(plan) -> BottleImages to BottleBackend. launch() calls it then passes images to _launch_impl. Each backend implements both methods. - Fix comment 3098 (macos-container): _build_images is removed. build_or_load_images() has separate fresh/cached code paths — the cached path never calls a build helper. - Update _start_bundle (smolmachines) to accept sidecar_artifact: Path directly. Sidecar artifact resolution moves to _sidecar_from_path(), called by build_or_load_images alongside _agent_from_path().
This commit is contained in:
@@ -13,7 +13,7 @@ from typing import Any
|
||||
from unittest import mock
|
||||
|
||||
from bot_bottle.agent_provider import AgentProvisionPlan
|
||||
from bot_bottle.backend import BottleSpec
|
||||
from bot_bottle.backend import BottleImages, BottleSpec
|
||||
from bot_bottle.backend.docker import launch as launch_mod
|
||||
from bot_bottle.backend.docker.bottle_plan import DockerBottlePlan
|
||||
from bot_bottle.backend.docker.consolidated_launch import LaunchContext
|
||||
@@ -115,7 +115,8 @@ class TestLaunchCommittedImage(unittest.TestCase):
|
||||
with self._patched(
|
||||
committed_tag=committed_tag, image_present=image_present, compose=compose,
|
||||
) as built:
|
||||
with launch_mod.launch(plan, provision=mock.Mock(return_value=None)):
|
||||
images = launch_mod.build_or_load_images(plan)
|
||||
with launch_mod.launch(plan, images, provision=mock.Mock(return_value=None)):
|
||||
pass
|
||||
return built
|
||||
|
||||
@@ -130,8 +131,10 @@ class TestLaunchCommittedImage(unittest.TestCase):
|
||||
captured.append(p)
|
||||
return {"services": {"agent": {}}}
|
||||
|
||||
with self._patched(committed_tag=_COMMITTED_TAG, image_present=True, compose=compose):
|
||||
with launch_mod.launch(_plan(self._tmp), provision=mock.Mock(return_value=None)):
|
||||
with self._patched(committed_tag=_COMMITTED_TAG, image_present=True, compose=compose) as _:
|
||||
plan = _plan(self._tmp)
|
||||
images = launch_mod.build_or_load_images(plan)
|
||||
with launch_mod.launch(plan, images, provision=mock.Mock(return_value=None)):
|
||||
pass
|
||||
self.assertEqual(_COMMITTED_TAG, captured[0].image)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user