From 16534237e0b3a697edd11f2e8928349328537a5b Mon Sep 17 00:00:00 2001 From: Chris McCarthy Date: Fri, 30 Jun 2023 17:09:50 +0100 Subject: [PATCH] #917 - Dropped VerboseLevel in enums.py and changed OutputVerboseLevel to SB3OutputVerboseLevel --- src/primaite/agents/agent.py | 2 +- src/primaite/agents/sb3.py | 2 +- src/primaite/common/enums.py | 17 +++-------------- .../training/training_config_main.yaml | 8 ++++---- src/primaite/config/training_config.py | 15 ++++++--------- src/primaite/primaite_session.py | 2 +- 6 files changed, 16 insertions(+), 30 deletions(-) diff --git a/src/primaite/agents/agent.py b/src/primaite/agents/agent.py index 90eb2b66..50939210 100644 --- a/src/primaite/agents/agent.py +++ b/src/primaite/agents/agent.py @@ -57,7 +57,7 @@ class AgentSessionABC(ABC): 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: 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._agent = None diff --git a/src/primaite/agents/sb3.py b/src/primaite/agents/sb3.py index 3161c93a..f5ac44cb 100644 --- a/src/primaite/agents/sb3.py +++ b/src/primaite/agents/sb3.py @@ -56,7 +56,7 @@ class SB3Agent(AgentSessionABC): self._agent = self._agent_class( PPOMlp, self._env, - verbose=self.output_verbose_level, + verbose=self.sb3_output_verbose_level, n_steps=self._training_config.num_steps, tensorboard_log=str(self._tensorboard_log_path), ) diff --git a/src/primaite/common/enums.py b/src/primaite/common/enums.py index a363a1a0..db5d153c 100644 --- a/src/primaite/common/enums.py +++ b/src/primaite/common/enums.py @@ -92,14 +92,6 @@ class SessionType(Enum): "Train then evaluate an agent" -class VerboseLevel(IntEnum): - """PrimAITE Session Output verbose level.""" - - NO_OUTPUT = 0 - INFO = 1 - DEBUG = 2 - - class AgentFramework(Enum): """The agent algorithm framework/package.""" @@ -199,12 +191,9 @@ class LinkStatus(Enum): OVERLOAD = 4 -class OutputVerboseLevel(IntEnum): - """The Agent output verbosity level.""" +class SB3OutputVerboseLevel(IntEnum): + """The Stable Baselines3 learn/eval output verbosity level.""" NONE = 0 - "No Output" INFO = 1 - "Info Messages" - ALL = 2 - "All Messages" + DEBUG = 2 diff --git a/src/primaite/config/_package_data/training/training_config_main.yaml b/src/primaite/config/_package_data/training/training_config_main.yaml index 57793058..a414bed9 100644 --- a/src/primaite/config/_package_data/training/training_config_main.yaml +++ b/src/primaite/config/_package_data/training/training_config_main.yaml @@ -60,12 +60,12 @@ session_type: TRAIN_EVAL # The high value for the observation space observation_space_high_value: 1000000000 -# The Agent output verbosity level: +# The Stable Baselines3 learn/eval output verbosity level: # Options are: # "NONE" (No Output) -# "INFO" (Info Messages) -# "ALL" (All Messages) -output_verbose_level: NONE +# "INFO" (Info Messages (such as devices and wrappers used)) +# "DEBUG" (All Messages) +sb3_output_verbose_level: NONE # Reward values # Generic diff --git a/src/primaite/config/training_config.py b/src/primaite/config/training_config.py index 3e0f26ca..2ffc2a8c 100644 --- a/src/primaite/config/training_config.py +++ b/src/primaite/config/training_config.py @@ -14,7 +14,7 @@ from primaite.common.enums import ( AgentIdentifier, DeepLearningFramework, HardCodedAgentView, - OutputVerboseLevel, + SB3OutputVerboseLevel, SessionType, ) @@ -86,8 +86,8 @@ class TrainingConfig: observation_space_high_value: int = 1000000000 "The high value for the observation space" - output_verbose_level: OutputVerboseLevel = OutputVerboseLevel.INFO - "The Agent output verbosity level" + sb3_output_verbose_level: SB3OutputVerboseLevel = SB3OutputVerboseLevel.NONE + "Stable Baselines3 learn/eval output verbosity level" # Reward values # Generic @@ -189,7 +189,7 @@ class TrainingConfig: "agent_identifier": AgentIdentifier, "action_type": ActionType, "session_type": SessionType, - "output_verbose_level": OutputVerboseLevel, + "sb3_output_verbose_level": SB3OutputVerboseLevel, "hard_coded_agent_view": HardCodedAgentView, } @@ -212,7 +212,7 @@ class TrainingConfig: data["deep_learning_framework"] = self.deep_learning_framework.name data["agent_identifier"] = self.agent_identifier.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["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, action_type: ActionType = ActionType.ANY, num_steps: int = 256, - output_verbose_level: OutputVerboseLevel = OutputVerboseLevel.INFO, ) -> Dict[str, Any]: """ 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. :param num_steps: The number of steps to set as legacy training configs 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. """ config_dict = { @@ -300,7 +297,7 @@ def convert_legacy_training_config_dict( "agent_identifier": agent_identifier.name, "action_type": action_type.name, "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"} legacy_config_dict["sessionType"] = session_type_map[legacy_config_dict["sessionType"]] diff --git a/src/primaite/primaite_session.py b/src/primaite/primaite_session.py index 4ee6c507..df3ebec1 100644 --- a/src/primaite/primaite_session.py +++ b/src/primaite/primaite_session.py @@ -75,7 +75,7 @@ class PrimaiteSession: raise ValueError 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: self._agent_session = DoNothingNodeAgent(self._training_config_path, self._lay_down_config_path)