API Reference
This page provides the technical API reference for the cloudmesh-ai-cmc library, automatically generated from the source code.
Modules
context
CMC Context Initialization.
This module initializes the global state for the Cloudmesh AI CMC application, including configuration loading, logging setup, and telemetry initialization.
Global Objects
config (Config): The application configuration object. logger (Logger): The main application logger. telemetry (Telemetry): The telemetry collection object.
Classes
Functions:
Modules
main
Classes
DelegatingCommand
Bases: Group
A command that delegates execution to another click object.
This is used to handle cases where a command is loaded from a different Click version or instance, preventing version mismatch errors.
Source code in src/cloudmesh/ai/cmc/main.py
Methods:
Initializes the DelegatingCommand.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the command. |
required |
delegate
|
Any
|
The actual click object or factory to delegate to. |
required |
**kwargs
|
Additional arguments passed to the click.Group constructor. |
{}
|
Source code in src/cloudmesh/ai/cmc/main.py
Overrides get_command to delegate subcommand retrieval to the delegate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
Context
|
The Click context. |
required |
name
|
str
|
The name of the command to retrieve. |
required |
Returns:
| Type | Description |
|---|---|
|
click.Command: The retrieved command from the delegate, or None. |
Source code in src/cloudmesh/ai/cmc/main.py
Invokes the delegate object with the provided context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
Context
|
The Click context containing the arguments. |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the delegate cannot be resolved or is not callable. |
Source code in src/cloudmesh/ai/cmc/main.py
LazyCommand
dataclass
Represents a command that is loaded lazily from a module.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
The name of the command. |
module_name |
str
|
The name of the module containing the command. |
entry_point_name |
str
|
The name of the entry point function/object in the module. |
hidden |
bool
|
Whether the command should be hidden from help output. Defaults to False. |
Source code in src/cloudmesh/ai/cmc/main.py
Methods:
Returns a short help string for the lazy-loaded command.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
limit
|
int
|
Maximum length of the help string. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
A short description of the command. |
Source code in src/cloudmesh/ai/cmc/main.py
SubcommandHelpGroup
Bases: Group
Custom Click Group to show subcommands in help output with dynamic width.
This group overrides the default command retrieval and formatting to support lazy loading of extensions and to ensure help text utilizes the full terminal width.
Source code in src/cloudmesh/ai/cmc/main.py
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 | |
Methods:
Overwrites the default command formatting for full terminal width.
Ensures that help text is not prematurely truncated by syncing the formatter width with the actual terminal size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
Context
|
The Click context. |
required |
formatter
|
HelpFormatter
|
The formatter to use. |
required |
Source code in src/cloudmesh/ai/cmc/main.py
Retrieves a command, supporting lazy loading of extensions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
Context
|
The Click context. |
required |
name
|
str
|
The name of the command to retrieve. |
required |
Returns:
| Type | Description |
|---|---|
|
click.Command: The loaded command, or None if not found. |
Source code in src/cloudmesh/ai/cmc/main.py
Functions:
alias_plugins_check
Alias for plugins check.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
Context
|
The Click context. |
required |
Source code in src/cloudmesh/ai/cmc/main.py
alias_plugins_list
Alias for plugins list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
Context
|
The Click context. |
required |
Source code in src/cloudmesh/ai/cmc/main.py
alias_telemetry
Alias for telemetry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
Context
|
The Click context. |
required |
alias_version
Alias for version.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
Context
|
The Click context. |
required |
cli
cmc: Cloudmesh Commands.
The main entry point for the Cloudmesh AI CMC tool.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
Context
|
The Click context. |
required |
debug
|
bool
|
Whether to enable debug logging. |
required |
Source code in src/cloudmesh/ai/cmc/main.py
generate_completion_script
Prints the shell completion script for the specified shell type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shell_type
|
str
|
The type of shell (e.g., 'bash_source', 'zsh_source', 'fish_source'). |
required |
Source code in src/cloudmesh/ai/cmc/main.py
handle_completion
Manually handles shell completion requests.
This function is called when the environment variable CLICOMPLETE=1 is set. It determines the current word being typed and suggests matching commands or subcommands.
Source code in src/cloudmesh/ai/cmc/main.py
432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 | |
load_core_extensions
Recursively loads all core extensions from the command directory.
Iterates through the cloudmesh.ai.command package and adds any found
Click commands or groups to the provided CLI object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cli
|
Group
|
The main CLI group to which extensions are added. |
required |
Source code in src/cloudmesh/ai/cmc/main.py
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 | |
load_pip_extensions
Loads extensions installed via pip using entry points lazily.
Searches for entry points in the 'cloudmesh.ai.command' group and adds them as LazyCommand objects to the CLI.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cli
|
Group
|
The main CLI group to which extensions are added. |
required |
Source code in src/cloudmesh/ai/cmc/main.py
main
Main entry point for the CMC application.
Initializes pip extensions and invokes the Click CLI.
Source code in src/cloudmesh/ai/cmc/main.py
Modules
utils
Classes
CMCError
Config
Handles configuration for CMC from a YAML file.
Source code in src/cloudmesh/ai/cmc/utils.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
Methods:
Initializes the Config object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_path
|
Optional[Path]
|
Path to the configuration file. Defaults to DEFAULT_CONFIG_PATH if not provided. |
None
|
Source code in src/cloudmesh/ai/cmc/utils.py
Gets a value from the config using a dot-separated path.
Environment variables can override config values. For example, 'telemetry.path' can be overridden by 'CMC_TELEMETRY_PATH'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key_path
|
str
|
Dot-separated path to the configuration value. |
required |
default
|
Any
|
Value to return if the key is not found. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The configuration value or the default value. |
Source code in src/cloudmesh/ai/cmc/utils.py
Saves the current configuration to the YAML file.
Raises:
| Type | Description |
|---|---|
Exception
|
If the configuration file cannot be saved. |
Sets a value in the config using a dot-separated path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key_path
|
str
|
Dot-separated path to the configuration value. |
required |
value
|
Any
|
The value to set. |
required |
Source code in src/cloudmesh/ai/cmc/utils.py
Validates a configuration value against the schema if it exists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key_path
|
str
|
Dot-separated path to the configuration value. |
required |
value
|
Any
|
The value to validate. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the value does not match the expected type in the schema. |
Source code in src/cloudmesh/ai/cmc/utils.py
PluginDependencyError
PluginVersionError
Registry
Manages the registration and status of AI extensions.
Persists extension metadata within the main CMC configuration file.
Source code in src/cloudmesh/ai/cmc/utils.py
Methods:
Returns a list of all registered extensions with their details.
Registers a new extension path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the extension. |
required |
directory
|
str
|
Path to the extension directory. |
required |
Source code in src/cloudmesh/ai/cmc/utils.py
Updates the active status of an extension.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if updated, False if extension not found. |
Source code in src/cloudmesh/ai/cmc/utils.py
Functions:
handle_errors
Decorator to provide standardized error handling for CMC commands.
Logs the full traceback for developers, emits a telemetry failure if available, and displays a clean, user-friendly error message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
Callable
|
The function to be wrapped. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Callable |
The wrapped function. |
Source code in src/cloudmesh/ai/cmc/utils.py
register_group_extensions
Iteratively loads all modules in a package and calls their register() function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent_group
|
Any
|
The parent group to register extensions to. |
required |
group_package
|
Module
|
The package containing the extension modules. |
required |
child_target
|
Any
|
An alternative target for registration. Defaults to parent_group if not provided. |
None
|