minitrino.core.exec.cmd module#

Command execution utilities for Minitrino clusters.

class minitrino.core.exec.cmd.CommandExecutor(ctx: MinitrinoContext)[source][source]#

Bases: object

Execute commands in a subprocess or within a Docker container.

This is a thin dispatcher that delegates to HostCommandExecutor or ContainerCommandExecutor based on the presence of the ‘container’ kwarg.

execute(*args: list[str], **kwargs: Any) list[CommandResult][source][source]#

Execute commands in a subprocess or within a container.

Keyword Arguments:
  • interactive (bool) – If True, runs the command in interactive mode.

  • container (MinitrinoContainer) – The container to run the command in. If not provided, the command will be run on the host via HostCommandExecutor.

  • user (str) – The user to run the command as. If not provided, the command will be run as root.

  • environment (dict) – The environment variables to pass to the command.

  • suppress_output (bool) – If True, suppresses output from the command.

  • trigger_error (bool) – If True, raises an error if the command fails. Defaults to False.

  • timeout (float) – The timeout for the command.

stream_execute(*args: list[str], **kwargs: Any) Iterator[str][source][source]#

Stream output from subprocesses or commands inside containers.

Parameters:
  • *args (list[str]) – A list of arguments to pass to the subprocess or container.

  • **kwargs (dict) – Keyword arguments to pass to the subprocess or container.

Yields:

str – Output lines as they are produced by the command(s).

stream_execute_with_result(command: list[str], **kwargs: Any) tuple[Iterator[str], Event, Callable[[], CommandResult]][source][source]#

Stream output with immediate access to exit code and completion status.

This method enables fast failure detection by providing both streaming output and immediate access to process/command completion status and exit code.

Parameters:
  • command (list[str]) – The command to execute.

  • **kwargs (dict) – Keyword arguments including: - container: If provided, executes in container - user: User for container execution - environment: Environment variables - suppress_output: Whether to suppress logging

Returns:

A tuple containing: - Iterator[str]: Yields output lines as produced - threading.Event: Signals when command has completed - Callable[[], CommandResult]: Returns the final CommandResult

Return type:

Tuple[Iterator[str], threading.Event, Callable[[], CommandResult]]

Raises:

MinitrinoError – If the command is not a list for host execution.