benchmarl.environments.Task

class Task(value)[source]

Bases: Enum

Enum of tasks in an environment.

Tasks are enums, one enum for each environment. Each enviornment usually contains multiple tasks.

Tasks are used just to enumerate the available tasks, to convert a Task into its corresponding instantiation, you can call Task.get_from_yaml() which will load the task config form yaml into the associated TaskClass.

Each enum member can also be converted to a TaskClass by calling Task.get_task(), (which by default behaves like Task.get_from_yaml()) or by calling get_task(config={...}), providing your own config.

Each new environment should inherit from Task and instantiate its members as:

TASK_1 = None

TASK_2 = None

Tasks configs are loaded from benchmarl/conf/task.

static associated_class() Type[TaskClass][source]

The associated task class

classmethod env_name() str[source]

The name of the environment in the benchmarl/conf/task folder

get_task(config: Dict[str, Any] | None = None) TaskClass[source]

Get the TaskClass object associated with this enum element by passing it the task name and config.

If no config is given, it will be loaded from benchmarl/conf/task/self.env_name()/self.name using Task.get_from_yaml().

Parameters:
  • config (dict) – Optional configuration of the task.

  • provided (If not)

  • yaml. (the default configuration will be loaded from)

Returns:

The TaskClass object for the task.

get_from_yaml(path: str | None = None) TaskClass[source]

Load the task configuration from yaml

Parameters:

path (str, optional) – The full path of the yaml file to load from. If None, it will default to benchmarl/conf/task/self.env_name()/self.name

Returns:

the TaskClass with the loaded config