From a7bfc56b98bd93f8c4043ffae678e72faa34f8f3 Mon Sep 17 00:00:00 2001 From: Marek Wolan Date: Tue, 5 Mar 2024 11:21:49 +0000 Subject: [PATCH] Apply documentation changes based on PR review. --- CHANGELOG.md | 2 +- docs/source/configuration/io_settings.rst | 12 +----------- src/primaite/session/io.py | 12 +++++++----- src/primaite/session/session.py | 2 +- 4 files changed, 10 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8064a18e..cdf7b5c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,7 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed the order of service health state - Fixed an issue where starting a node didn't start the services on it - Added support for SQL INSERT command. -- Added ability to log each agent's action choices each step to a JSON file. +- Added ability to log each agent's action choices in each step to a JSON file. diff --git a/docs/source/configuration/io_settings.rst b/docs/source/configuration/io_settings.rst index e5c6d2ce..f9704541 100644 --- a/docs/source/configuration/io_settings.rst +++ b/docs/source/configuration/io_settings.rst @@ -18,7 +18,6 @@ This section configures how PrimAITE saves data during simulation and training. checkpoint_interval: 10 # save_logs: True # save_transactions: False - # save_tensorboard_logs: False save_agent_actions: True save_step_metadata: False save_pcap_logs: False @@ -56,21 +55,12 @@ Defines how often to save the policy during training. *currently unused*. -``save_transactions`` ---------------------- - -*currently unused*. - -``save_tensorboard_logs`` -------------------------- - -*currently unused*. ``save_agent_actions`` Optional. Default value is ``True``. -If ``True``, this will create a JSON file each episode detailing every agent's action each step in that episode, formatted according to the CAOS format. This includes scripted, RL, and red agents. +If ``True``, this will create a JSON file each episode detailing every agent's action in each step of that episode, formatted according to the CAOS format. This includes scripted, RL, and red agents. ``save_step_metadata`` ---------------------- diff --git a/src/primaite/session/io.py b/src/primaite/session/io.py index 22d9dbeb..3e21ed16 100644 --- a/src/primaite/session/io.py +++ b/src/primaite/session/io.py @@ -15,7 +15,7 @@ class PrimaiteIO: """ Class for managing session IO. - Currently it's handling path generation, but could expand to handle loading, transaction, tensorboard, and so on. + Currently it's handling path generation, but could expand to handle loading, transaction, and so on. """ class Settings(BaseModel): @@ -27,8 +27,6 @@ class PrimaiteIO: """Whether to save logs""" save_agent_actions: bool = True """Whether to save a log of all agents' actions every step.""" - save_transactions: bool = True - """Whether to save transactions, If true, the session path will have a transactions folder.""" save_step_metadata: bool = False """Whether to save the RL agents' action, environment state, and other data at every single step.""" save_pcap_logs: bool = False @@ -37,6 +35,12 @@ class PrimaiteIO: """Whether to save system logs.""" def __init__(self, settings: Optional[Settings] = None) -> None: + """ + Init the PrimaiteIO object. + + Note: Instantiating this object creates a new directory for outputs, and sets the global SIM_OUTPUT variable. + It is intended that this object is instantiated when a new environment is created. + """ self.settings = settings or PrimaiteIO.Settings() self.session_path: Path = self.generate_session_path() # set global SIM_OUTPUT path @@ -45,8 +49,6 @@ class PrimaiteIO: SIM_OUTPUT.save_sys_logs = self.settings.save_sys_logs self.agent_action_log: List[Dict] = [] - # warning TODO: must be careful not to re-initialise sessionIO because it will create a new path each time it's - # possible refactor needed def generate_session_path(self, timestamp: Optional[datetime] = None) -> Path: """Create a folder for the session and return the path to it.""" diff --git a/src/primaite/session/session.py b/src/primaite/session/session.py index 84dd9b2f..9c935ae3 100644 --- a/src/primaite/session/session.py +++ b/src/primaite/session/session.py @@ -61,7 +61,7 @@ class PrimaiteSession: """Primaite Game object for managing main simulation loop and agents.""" self.save_checkpoints: bool = False - """Whether to save chcekpoints.""" + """Whether to save checkpoints.""" self.checkpoint_interval: int = 10 """If save_checkpoints is true, checkpoints will be saved every checkpoint_interval episodes."""