Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Interpretml Interpret Powerlift RunAzureCI

From Leeroopedia


Knowledge Sources
Domains Benchmarking, Cloud_Infrastructure, Azure, Container_Orchestration
Last Updated 2026-02-07 12:00 GMT

Overview

Azure Container Instance provisioning runner that creates, configures, and manages the full lifecycle of ACI container groups for executing Powerlift benchmark trials, including permission assignment, startup scripting, and self-deletion.

Description

This module implements the remote process logic invoked by the AzureContainerInstance executor. It contains two main functions:

assign_contributor_permissions() -- Manages Azure RBAC role assignments for container groups using a priority queue pattern:

  • Uses a min-heap (heapq) to process container groups in order of creation time.
  • Waits for containers to start before assigning the Azure Contributor role to both the container's managed identity and the client user.
  • Retries on HttpResponseError with 1-second delays, recreating API clients as needed.
  • Respects the max_undead parameter to limit the number of unprocessed containers.

run_azure_process() -- Orchestrates the full container lifecycle:

  • Authenticates using ClientSecretCredential or a provided credential object.
  • Retrieves the resource group location from Azure Resource Manager.
  • Creates container groups with configurable CPU, memory, image, and environment variables.
  • Embeds a comprehensive startup shell script that: installs PostgreSQL client, retrieves shell/pip install requirements from the database, downloads and installs wheel files, retrieves and executes the experiment script, handles error recovery for orphaned trials, and self-deletes the container on completion.
  • Monitors container termination and deletes container groups when delete_on_complete is enabled.

The startup script communicates with the PostgreSQL database directly via psql commands, with retry logic (up to 300 retries with 300-second waits) for resilience against transient failures.

Usage

This module is not called directly by users. It is invoked by the AzureContainerInstance executor via multiprocessing.Pool.apply_async(). Understanding this module is essential for debugging Azure container provisioning issues or customizing the container startup behavior.

Code Reference

Source Location

Signature

def assign_contributor_permissions(
    aci_client,
    auth_client,
    max_undead,
    credential,
    subscription_id,
    client_id,
    resource_group_name,
    resource_uris,
    container_groups,
):
    ...

def run_azure_process(
    experiment_id,
    n_instances,
    uri,
    resource_uris,
    timeout,
    image,
    azure_json,
    credential,
    num_cores,
    mem_size_gb,
    max_undead,
    delete_on_complete,
    batch_id,
):
    ...

Import

from powerlift.run.azure_ci import run_azure_process, assign_contributor_permissions

I/O Contract

Inputs

Name Type Required Description
experiment_id int Yes Experiment identifier to run trials for
n_instances int Yes Number of container groups to create
uri str Yes Database connection URI (passed as secure env var)
resource_uris List[str] No Azure resource URIs to grant contributor permissions
timeout float Yes Timeout in seconds per trial execution
image str Yes Docker image for the container
azure_json dict Yes Azure credentials (tenant_id, client_id, client_secret, subscription_id, resource_group)
credential object No Pre-built Azure credential object
num_cores int Yes CPU cores per container
mem_size_gb int Yes Memory in GB per container
max_undead int Yes Maximum unprocessed containers during initialization
delete_on_complete bool Yes Whether to delete containers after trial completion
batch_id int Yes Random batch identifier for naming container groups

Outputs

Name Type Description
assign_contributor_permissions return Tuple Updated (aci_client, auth_client) tuple
run_azure_process return None Function completes when all containers are terminated and deleted

Usage Examples

# This module is invoked internally by AzureContainerInstance executor.
# Direct usage is not recommended. See AzureContainerInstance for the public API.

from powerlift.executors.azure_ci import AzureContainerInstance

executor = AzureContainerInstance(
    store=store,
    azure_tenant_id="...",
    subscription_id="...",
    azure_client_id="...",
    azure_client_secret="...",
    n_instances=4,
)
# submit() internally calls run_azure_process via multiprocessing
executor.submit(experiment_id=1, timeout=3600)
executor.join()

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment