refactor: AgentProvider.dockerfile always returns Path, never None
The convention is that every provider declares a Dockerfile location; callers that care whether the file actually exists check .is_file(). Drops all `is not None` guards on the property result.
This commit is contained in:
@@ -128,16 +128,13 @@ class AgentProvider(ABC):
|
||||
template."""
|
||||
|
||||
@property
|
||||
def dockerfile(self) -> Path | None:
|
||||
"""Path to the provider's Dockerfile, or None if no Dockerfile
|
||||
is declared.
|
||||
def dockerfile(self) -> Path:
|
||||
"""Path to the provider's Dockerfile.
|
||||
|
||||
Default: looks for a `Dockerfile` file next to this provider's
|
||||
Default: the `Dockerfile` file next to this provider's
|
||||
`agent_provider.py` module. Override to point at a non-standard
|
||||
path, or return None to signal that no Dockerfile exists (the
|
||||
provider relies on a pre-built image)."""
|
||||
path = Path(inspect.getfile(type(self))).parent / "Dockerfile"
|
||||
return path if path.is_file() else None
|
||||
path."""
|
||||
return Path(inspect.getfile(type(self))).parent / "Dockerfile"
|
||||
|
||||
@abstractmethod
|
||||
def provision_plan(
|
||||
|
||||
@@ -95,7 +95,7 @@ def fetch_current_dockerfile(slug: str) -> str:
|
||||
if override is not None:
|
||||
return override
|
||||
repo_dockerfile = get_provider("claude").dockerfile
|
||||
if repo_dockerfile is not None and repo_dockerfile.is_file():
|
||||
if repo_dockerfile.is_file():
|
||||
return repo_dockerfile.read_text()
|
||||
raise CapabilityApplyError(
|
||||
f"no per-bottle Dockerfile for {slug} and no provider Dockerfile at "
|
||||
|
||||
@@ -102,14 +102,11 @@ def resolve_plan(
|
||||
dockerfile_path = _resolve_manifest_dockerfile(provider.dockerfile, spec)
|
||||
else:
|
||||
p_dockerfile = provider_obj.dockerfile
|
||||
if p_dockerfile is not None:
|
||||
if provider.template in PROVIDER_TEMPLATES:
|
||||
image_default = provider_runtime.image
|
||||
else:
|
||||
image_default = f"bot-bottle-{provider.template}:{slug}"
|
||||
dockerfile_path = str(p_dockerfile)
|
||||
else:
|
||||
if provider.template in PROVIDER_TEMPLATES:
|
||||
image_default = provider_runtime.image
|
||||
else:
|
||||
image_default = f"bot-bottle-{provider.template}:{slug}"
|
||||
dockerfile_path = str(p_dockerfile)
|
||||
image = image_default
|
||||
derived_image = ""
|
||||
runtime_image = image
|
||||
@@ -217,7 +214,7 @@ def resolve_plan(
|
||||
)
|
||||
dockerfile_content = (
|
||||
supervise_dockerfile_path.read_text(encoding="utf-8")
|
||||
if supervise_dockerfile_path is not None and supervise_dockerfile_path.is_file()
|
||||
if supervise_dockerfile_path.is_file()
|
||||
else ""
|
||||
)
|
||||
supervise_dir = supervise_state_dir(slug)
|
||||
|
||||
@@ -122,14 +122,11 @@ def resolve_plan(
|
||||
image_default = f"bot-bottle-{provider.template}:{slug}"
|
||||
else:
|
||||
p_dockerfile = provider_obj.dockerfile
|
||||
if p_dockerfile is not None:
|
||||
agent_dockerfile_path = str(p_dockerfile)
|
||||
if provider.template in PROVIDER_TEMPLATES:
|
||||
image_default = provider_runtime.image
|
||||
else:
|
||||
image_default = f"bot-bottle-{provider.template}:{slug}"
|
||||
else:
|
||||
agent_dockerfile_path = str(p_dockerfile)
|
||||
if provider.template in PROVIDER_TEMPLATES:
|
||||
image_default = provider_runtime.image
|
||||
else:
|
||||
image_default = f"bot-bottle-{provider.template}:{slug}"
|
||||
agent_image_ref = image_default
|
||||
agent_provision = agent_provision_plan(
|
||||
template=provider.template,
|
||||
|
||||
Reference in New Issue
Block a user