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) Namespace

Adds the command’s arguments to a given namespace.

Parameters:

namespace – The namespace, the arguments should be added to

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

module_name: str