Skip to content

datarobot_genai.drtools.workload.build_status

build_status

Artifact image-build status semantics shared by the workload tools.

Builds progress PENDING -> IN_PROGRESS -> BUILT -> COMPLETED (or FAILED). BUILT and COMPLETED are sequential, not equivalent: BUILT means the image was built locally but has NOT been pushed to the registry yet, so it is not deployable — scheduling a workload on it fails with 422 runtime_image_uri ... None. Only COMPLETED is a green light. Some flows (e.g. Code-to-Workload) report lowercase/dash-cased status variants (pending / in-progress / completed), so statuses are normalized before interpretation.

normalize_build_status

normalize_build_status(status: str) -> str

Uppercase and underscore a build status (in-progress -> IN_PROGRESS).

Source code in datarobot_genai/drtools/workload/build_status.py
def normalize_build_status(status: str) -> str:
    """Uppercase and underscore a build status (``in-progress`` -> ``IN_PROGRESS``)."""
    return (status or "").upper().replace("-", "_")

annotate_build_deployability

annotate_build_deployability(build: dict[str, Any]) -> dict[str, Any]

Return a copy of build with deployable and status_guidance attached.

Unrecognized statuses are returned unchanged rather than guessed at.

Source code in datarobot_genai/drtools/workload/build_status.py
def annotate_build_deployability(build: dict[str, Any]) -> dict[str, Any]:
    """Return a copy of *build* with ``deployable`` and ``status_guidance`` attached.

    Unrecognized statuses are returned unchanged rather than guessed at.
    """
    norm = normalize_build_status(str(build.get("status") or ""))
    guidance = _GUIDANCE_BY_STATUS.get(norm)
    if guidance is None:
        return build
    annotated = dict(build)
    annotated["deployable"] = norm == "COMPLETED"
    annotated["status_guidance"] = guidance
    return annotated

raise_tool_error_for_workload_client_error

raise_tool_error_for_workload_client_error(exc: ClientError) -> NoReturn

Map SDK errors like the shared helper, adding the BUILT-not-pushed 422 hint.

Source code in datarobot_genai/drtools/workload/build_status.py
def raise_tool_error_for_workload_client_error(exc: ClientError) -> NoReturn:
    """Map SDK errors like the shared helper, adding the BUILT-not-pushed 422 hint."""
    sc = getattr(exc, "status_code", None)
    if sc == 422 and "runtime_image_uri" in str(exc):
        raise ToolError(
            f"DataRobot API error ({sc}): {exc}\n{_RUNTIME_IMAGE_URI_HINT}",
            kind=ToolErrorKind.UPSTREAM,
        ) from exc
    raise_tool_error_for_client_error(exc)