| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- """NoOp builder implementation."""
- from __future__ import annotations
- from typing import Any
- from wandb.sdk.launch.builder.abstract import AbstractBuilder
- from wandb.sdk.launch.environment.abstract import AbstractEnvironment
- from wandb.sdk.launch.errors import LaunchError
- from wandb.sdk.launch.registry.abstract import AbstractRegistry
- from .._project_spec import EntryPoint, LaunchProject
- from ..agent.job_status_tracker import JobAndRunStatusTracker
- class NoOpBuilder(AbstractBuilder):
- """NoOp builder."""
- type = "noop"
- def __init__(
- self,
- builder_config: dict[str, Any],
- environment: AbstractEnvironment,
- registry: AbstractRegistry,
- ) -> None:
- """Initialize a NoOpBuilder."""
- self.environment = environment
- self.registry = registry
- @classmethod
- def from_config(
- cls,
- config: dict,
- environment: AbstractEnvironment,
- registry: AbstractRegistry,
- verify: bool = True,
- ) -> AbstractBuilder:
- """Create a noop builder from a config."""
- return cls(config, environment, registry)
- async def verify(self) -> None:
- """Verify the builder."""
- raise LaunchError("Attempted to verify noop builder.")
- async def build_image(
- self,
- launch_project: LaunchProject,
- entrypoint: EntryPoint,
- job_tracker: JobAndRunStatusTracker | None = None,
- ) -> str:
- """Build the image.
- For this we raise a launch error since it can't build.
- """
- raise LaunchError(
- "Attempted build with noop builder. Specify a builder in your launch config at ~/.config/wandb/launch-config.yaml.\n"
- "Note: Jobs sourced from git repos and code artifacts require a builder, while jobs sourced from Docker images do not.\n"
- "See https://docs.wandb.ai/platform/launch/create-job."
- )
|