mpilot.commands

class mpilot.commands.Command(result_name: str, arguments: List[Any] = [], program: Any | None = None, lineno: int | None = None)
inputs: Dict[str, Parameter]

Individual command implementation are expected to set inputs to define their arguments. For example:

class EEMSRead(Command):
  inputs = {
    'InFileName': params.PathParameter(must_exist=True),
    'InFieldName': params.StringParameter()
  }
output: Parameter

The output parameter type for the command. Individual command implementations are expected to set this to the appropriate parameter for their expected output. For example:

class EEMSRead(Command):
  inputs = { ... }
  output = params.DataParameter()
allow_extra_inputs: bool

True indicates that this command accepts any inputs not explicitly defined in inputs. Any extra inputs from the model will be passed unmodified to execute(). Defaults to False.

result: Any

The result from the command execution. Accessing this property will run the command if it hasn’t already been run. Once the command is run, the result is memoized, and accessing this property will simply return the memoized value.

metadata: Dict[str, str]

This property returns any metadata included with the command, as a dictionary. Metadata can be added to any command:

Var_A = EEMSRead(
  InFileName = "input.csv",
  InFieldName = "Var_A",
  Metadata = [
    DisplayName: "Near Roads",
    Description: "Thresholds set using +/- 2 SD from the mean.",
    ColorMap: "PiYG"
  ]
)

The resulting .metadata property for this command will be:

{
  'DisplayName': 'Near Roads',
  'Description': 'Thresholds set using +/- 2 SD from the mean.',
  'ColorMap': 'PiYG'
}
get_argument_value(name: str, default: Any | None = None) Any
validate_params(params: Dict[str, Any]) Dict[str, Any]
run()
execute(**kwargs) Any

The implementation hook for commands. When the command is run, it’s implementation method will be called and passed cleaned and validated arguments as keyword parameters. It should return the appropriate output for the command. This method should not be called directly.