Skip to content

Container adapter

terminate_running_containers(containers, interactive_mode=True) ΒΆ

Parameters:

Name Type Description Default
containers List[Container]

List of containers to handle

required
interactive_mode bool

Flag to determine if user prompt should decide on container termination

True

boolean value that informs if there are containers that have not received SIGKILL

Type Description
bool

as a result of procedure.

Source code in inference_cli/lib/container_adapter.py
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
def terminate_running_containers(
    containers: List[Container], interactive_mode: bool = True
) -> bool:
    """
    Args:
        containers (List[Container]): List of containers to handle
        interactive_mode (bool): Flag to determine if user prompt should decide on container termination

    Returns: boolean value that informs if there are containers that have not received SIGKILL
        as a result of procedure.
    """
    running_inference_containers = [
        c for c in containers if is_container_running(container=c)
    ]
    containers_to_kill = running_inference_containers
    if interactive_mode:
        containers_to_kill = [
            c for c in running_inference_containers if ask_user_to_kill_container(c)
        ]
    kill_containers(containers=containers_to_kill)
    return len(containers_to_kill) < len(running_inference_containers)