minitrino.core.context module#

Core context and controls for Minitrino CLI.

class minitrino.core.context.MinitrinoContext[source][source]#

Bases: object

Expose context and core controls to CLI scripts.

cluster[source]#

Cluster interface.

Type:

Cluster

logger[source]#

Logs CLI activity.

Type:

MinitrinoLogger

env[source]#

CLI environment variables, subdivided by sections.

Type:

EnvironmentVariables

modules[source]#

Metadata about Minitrino modules.

Type:

Modules

cmd_executor[source]#

Executes shell commands in host and containers.

Type:

CommandExecutor

docker_client[source]#

Docker client for high-level API access.

Type:

docker.DockerClient

api_client[source]#

Docker API client for low-level access.

Type:

docker.APIClient

all_clusters[source]#

If True, operations are applied to all clusters.

Type:

bool

user_home_dir[source]#

Home directory of the current user.

Type:

str

minitrino_user_dir[source]#

Path to ~/.minitrino/ directory.

Type:

str

config_file[source]#

Path to user’s minitrino.cfg file.

Type:

str

snapshot_dir[source]#

Path to snapshot directory for temporary tarballs.

Type:

str

lib_dir[source]#

Path to Minitrino’s library directory.

Type:

str

initialize()[source][source]#

Hydrate the context with user-provided inputs.

Notes

The lib_dir property cannot be accessed prior to _lib_safe being set to True, which occurs early during initialize(). The idea is to force any user-provided env vars (since one of them may be LIB_PATH) to load before we attempt to do anything with the library.

library_manager: LibraryManager[source]#
all_clusters: bool[source]#
provisioned_clusters: list[str][source]#
logger: MinitrinoLogger[source]#
cluster: Cluster[source]#
env: EnvironmentVariables[source]#
modules: Modules[source]#
cmd_executor: CommandExecutor[source]#
docker_client: DockerClient | None[source]#
api_client: APIClient | None[source]#
user_home_dir: str[source]#
minitrino_user_dir: str[source]#
config_file: str[source]#
snapshot_dir: str[source]#
initialize(cluster_name: str = '', version_only: bool = False, log_level: LogLevel | None = None) None[source][source]#

Initialize core CLI context attributes.

This method sets up logging, environment variables, and context-specific resources like the cluster and Docker clients. If version_only is True, initialization is limited to what is required to resolve the CLI and library versions.

Parameters:
  • cluster_name (str, optional) – The cluster name to scope operations to. Defaults to “default”.

  • version_only (bool, optional) – If True, initializes only the attributes required for version fetching (e.g. minitrino –version).

  • log_level (LogLevel, optional) – The log level to set for the logger.

property user_log_level: LogLevel[source]#

The user-configured log level for this context.

Immutable once set.

Returns:

The immutable log level set by the user or default (INFO).

Return type:

LogLevel

property lib_dir: str[source]#

Get the library directory.

Returns:

Path to the resolved library directory.

Return type:

str

Notes

The directory is determined using the following order of precedence:

  1. Use LIB_PATH if provided via environment.

  2. Check if the library exists relative to the location of this file, assuming the project is running in a repository context.