Skip to content

Server

zenml.cli.server

CLI for managing ZenML server deployments.

get_active_deployment(local=False)

Get the active local or remote server deployment.

Call this function to retrieve the local or remote server deployment that was last provisioned on this machine.

Parameters:

Name Type Description Default
local bool

Whether to return the local active deployment or the remote one.

False

Returns:

Type Description
Optional[ServerDeployment]

The local or remote active server deployment or None, if no deployment was found.

Source code in zenml/cli/server.py
def get_active_deployment(local: bool = False) -> Optional["ServerDeployment"]:
    """Get the active local or remote server deployment.

    Call this function to retrieve the local or remote server deployment that
    was last provisioned on this machine.

    Args:
        local: Whether to return the local active deployment or the remote one.

    Returns:
        The local or remote active server deployment or None, if no deployment
        was found.
    """
    from zenml.zen_server.deploy.deployer import ServerDeployer

    deployer = ServerDeployer()
    if local:
        servers = deployer.list_servers(provider_type=ServerProviderType.LOCAL)
        if not servers:
            servers = deployer.list_servers(
                provider_type=ServerProviderType.DOCKER
            )
    else:
        servers = deployer.list_servers()

    if not servers:
        return None

    for server in servers:
        if server.config.provider in [
            ServerProviderType.LOCAL,
            ServerProviderType.DOCKER,
        ]:
            if local:
                return server
        elif not local:
            return server

    return None