mlrl.testbed.command module

Author: Michael Rapp (michael.rapp.ml@gmail.com)

Provides classes for dealing with commands and their arguments.

class mlrl.testbed.command.ArgumentDict

Bases: dict[str, str | None]

A dictionary that stores the names of command line arguments, as well as their associated values, if available.

to_list() ArgumentList

Creates and returns an ArgumentList from this dictionary.

Returns:

The ArgumentList that has been created

class mlrl.testbed.command.ArgumentList(iterable=(), /)

Bases: list[str]

A list that stores command line arguments.

filter(*arguments_to_be_ignored: str) ArgumentList

Creates and returns an ArgumentList by filtering the arguments in this list.

Parameters:

arguments_to_be_ignored – The names of the arguments to be ignored

Returns:

The ArgumentList that has been created

to_dict() ArgumentDict

Creates and returns an ArgumentDict from this list.

Returns:

The ArgumentDict that has been created

class mlrl.testbed.command.Command(module_name: str, argument_dict: ArgumentDict, argument_list: ArgumentList)

Bases: Iterable[str]

A command for running MLRL-Testbed, consisting of a module name and several arguments.

Attributes:

module_name: The name of the Python module argument_dict: An ArgumentDict that stores the arguments of the command argument_list: An ArgumentList that stores the arguments of the command

apply_to_namespace(namespace: Namespace, ignore: set[str] | None = None) Namespace

Adds the command’s arguments to a given namespace.

Parameters:
  • namespace – The namespace, the arguments should be added to

  • ignore – A set that contains the names of arguments to be ignored or None, if all argument should be added

Returns:

The modified namespace

argument_dict: ArgumentDict
argument_list: ArgumentList
static from_argv() Command

Creates and returns a command from sys.argv.

Returns:

The command that has been created

static from_dict(module_name: str, argument_dict: ArgumentDict) Command

Creates and returns a command from a given ArgumentDict.

Parameters:
  • module_name – The name of the Python module

  • argument_dict – The ArgumentDict, the command should be created from

Returns:

The command that has been created

static from_list(module_name: str, argument_list: ArgumentList) Command

Creates and returns a command from a given ArgumentList.

Parameters:
  • module_name – The name of the Python module

  • argument_list – The ArgumentList, the command should be created from

Returns:

The command that has been created

static from_string(string: str) Command

Creates and returns a command from a given string.

Parameters:

string – The string, the command should be created from

Returns:

The command that has been created

module_name: str
to_namespace(ignore: set[str] | None = None) Namespace

Creates and returns a namespace from the command’s arguments.

Parameters:

ignore – A set that contains the names of arguments to be ignored or None, if all argument should be added

Returns:

The namespace that has been created

static with_argument(command: Command, argument: str, value: str) Command

Creates and returns a modified variant of a command, where a specific argument set to a given value.

Parameters:
  • command – The command to modify

  • argument – The name of the argument to be set

  • value – The value to be set

Returns:

The modified command