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 Executor

From Leeroopedia
Revision as of 15:17, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Interpretml_Interpret_Powerlift_Executor.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Knowledge Sources
Domains Benchmarking, Execution
Last Updated 2026-02-07 12:00 GMT

Overview

Abstract base class defining the executor interface for Powerlift trial execution, along with utility functions for timed execution and error handling.

Description

This module provides the foundational abstractions for all Powerlift executors:

  • Executor class -- An abstract base class that defines the three core lifecycle methods for trial execution: submit() to start asynchronous execution, join() to block until completion, and cancel() to abort execution. All methods raise NotImplementedError by default and must be overridden by concrete implementations.
  • timed_run() function -- A utility that executes a callable with a configurable timeout (default 3600 seconds) using stopit.ThreadingTimeout. Returns a tuple of (result, duration, timed_out). If the function times out, the result is set to None.
  • handle_err() function -- A simple error callback that re-raises a provided exception. Used as the error_callback parameter in multiprocessing pool submissions across executor implementations.

Usage

Use this module as the base for implementing custom Powerlift executors. All concrete executor classes (LocalMachine, AzureContainerInstance, AzureVMInstance, InsecureDocker, BicepAzureContainerInstance) extend this base class. The timed_run function is used by the trial runner to enforce execution time limits.

Code Reference

Source Location

Signature

class Executor:
    def submit(
        self,
        experiment_id,
        timeout: Optional[int] = None,
    ):
        raise NotImplementedError()

    def join(self):
        raise NotImplementedError()

    def cancel(self):
        raise NotImplementedError()

def timed_run(f: FunctionType, timeout_seconds: int = 3600) -> Tuple[Any, Number, bool]:
    ...

def handle_err(err: Exception):
    raise err

Import

from powerlift.executors.base import Executor, timed_run, handle_err

I/O Contract

Inputs

Name Type Required Description
experiment_id int Yes Identifier of the experiment to execute (for submit)
timeout int No Timeout in seconds for trial execution (for submit)
f FunctionType Yes Function to execute with time limit (for timed_run)
timeout_seconds int No Maximum execution time in seconds (default: 3600, for timed_run)
err Exception Yes Exception to re-raise (for handle_err)

Outputs

Name Type Description
timed_run return Tuple[Any, Number, bool] Tuple of (function result, duration in seconds, whether timeout occurred)

Usage Examples

from powerlift.executors.base import Executor, timed_run

# Using timed_run to execute a function with timeout
def expensive_computation():
    # ... long-running computation
    return result

result, duration, timed_out = timed_run(expensive_computation, timeout_seconds=300)
if timed_out:
    print(f"Computation timed out after {duration:.1f}s")
else:
    print(f"Completed in {duration:.1f}s with result: {result}")

# Implementing a custom executor
class MyExecutor(Executor):
    def submit(self, experiment_id, timeout=None):
        # Custom submission logic
        pass

    def join(self):
        # Block until complete
        pass

    def cancel(self):
        # Cancel running execution
        pass

Related Pages

Page Connections

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