#917 - Dropped VerboseLevel in enums.py and changed OutputVerboseLevel to SB3OutputVerboseLevel

This commit is contained in:
Chris McCarthy
2023-06-30 17:09:50 +01:00
parent e11fd2ced4
commit 06d5004695
6 changed files with 16 additions and 30 deletions

View File

@@ -57,7 +57,7 @@ class AgentSessionABC(ABC):
lay_down_config_path = Path(lay_down_config_path) lay_down_config_path = Path(lay_down_config_path)
self._lay_down_config_path: Final[Union[Path]] = lay_down_config_path self._lay_down_config_path: Final[Union[Path]] = lay_down_config_path
self._lay_down_config: Dict = lay_down_config.load(self._lay_down_config_path) self._lay_down_config: Dict = lay_down_config.load(self._lay_down_config_path)
self.output_verbose_level = self._training_config.output_verbose_level self.sb3_output_verbose_level = self._training_config.sb3_output_verbose_level
self._env: Primaite self._env: Primaite
self._agent = None self._agent = None

View File

@@ -56,7 +56,7 @@ class SB3Agent(AgentSessionABC):
self._agent = self._agent_class( self._agent = self._agent_class(
PPOMlp, PPOMlp,
self._env, self._env,
verbose=self.output_verbose_level, verbose=self.sb3_output_verbose_level,
n_steps=self._training_config.num_steps, n_steps=self._training_config.num_steps,
tensorboard_log=str(self._tensorboard_log_path), tensorboard_log=str(self._tensorboard_log_path),
) )

View File

@@ -92,14 +92,6 @@ class SessionType(Enum):
"Train then evaluate an agent" "Train then evaluate an agent"
class VerboseLevel(IntEnum):
"""PrimAITE Session Output verbose level."""
NO_OUTPUT = 0
INFO = 1
DEBUG = 2
class AgentFramework(Enum): class AgentFramework(Enum):
"""The agent algorithm framework/package.""" """The agent algorithm framework/package."""
@@ -199,12 +191,9 @@ class LinkStatus(Enum):
OVERLOAD = 4 OVERLOAD = 4
class OutputVerboseLevel(IntEnum): class SB3OutputVerboseLevel(IntEnum):
"""The Agent output verbosity level.""" """The Stable Baselines3 learn/eval output verbosity level."""
NONE = 0 NONE = 0
"No Output"
INFO = 1 INFO = 1
"Info Messages" DEBUG = 2
ALL = 2
"All Messages"

View File

@@ -60,12 +60,12 @@ session_type: TRAIN_EVAL
# The high value for the observation space # The high value for the observation space
observation_space_high_value: 1000000000 observation_space_high_value: 1000000000
# The Agent output verbosity level: # The Stable Baselines3 learn/eval output verbosity level:
# Options are: # Options are:
# "NONE" (No Output) # "NONE" (No Output)
# "INFO" (Info Messages) # "INFO" (Info Messages (such as devices and wrappers used))
# "ALL" (All Messages) # "DEBUG" (All Messages)
output_verbose_level: NONE sb3_output_verbose_level: NONE
# Reward values # Reward values
# Generic # Generic

View File

@@ -14,7 +14,7 @@ from primaite.common.enums import (
AgentIdentifier, AgentIdentifier,
DeepLearningFramework, DeepLearningFramework,
HardCodedAgentView, HardCodedAgentView,
OutputVerboseLevel, SB3OutputVerboseLevel,
SessionType, SessionType,
) )
@@ -86,8 +86,8 @@ class TrainingConfig:
observation_space_high_value: int = 1000000000 observation_space_high_value: int = 1000000000
"The high value for the observation space" "The high value for the observation space"
output_verbose_level: OutputVerboseLevel = OutputVerboseLevel.INFO sb3_output_verbose_level: SB3OutputVerboseLevel = SB3OutputVerboseLevel.NONE
"The Agent output verbosity level" "Stable Baselines3 learn/eval output verbosity level"
# Reward values # Reward values
# Generic # Generic
@@ -189,7 +189,7 @@ class TrainingConfig:
"agent_identifier": AgentIdentifier, "agent_identifier": AgentIdentifier,
"action_type": ActionType, "action_type": ActionType,
"session_type": SessionType, "session_type": SessionType,
"output_verbose_level": OutputVerboseLevel, "sb3_output_verbose_level": SB3OutputVerboseLevel,
"hard_coded_agent_view": HardCodedAgentView, "hard_coded_agent_view": HardCodedAgentView,
} }
@@ -212,7 +212,7 @@ class TrainingConfig:
data["deep_learning_framework"] = self.deep_learning_framework.name data["deep_learning_framework"] = self.deep_learning_framework.name
data["agent_identifier"] = self.agent_identifier.name data["agent_identifier"] = self.agent_identifier.name
data["action_type"] = self.action_type.name data["action_type"] = self.action_type.name
data["output_verbose_level"] = self.output_verbose_level.name data["sb3_output_verbose_level"] = self.sb3_output_verbose_level.name
data["session_type"] = self.session_type.name data["session_type"] = self.session_type.name
data["hard_coded_agent_view"] = self.hard_coded_agent_view.name data["hard_coded_agent_view"] = self.hard_coded_agent_view.name
@@ -277,7 +277,6 @@ def convert_legacy_training_config_dict(
agent_identifier: AgentIdentifier = AgentIdentifier.PPO, agent_identifier: AgentIdentifier = AgentIdentifier.PPO,
action_type: ActionType = ActionType.ANY, action_type: ActionType = ActionType.ANY,
num_steps: int = 256, num_steps: int = 256,
output_verbose_level: OutputVerboseLevel = OutputVerboseLevel.INFO,
) -> Dict[str, Any]: ) -> Dict[str, Any]:
""" """
Convert a legacy training config dict to the new format. Convert a legacy training config dict to the new format.
@@ -291,8 +290,6 @@ def convert_legacy_training_config_dict(
don't have action_type values. don't have action_type values.
:param num_steps: The number of steps to set as legacy training configs :param num_steps: The number of steps to set as legacy training configs
don't have num_steps values. don't have num_steps values.
:param output_verbose_level: The agent output verbose level to use as
legacy training configs don't have output_verbose_level values.
:return: The converted training config dict. :return: The converted training config dict.
""" """
config_dict = { config_dict = {
@@ -300,7 +297,7 @@ def convert_legacy_training_config_dict(
"agent_identifier": agent_identifier.name, "agent_identifier": agent_identifier.name,
"action_type": action_type.name, "action_type": action_type.name,
"num_steps": num_steps, "num_steps": num_steps,
"output_verbose_level": output_verbose_level.name, "sb3_output_verbose_level": SB3OutputVerboseLevel.INFO.name,
} }
session_type_map = {"TRAINING": "TRAIN", "EVALUATION": "EVAL"} session_type_map = {"TRAINING": "TRAIN", "EVALUATION": "EVAL"}
legacy_config_dict["sessionType"] = session_type_map[legacy_config_dict["sessionType"]] legacy_config_dict["sessionType"] = session_type_map[legacy_config_dict["sessionType"]]

View File

@@ -75,7 +75,7 @@ class PrimaiteSession:
raise ValueError raise ValueError
elif self._training_config.agent_identifier == AgentIdentifier.DO_NOTHING: elif self._training_config.agent_identifier == AgentIdentifier.DO_NOTHING:
_LOGGER.debug(f"PrimaiteSession Setup: Agent Identifier =" f" {AgentIdentifier.DO_NOTHINGD}") _LOGGER.debug(f"PrimaiteSession Setup: Agent Identifier =" f" {AgentIdentifier.DO_NOTHING}")
if self._training_config.action_type == ActionType.NODE: if self._training_config.action_type == ActionType.NODE:
self._agent_session = DoNothingNodeAgent(self._training_config_path, self._lay_down_config_path) self._agent_session = DoNothingNodeAgent(self._training_config_path, self._lay_down_config_path)